Skip to content

Instantly share code, notes, and snippets.

@sonerb
Created April 17, 2020 22:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sonerb/015f44d340f4d452ea2082f4d19b5618 to your computer and use it in GitHub Desktop.
Save sonerb/015f44d340f4d452ea2082f4d19b5618 to your computer and use it in GitHub Desktop.
This script unfollow your followings except your followers for Twitter.
users = document.querySelectorAll("div[data-testid$=-unfollow]");
user_idx = 0;
function callReload()
{
users = document.querySelectorAll("div[data-testid$=-unfollow]");
user_idx = 0;
callClick();
}
function callClick()
{
if (user_idx < users.length)
{
user = users[user_idx++];
if (user.parentElement.parentElement.querySelectorAll("div > div > div > a > div > div:nth-child(2) > div").length == 1)
{
user.click();
setTimeout(callUnfollow, 100);
}
else
{
callClick();
}
}
else
{
window.scrollTo(0,document.querySelector("body").scrollHeight);
setTimeout(callReload, 250);
}
}
function callUnfollow()
{
if (document.querySelector("div[data-testid=confirmationSheetConfirm]") != null)
{
document.querySelector("div[data-testid=confirmationSheetConfirm]").click();
setTimeout(callClick, 100);
}
else
{
setTimeout(callClick, 100);
console.log('I can\'t found unfollow button');
}
}
callClick();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment