Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gui25/639ac97083b9e3df3ea055f61412674a to your computer and use it in GitHub Desktop.
Save gui25/639ac97083b9e3df3ea055f61412674a to your computer and use it in GitHub Desktop.

Revisions

  1. gui25 revised this gist Dec 20, 2021. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion unfollow-non-followers-twitter.js
    Original file line number Diff line number Diff line change
    @@ -21,7 +21,7 @@
    */


    var LANGUAGE = "EN"; //NOTE: change it to use your language!
    var LANGUAGE = "PT"; //NOTE: change it to use your language!
    var WORDS =
    {
    //English language:
    @@ -37,6 +37,12 @@ var WORDS =
    followsYouText: "Te sigue", //Text that informs that follows you.
    followingButtonText: "Siguiendo", //Text of the "Following" button.
    confirmationButtonText: "Dejar de seguir" //Text of the confirmation button. I am not totally sure.
    },
    PT:
    {
    followsYouText: "Segue você", //Text that informs that follows you.
    followingButtonText: "Seguindo", //Text of the "Following" button.
    confirmationButtonText: "Deixar de Seguir" //Text of the confirmation button. I am not totally sure.
    }
    //NOTE: if needed, add your language here...
    }
  2. @jalbam jalbam revised this gist Feb 6, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion unfollow-non-followers-twitter.js
    Original file line number Diff line number Diff line change
    @@ -174,6 +174,6 @@ var scrollAndUnfollow = function()
    window.scrollTo(0, document.body.scrollHeight);
    var unfollowed = performUnfollow(WORDS[LANGUAGE].followsYouText, WORDS[LANGUAGE].followingButtonText, WORDS[LANGUAGE].confirmationButtonText, UNFOLLOW_FOLLOWERS, MAXIMUM_UNFOLLOW_ACTIONS_PER_CYCLE, MAXIMUM_UNFOLLOW_ACTIONS_TOTAL); //For English, you can try to call it without parameters.
    if (unfollowed !== null) { setTimeout(scrollAndUnfollow, MS_PER_CYCLE); }
    else { console.log("Total desire of unfollow actions performed!"); }
    else { console.log("Total desired of unfollow actions performed!"); }
    };
    scrollAndUnfollow();
  3. @jalbam jalbam revised this gist Aug 10, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion unfollow-non-followers-twitter.js
    Original file line number Diff line number Diff line change
    @@ -108,6 +108,7 @@ var performUnfollow = function(followsYouText, followingButtonText, confirmation
    (
    function (element)
    {
    if (skipUser) { return; }
    if (element.href.indexOf("search?q=") !== -1 || element.href.indexOf("/") === -1) { return; }
    userName = element.href.substring(element.href.lastIndexOf("/") + 1).toLowerCase();
    Array.from(element.querySelectorAll("*")).find
    @@ -124,7 +125,6 @@ var performUnfollow = function(followsYouText, followingButtonText, confirmation
    }
    }
    );
    if (skipUser) { return; }
    }
    );

  4. @jalbam jalbam revised this gist Aug 10, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion unfollow-non-followers-twitter.js
    Original file line number Diff line number Diff line change
    @@ -15,7 +15,7 @@
    6) If desired, set a number to the 'MAXIMUM_UNFOLLOW_ACTIONS_TOTAL' variable to establish a maximum of unfollow actions to perform in total for all cycles (all calls to the 'performUnfollow' function). Set to null to have no limit.
    7) When the code is fine, on Twitter web site, go to the section where it shows all the people you are following (https://twitter.com/YOUR_USERNAME_HERE/following).
    8) Once there, open the JavaScript console (F12 key, normally), paste all the code there and press enter.
    9) Wait until you see it has finished. If something goes wrong or some users were not unfollowed, reload the page and repeat from the step 7 again.
    9) Wait until you see it has finished. If something goes wrong or some users were not unfollowed, reload the page and repeat from the step 8 again.
    * Gist by Joan Alba Maldonado: https://gist.github.com/jalbam/d7678c32b6f029c602c0bfb2a72e0c26
    */
  5. @jalbam jalbam revised this gist Aug 10, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion unfollow-non-followers-twitter.js
    Original file line number Diff line number Diff line change
    @@ -15,7 +15,7 @@
    6) If desired, set a number to the 'MAXIMUM_UNFOLLOW_ACTIONS_TOTAL' variable to establish a maximum of unfollow actions to perform in total for all cycles (all calls to the 'performUnfollow' function). Set to null to have no limit.
    7) When the code is fine, on Twitter web site, go to the section where it shows all the people you are following (https://twitter.com/YOUR_USERNAME_HERE/following).
    8) Once there, open the JavaScript console (F12 key, normally), paste all the code there and press enter.
    9) Wait until you see it has finished. If something goes wrong or some users were not unfollowed, reload the page and repeat from the step 6 again.
    9) Wait until you see it has finished. If something goes wrong or some users were not unfollowed, reload the page and repeat from the step 7 again.
    * Gist by Joan Alba Maldonado: https://gist.github.com/jalbam/d7678c32b6f029c602c0bfb2a72e0c26
    */
  6. @jalbam jalbam revised this gist Aug 9, 2019. No changes.
  7. @jalbam jalbam revised this gist Aug 9, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion unfollow-non-followers-twitter.js
    Original file line number Diff line number Diff line change
    @@ -123,7 +123,7 @@ var performUnfollow = function(followsYouText, followingButtonText, confirmation
    }
    }
    }
    )
    );
    if (skipUser) { return; }
    }
    );
  8. @jalbam jalbam revised this gist Aug 9, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion unfollow-non-followers-twitter.js
    Original file line number Diff line number Diff line change
    @@ -139,7 +139,7 @@ var performUnfollow = function(followsYouText, followingButtonText, confirmation
    //If the unfollow button is found, clicks it:
    if (element.textContent === followingButtonText)
    {
    console.log("* Unfollowing: " + userName)
    console.log("* Unfollowing: " + userName);
    element.click();
    unfollowed++;
    _UNFOLLOWED_TOTAL++;
  9. @jalbam jalbam revised this gist Aug 5, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion unfollow-non-followers-twitter.js
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@
    * For another language, remember to set the 'LANGUAGE' variable to that language and modify the 'WORDS' object to add the words in that language.
    2) Optionally, you can edit the 'SKIP_USERS' array to insert those users that you do not want to unfollow (even if they are not following you back).
    3) If you want to follow everyone (except the users in 'SKIP_USERS'), including those who are following you, just set the 'UNFOLLOW_FOLLOWERS' variable to 'true'.
    4) You can set the milliseconds between each cycle (each call to the 'performUnfollow' function) by modifying the 'MS_PER_CYCLE' variable.
    4) You can set the milliseconds per cycle (each call to the 'performUnfollow' function) by modifying the 'MS_PER_CYCLE' variable.
    5) If desired, set a number to the 'MAXIMUM_UNFOLLOW_ACTIONS_PER_CYCLE' variable to establish a maximum of unfollow actions to perform for each cycle (each call to the 'performUnfollow' function). Set to null to have no limit.
    6) If desired, set a number to the 'MAXIMUM_UNFOLLOW_ACTIONS_TOTAL' variable to establish a maximum of unfollow actions to perform in total for all cycles (all calls to the 'performUnfollow' function). Set to null to have no limit.
    7) When the code is fine, on Twitter web site, go to the section where it shows all the people you are following (https://twitter.com/YOUR_USERNAME_HERE/following).
  10. @jalbam jalbam revised this gist Aug 5, 2019. 1 changed file with 8 additions and 6 deletions.
    14 changes: 8 additions & 6 deletions unfollow-non-followers-twitter.js
    Original file line number Diff line number Diff line change
    @@ -10,11 +10,12 @@
    * For another language, remember to set the 'LANGUAGE' variable to that language and modify the 'WORDS' object to add the words in that language.
    2) Optionally, you can edit the 'SKIP_USERS' array to insert those users that you do not want to unfollow (even if they are not following you back).
    3) If you want to follow everyone (except the users in 'SKIP_USERS'), including those who are following you, just set the 'UNFOLLOW_FOLLOWERS' variable to 'true'.
    4) If desired, set a number to the 'MAXIMUM_UNFOLLOW_ACTIONS_PER_CYCLE' variable to establish a maximum of unfollow actions to perform for each cycle (each call to the 'performUnfollow' function). Set to null to have no limit.
    5) If desired, set a number to the 'MAXIMUM_UNFOLLOW_ACTIONS_TOTAL' variable to establish a maximum of unfollow actions to perform in total for all cycles (all calls to the 'performUnfollow' function). Set to null to have no limit.
    6) When the code is fine, on Twitter web site, go to the section where it shows all the people you are following (https://twitter.com/YOUR_USERNAME_HERE/following).
    7) Once there, open the JavaScript console (F12 key, normally), paste all the code there and press enter.
    8) Wait until you see it has finished. If something goes wrong or some users were not unfollowed, reload the page and repeat from the step 6 again.
    4) You can set the milliseconds between each cycle (each call to the 'performUnfollow' function) by modifying the 'MS_PER_CYCLE' variable.
    5) If desired, set a number to the 'MAXIMUM_UNFOLLOW_ACTIONS_PER_CYCLE' variable to establish a maximum of unfollow actions to perform for each cycle (each call to the 'performUnfollow' function). Set to null to have no limit.
    6) If desired, set a number to the 'MAXIMUM_UNFOLLOW_ACTIONS_TOTAL' variable to establish a maximum of unfollow actions to perform in total for all cycles (all calls to the 'performUnfollow' function). Set to null to have no limit.
    7) When the code is fine, on Twitter web site, go to the section where it shows all the people you are following (https://twitter.com/YOUR_USERNAME_HERE/following).
    8) Once there, open the JavaScript console (F12 key, normally), paste all the code there and press enter.
    9) Wait until you see it has finished. If something goes wrong or some users were not unfollowed, reload the page and repeat from the step 6 again.
    * Gist by Joan Alba Maldonado: https://gist.github.com/jalbam/d7678c32b6f029c602c0bfb2a72e0c26
    */
    @@ -40,6 +41,7 @@ var WORDS =
    //NOTE: if needed, add your language here...
    }
    var UNFOLLOW_FOLLOWERS = false; //If set to true, it will also remove followers (unless they are skipped).
    var MS_PER_CYCLE = 10; //Milliseconds per cycle (each call to 'performUnfollow').
    var MAXIMUM_UNFOLLOW_ACTIONS_PER_CYCLE = null; //Maximum of unfollow actions to perform, per cycle (each call to 'performUnfollow'). Set to 'null' to have no limit.
    var MAXIMUM_UNFOLLOW_ACTIONS_TOTAL = null; //Maximum of unfollow actions to perform, in total (among all calls to 'performUnfollow'). Set to 'null' to have no limit.
    var SKIP_USERS = //Users that we do not want to unfollow (even if they are not following you back):
    @@ -171,7 +173,7 @@ var scrollAndUnfollow = function()
    {
    window.scrollTo(0, document.body.scrollHeight);
    var unfollowed = performUnfollow(WORDS[LANGUAGE].followsYouText, WORDS[LANGUAGE].followingButtonText, WORDS[LANGUAGE].confirmationButtonText, UNFOLLOW_FOLLOWERS, MAXIMUM_UNFOLLOW_ACTIONS_PER_CYCLE, MAXIMUM_UNFOLLOW_ACTIONS_TOTAL); //For English, you can try to call it without parameters.
    if (unfollowed !== null) { setTimeout(scrollAndUnfollow, 10); }
    if (unfollowed !== null) { setTimeout(scrollAndUnfollow, MS_PER_CYCLE); }
    else { console.log("Total desire of unfollow actions performed!"); }
    };
    scrollAndUnfollow();
  11. @jalbam jalbam revised this gist Aug 1, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion unfollow-non-followers-twitter.js
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@
    5) If desired, set a number to the 'MAXIMUM_UNFOLLOW_ACTIONS_TOTAL' variable to establish a maximum of unfollow actions to perform in total for all cycles (all calls to the 'performUnfollow' function). Set to null to have no limit.
    6) When the code is fine, on Twitter web site, go to the section where it shows all the people you are following (https://twitter.com/YOUR_USERNAME_HERE/following).
    7) Once there, open the JavaScript console (F12 key, normally), paste all the code there and press enter.
    8) Wait until you see it has finished. If something goes wrong, reload the page and repeat from the step 3 again.
    8) Wait until you see it has finished. If something goes wrong or some users were not unfollowed, reload the page and repeat from the step 6 again.
    * Gist by Joan Alba Maldonado: https://gist.github.com/jalbam/d7678c32b6f029c602c0bfb2a72e0c26
    */
  12. @jalbam jalbam revised this gist Aug 1, 2019. 1 changed file with 33 additions and 10 deletions.
    43 changes: 33 additions & 10 deletions unfollow-non-followers-twitter.js
    Original file line number Diff line number Diff line change
    @@ -10,9 +10,11 @@
    * For another language, remember to set the 'LANGUAGE' variable to that language and modify the 'WORDS' object to add the words in that language.
    2) Optionally, you can edit the 'SKIP_USERS' array to insert those users that you do not want to unfollow (even if they are not following you back).
    3) If you want to follow everyone (except the users in 'SKIP_USERS'), including those who are following you, just set the 'UNFOLLOW_FOLLOWERS' variable to 'true'.
    4) When the code is fine, on Twitter web site, go to the section where it shows all the people you are following (https://twitter.com/YOUR_USERNAME_HERE/following).
    5) Once there, open the JavaScript console (F12 key, normally), paste all the code there and press enter.
    6) Wait until you see it has finished. If something goes wrong, reload the page and repeat from the step 3 again.
    4) If desired, set a number to the 'MAXIMUM_UNFOLLOW_ACTIONS_PER_CYCLE' variable to establish a maximum of unfollow actions to perform for each cycle (each call to the 'performUnfollow' function). Set to null to have no limit.
    5) If desired, set a number to the 'MAXIMUM_UNFOLLOW_ACTIONS_TOTAL' variable to establish a maximum of unfollow actions to perform in total for all cycles (all calls to the 'performUnfollow' function). Set to null to have no limit.
    6) When the code is fine, on Twitter web site, go to the section where it shows all the people you are following (https://twitter.com/YOUR_USERNAME_HERE/following).
    7) Once there, open the JavaScript console (F12 key, normally), paste all the code there and press enter.
    8) Wait until you see it has finished. If something goes wrong, reload the page and repeat from the step 3 again.
    * Gist by Joan Alba Maldonado: https://gist.github.com/jalbam/d7678c32b6f029c602c0bfb2a72e0c26
    */
    @@ -38,6 +40,8 @@ var WORDS =
    //NOTE: if needed, add your language here...
    }
    var UNFOLLOW_FOLLOWERS = false; //If set to true, it will also remove followers (unless they are skipped).
    var MAXIMUM_UNFOLLOW_ACTIONS_PER_CYCLE = null; //Maximum of unfollow actions to perform, per cycle (each call to 'performUnfollow'). Set to 'null' to have no limit.
    var MAXIMUM_UNFOLLOW_ACTIONS_TOTAL = null; //Maximum of unfollow actions to perform, in total (among all calls to 'performUnfollow'). Set to 'null' to have no limit.
    var SKIP_USERS = //Users that we do not want to unfollow (even if they are not following you back):
    [
    //Place the user names that you want to skip here (they will not be unfollowed):
    @@ -47,23 +51,37 @@ var SKIP_USERS = //Users that we do not want to unfollow (even if they are not f
    ];
    SKIP_USERS.forEach(function(value, index) { SKIP_USERS[index] = value.toLowerCase(); }); //Transforms all the user names to lower case as it will be case insensitive.

    var _UNFOLLOWED_TOTAL = 0; //Keeps the number of total unfollow actions performed. Read-only (do not modify).

    //Function that unfollows non-followers on Twitter:
    var usersFollowingMe = function(followsYouText, followingButtonText, confirmationButtonText, unfollowFollowers)
    var performUnfollow = function(followsYouText, followingButtonText, confirmationButtonText, unfollowFollowers, maximumUnfollowActionsPerCycle, maximumUnfollowActionsTotal)
    {
    var nonFollowers = 0;
    var unfollowed = 0;
    followsYouText = followsYouText || WORDS.EN.followsYouText; //Text that informs that follows you.
    followingButtonText = followingButtonText || WORDS.EN.followingButtonText; //Text of the "Following" button.
    confirmationButtonText = confirmationButtonText || WORDS.EN.confirmationButtonText; //Text of the confirmation button.
    unfollowFollowers = typeof(unfollowFollowers) === "undefined" || unfollowFollowers === null ? UNFOLLOW_FOLLOWERS : unfollowFollowers;
    maximumUnfollowActionsTotal = maximumUnfollowActionsTotal === null || !isNaN(parseInt(maximumUnfollowActionsTotal)) ? maximumUnfollowActionsTotal : MAXIMUM_UNFOLLOW_ACTIONS_TOTAL || null;
    maximumUnfollowActionsTotal = !isNaN(parseInt(maximumUnfollowActionsTotal)) ? parseInt(maximumUnfollowActionsTotal) : null;
    maximumUnfollowActionsPerCycle = maximumUnfollowActionsPerCycle === null || !isNaN(parseInt(maximumUnfollowActionsPerCycle)) ? maximumUnfollowActionsPerCycle : MAXIMUM_UNFOLLOW_ACTIONS_PER_CYCLE || null;
    maximumUnfollowActionsPerCycle = !isNaN(parseInt(maximumUnfollowActionsPerCycle)) ? parseInt(maximumUnfollowActionsPerCycle) : null;

    //Looks through all the containers of each user:
    var totalLimitReached = false;
    var localLimitReached = false;
    var userContainers = document.querySelectorAll('[data-testid=UserCell]');
    Array.prototype.filter.call
    (
    userContainers,
    function(userContainer)
    {
    //If we have reached a limit previously, exits silently:
    if (totalLimitReached || localLimitReached) { return; }
    //If we have reached the maximum desired number of total unfollow actions, exits:
    else if (maximumUnfollowActionsTotal !== null && _UNFOLLOWED_TOTAL >= maximumUnfollowActionsTotal) { console.log("Exiting! Limit of unfollow actions in total reached: " + maximumUnfollowActionsTotal); totalLimitReached = true; return; }
    //...otherwise, if we have reached the maximum desired number of local unfollow actions, exits:
    else if (maximumUnfollowActionsPerCycle !== null && unfollowed >= maximumUnfollowActionsPerCycle) { console.log("Exiting! Limit of unfollow actions per cycle reached: " + maximumUnfollowActionsPerCycle); localLimitReached = true; return; }

    //Checks whether the user is following you:
    if (!unfollowFollowers)
    {
    @@ -83,12 +101,13 @@ var usersFollowingMe = function(followsYouText, followingButtonText, confirmatio
    {
    //Finds the user name and checks whether we want to skip this user or not:
    var skipUser = false;
    var userName = "";
    Array.from(userContainer.querySelectorAll("[href^='/']")).find
    (
    function (element)
    {
    if (element.href.indexOf("search?q=") !== -1 || element.href.indexOf("/") === -1) { return; }
    var userName = element.href.substring(element.href.lastIndexOf("/") + 1).toLowerCase();
    userName = element.href.substring(element.href.lastIndexOf("/") + 1).toLowerCase();
    Array.from(element.querySelectorAll("*")).find
    (
    function (subElement)
    @@ -103,6 +122,7 @@ var usersFollowingMe = function(followsYouText, followingButtonText, confirmatio
    }
    }
    )
    if (skipUser) { return; }
    }
    );

    @@ -117,8 +137,10 @@ var usersFollowingMe = function(followsYouText, followingButtonText, confirmatio
    //If the unfollow button is found, clicks it:
    if (element.textContent === followingButtonText)
    {
    console.log("* Unfollowing: " + userName)
    element.click();
    nonFollowers++;
    unfollowed++;
    _UNFOLLOWED_TOTAL++;
    }
    }
    );
    @@ -140,15 +162,16 @@ var usersFollowingMe = function(followsYouText, followingButtonText, confirmatio
    }
    );

    return nonFollowers; //Returns the number of non-followers.
    return totalLimitReached ? null : unfollowed; //If the total limit has been reached, returns null. Otherwise, returns the number of unfollowed people.
    }


    //Scrolls and unfollows non-followers, constantly:
    var scrollAndUnfollow = function()
    {
    window.scrollTo(0, document.body.scrollHeight);
    usersFollowingMe(WORDS[LANGUAGE].followsYouText, WORDS[LANGUAGE].followingButtonText, WORDS[LANGUAGE].confirmationButtonText, UNFOLLOW_FOLLOWERS); //For English, you can try to call it without parameters.
    setTimeout(scrollAndUnfollow, 10);
    var unfollowed = performUnfollow(WORDS[LANGUAGE].followsYouText, WORDS[LANGUAGE].followingButtonText, WORDS[LANGUAGE].confirmationButtonText, UNFOLLOW_FOLLOWERS, MAXIMUM_UNFOLLOW_ACTIONS_PER_CYCLE, MAXIMUM_UNFOLLOW_ACTIONS_TOTAL); //For English, you can try to call it without parameters.
    if (unfollowed !== null) { setTimeout(scrollAndUnfollow, 10); }
    else { console.log("Total desire of unfollow actions performed!"); }
    };
    scrollAndUnfollow();
  13. @jalbam jalbam revised this gist Jul 23, 2019. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions unfollow-non-followers-twitter.js
    Original file line number Diff line number Diff line change
    @@ -10,9 +10,9 @@
    * For another language, remember to set the 'LANGUAGE' variable to that language and modify the 'WORDS' object to add the words in that language.
    2) Optionally, you can edit the 'SKIP_USERS' array to insert those users that you do not want to unfollow (even if they are not following you back).
    3) If you want to follow everyone (except the users in 'SKIP_USERS'), including those who are following you, just set the 'UNFOLLOW_FOLLOWERS' variable to 'true'.
    3) When the code is fine, on Twitter web site, go to the section where it shows all the people you are following (https://twitter.com/YOUR_USERNAME_HERE/following).
    4) Once there, open the JavaScript console (F12 key, normally), paste all the code there and press enter.
    5) Wait until you see it has finished. If something goes wrong, reload the page and repeat from the step 3 again.
    4) When the code is fine, on Twitter web site, go to the section where it shows all the people you are following (https://twitter.com/YOUR_USERNAME_HERE/following).
    5) Once there, open the JavaScript console (F12 key, normally), paste all the code there and press enter.
    6) Wait until you see it has finished. If something goes wrong, reload the page and repeat from the step 3 again.
    * Gist by Joan Alba Maldonado: https://gist.github.com/jalbam/d7678c32b6f029c602c0bfb2a72e0c26
    */
  14. @jalbam jalbam revised this gist Jul 23, 2019. 1 changed file with 21 additions and 14 deletions.
    35 changes: 21 additions & 14 deletions unfollow-non-followers-twitter.js
    Original file line number Diff line number Diff line change
    @@ -1,14 +1,15 @@
    /*
    Unfollow (stop following) those people who are not following you back on Twitter.
    Unfollow (stop following) those people who are not following you back on Twitter (or unfollow everyone if desired).
    This will work for new Twitter web site code structure (it was changed from July 2019, causing other unfollow-scripts to stop working).
    Instructions:
    1) The code may need to be modified depending on the language of your Twitter web site:
    * For English language web site, no modification needed.
    * For Spanish language web site, remember to set the variable 'LANGUAGE' to "ES".
    * For another language, remember to set the variable 'LANGUAGE' to that language and modify the 'WORDS' object to add the words in that language.
    * For Spanish language web site, remember to set the 'LANGUAGE' variable to "ES".
    * For another language, remember to set the 'LANGUAGE' variable to that language and modify the 'WORDS' object to add the words in that language.
    2) Optionally, you can edit the 'SKIP_USERS' array to insert those users that you do not want to unfollow (even if they are not following you back).
    3) If you want to follow everyone (except the users in 'SKIP_USERS'), including those who are following you, just set the 'UNFOLLOW_FOLLOWERS' variable to 'true'.
    3) When the code is fine, on Twitter web site, go to the section where it shows all the people you are following (https://twitter.com/YOUR_USERNAME_HERE/following).
    4) Once there, open the JavaScript console (F12 key, normally), paste all the code there and press enter.
    5) Wait until you see it has finished. If something goes wrong, reload the page and repeat from the step 3 again.
    @@ -36,6 +37,7 @@ var WORDS =
    }
    //NOTE: if needed, add your language here...
    }
    var UNFOLLOW_FOLLOWERS = false; //If set to true, it will also remove followers (unless they are skipped).
    var SKIP_USERS = //Users that we do not want to unfollow (even if they are not following you back):
    [
    //Place the user names that you want to skip here (they will not be unfollowed):
    @@ -47,12 +49,13 @@ SKIP_USERS.forEach(function(value, index) { SKIP_USERS[index] = value.toLowerCas


    //Function that unfollows non-followers on Twitter:
    var usersFollowingMe = function(followsYouText, followingButtonText, confirmationButtonText)
    var usersFollowingMe = function(followsYouText, followingButtonText, confirmationButtonText, unfollowFollowers)
    {
    var nonFollowers = 0;
    followsYouText = followsYouText || WORDS.EN.followsYouText; //Text that informs that follows you.
    followingButtonText = followingButtonText || WORDS.EN.followingButtonText; //Text of the "Following" button.
    confirmationButtonText = confirmationButtonText || WORDS.EN.confirmationButtonText; //Text of the confirmation button.
    unfollowFollowers = typeof(unfollowFollowers) === "undefined" || unfollowFollowers === null ? UNFOLLOW_FOLLOWERS : unfollowFollowers;

    //Looks through all the containers of each user:
    var userContainers = document.querySelectorAll('[data-testid=UserCell]');
    @@ -62,16 +65,20 @@ var usersFollowingMe = function(followsYouText, followingButtonText, confirmatio
    function(userContainer)
    {
    //Checks whether the user is following you:
    var followsYou = false;
    Array.from(userContainer.querySelectorAll("*")).find
    (
    function(element)
    {
    if (element.textContent === followsYouText) { followsYou = true; }
    }
    );
    if (!unfollowFollowers)
    {
    var followsYou = false;
    Array.from(userContainer.querySelectorAll("*")).find
    (
    function(element)
    {
    if (element.textContent === followsYouText) { followsYou = true; }
    }
    );
    }
    else { followsYou = false; } //If we want to also unfollow followers, we consider it is not a follower.

    //If the user is not following you:
    //If the user is not following you (or we also want to unfollow followers):
    if (!followsYou)
    {
    //Finds the user name and checks whether we want to skip this user or not:
    @@ -141,7 +148,7 @@ var usersFollowingMe = function(followsYouText, followingButtonText, confirmatio
    var scrollAndUnfollow = function()
    {
    window.scrollTo(0, document.body.scrollHeight);
    usersFollowingMe(WORDS[LANGUAGE].followsYouText, WORDS[LANGUAGE].followingButtonText, WORDS[LANGUAGE].confirmationButtonText); //For English, you can try to call it without parameters.
    usersFollowingMe(WORDS[LANGUAGE].followsYouText, WORDS[LANGUAGE].followingButtonText, WORDS[LANGUAGE].confirmationButtonText, UNFOLLOW_FOLLOWERS); //For English, you can try to call it without parameters.
    setTimeout(scrollAndUnfollow, 10);
    };
    scrollAndUnfollow();
  15. @jalbam jalbam revised this gist Jul 22, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion unfollow-non-followers-twitter.js
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@
    2) Optionally, you can edit the 'SKIP_USERS' array to insert those users that you do not want to unfollow (even if they are not following you back).
    3) When the code is fine, on Twitter web site, go to the section where it shows all the people you are following (https://twitter.com/YOUR_USERNAME_HERE/following).
    4) Once there, open the JavaScript console (F12 key, normally), paste all the code there and press enter.
    5) Wait until you see it has finished. If something is wrong, reload the page and repeat from the step 3 again.
    5) Wait until you see it has finished. If something goes wrong, reload the page and repeat from the step 3 again.
    * Gist by Joan Alba Maldonado: https://gist.github.com/jalbam/d7678c32b6f029c602c0bfb2a72e0c26
    */
  16. @jalbam jalbam revised this gist Jul 22, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion unfollow-non-followers-twitter.js
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@
    * For another language, remember to set the variable 'LANGUAGE' to that language and modify the 'WORDS' object to add the words in that language.
    2) Optionally, you can edit the 'SKIP_USERS' array to insert those users that you do not want to unfollow (even if they are not following you back).
    3) When the code is fine, on Twitter web site, go to the section where it shows all the people you are following (https://twitter.com/YOUR_USERNAME_HERE/following).
    4) Once there, open the JavaScript console (F12 key), paste all the code there and press enter.
    4) Once there, open the JavaScript console (F12 key, normally), paste all the code there and press enter.
    5) Wait until you see it has finished. If something is wrong, reload the page and repeat from the step 3 again.
    * Gist by Joan Alba Maldonado: https://gist.github.com/jalbam/d7678c32b6f029c602c0bfb2a72e0c26
  17. @jalbam jalbam revised this gist Jul 22, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion unfollow-non-followers-twitter.js
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@
    * For English language web site, no modification needed.
    * For Spanish language web site, remember to set the variable 'LANGUAGE' to "ES".
    * For another language, remember to set the variable 'LANGUAGE' to that language and modify the 'WORDS' object to add the words in that language.
    2) Optionally, you can edit the 'SKIP_USERS' array to insert those users that you do not want to follow (even if they are not following you back).
    2) Optionally, you can edit the 'SKIP_USERS' array to insert those users that you do not want to unfollow (even if they are not following you back).
    3) When the code is fine, on Twitter web site, go to the section where it shows all the people you are following (https://twitter.com/YOUR_USERNAME_HERE/following).
    4) Once there, open the JavaScript console (F12 key), paste all the code there and press enter.
    5) Wait until you see it has finished. If something is wrong, reload the page and repeat from the step 3 again.
  18. @jalbam jalbam revised this gist Jul 22, 2019. No changes.
  19. @jalbam jalbam revised this gist Jul 22, 2019. No changes.
  20. @jalbam jalbam revised this gist Jul 22, 2019. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions unfollow-non-followers-twitter.js
    Original file line number Diff line number Diff line change
    @@ -9,9 +9,9 @@
    * For Spanish language web site, remember to set the variable 'LANGUAGE' to "ES".
    * For another language, remember to set the variable 'LANGUAGE' to that language and modify the 'WORDS' object to add the words in that language.
    2) Optionally, you can edit the 'SKIP_USERS' array to insert those users that you do not want to follow (even if they are not following you back).
    2) When the code is fine, on Twitter web site, go to the section where it shows all the people you are following (https://twitter.com/YOUR_USERNAME_HERE/following).
    2) Once there, open the JavaScript console (F12 key), paste all the code there and press enter.
    3) Wait until you see it has finished. If something is wrong, reload the page and repeat from the step 3 again.
    3) When the code is fine, on Twitter web site, go to the section where it shows all the people you are following (https://twitter.com/YOUR_USERNAME_HERE/following).
    4) Once there, open the JavaScript console (F12 key), paste all the code there and press enter.
    5) Wait until you see it has finished. If something is wrong, reload the page and repeat from the step 3 again.
    * Gist by Joan Alba Maldonado: https://gist.github.com/jalbam/d7678c32b6f029c602c0bfb2a72e0c26
    */
  21. @jalbam jalbam revised this gist Jul 22, 2019. 1 changed file with 86 additions and 38 deletions.
    124 changes: 86 additions & 38 deletions unfollow-non-followers-twitter.js
    Original file line number Diff line number Diff line change
    @@ -1,35 +1,58 @@
    /*
    Unfollow (stop following) those people who is not following you back on Twitter.
    Unfollow (stop following) those people who are not following you back on Twitter.
    This will work for new Twitter web site code structure (it was changed from July 2019, causing other unfollow-scripts to stop working).
    Instructions:
    1) On Twitter web site, go to the section where it shows all the people you are following.
    1) The code may need to be modified depending on the language of your Twitter web site:
    * For English language web site, no modification needed.
    * For Spanish language web site, remember to set the variable 'LANGUAGE' to "ES".
    * For another language, remember to set the variable 'LANGUAGE' to that language and modify the 'WORDS' object to add the words in that language.
    2) Optionally, you can edit the 'SKIP_USERS' array to insert those users that you do not want to follow (even if they are not following you back).
    2) When the code is fine, on Twitter web site, go to the section where it shows all the people you are following (https://twitter.com/YOUR_USERNAME_HERE/following).
    2) Once there, open the JavaScript console (F12 key), paste all the code there and press enter.
    IMPORTANT: before pressing enter, remember to change the three parameters to adapt it to your language.
    3) Wait until you see it has finished.
    3) Wait until you see it has finished. If something is wrong, reload the page and repeat from the step 3 again.
    * Gist by Joan Alba Maldonado: https://gist.github.com/jalbam/d7678c32b6f029c602c0bfb2a72e0c26
    */


    /*
    Note:
    * For English language web site, remember to change "Te sigue" for "Follows you", "Siguiendo" for "Following" and "Dejar de seguir" for "Unfollow" (I am not totally sure about this one).
    * For another languages, change those three parameters to your language.
    */
    var followsYouText = "Te sigue"; //English: "Follows you".
    var followingButtonText = "Siguiendo"; //English: "Following".
    var confirmationButtonText = "Dejar de seguir"; //English: "Unfollow" (I am not totally sure).
    var LANGUAGE = "EN"; //NOTE: change it to use your language!
    var WORDS =
    {
    //English language:
    EN:
    {
    followsYouText: "Follows you", //Text that informs that follows you.
    followingButtonText: "Following", //Text of the "Following" button.
    confirmationButtonText: "Unfollow" //Text of the confirmation button. I am not totally sure.
    },
    //Spanish language:
    ES:
    {
    followsYouText: "Te sigue", //Text that informs that follows you.
    followingButtonText: "Siguiendo", //Text of the "Following" button.
    confirmationButtonText: "Dejar de seguir" //Text of the confirmation button. I am not totally sure.
    }
    //NOTE: if needed, add your language here...
    }
    var SKIP_USERS = //Users that we do not want to unfollow (even if they are not following you back):
    [
    //Place the user names that you want to skip here (they will not be unfollowed):
    "user_name_to_skip_example_1",
    "user_name_to_skip_example_2",
    "user_name_to_skip_example_3"
    ];
    SKIP_USERS.forEach(function(value, index) { SKIP_USERS[index] = value.toLowerCase(); }); //Transforms all the user names to lower case as it will be case insensitive.


    //Function that unfollows non-followers on Twitter:
    var usersFollowingMe = function(followsYouText, followingButtonText, confirmationButtonText)
    {
    var nonFollowers = 0;
    followsYouText = followsYouText || "Follows you"; //Text that informs that follows you. Spanish: "Te sigue".
    followingButtonText = followingButtonText || "Following"; //Text of the "Following" button. Spanish: "Following".
    confirmationButtonText = confirmationButtonText || "Unfollow" //Text of the confirmation button. Spanish: "Dejar de seguir". TODO: confirm real text in English!
    followsYouText = followsYouText || WORDS.EN.followsYouText; //Text that informs that follows you.
    followingButtonText = followingButtonText || WORDS.EN.followingButtonText; //Text of the "Following" button.
    confirmationButtonText = confirmationButtonText || WORDS.EN.confirmationButtonText; //Text of the confirmation button.

    //Looks through all the containers of each user:
    var userContainers = document.querySelectorAll('[data-testid=UserCell]');
    @@ -51,39 +74,64 @@ var usersFollowingMe = function(followsYouText, followingButtonText, confirmatio
    //If the user is not following you:
    if (!followsYou)
    {
    //Finds the unfollow button:
    Array.from(userContainer.querySelectorAll('[role=button]')).find
    //Finds the user name and checks whether we want to skip this user or not:
    var skipUser = false;
    Array.from(userContainer.querySelectorAll("[href^='/']")).find
    (
    function(element)
    function (element)
    {
    //If the unfollow button is found, clicks it:
    if (element.textContent === followingButtonText)
    {
    element.click();
    nonFollowers++;
    }
    if (element.href.indexOf("search?q=") !== -1 || element.href.indexOf("/") === -1) { return; }
    var userName = element.href.substring(element.href.lastIndexOf("/") + 1).toLowerCase();
    Array.from(element.querySelectorAll("*")).find
    (
    function (subElement)
    {
    if (subElement.textContent.toLowerCase() === "@" + userName)
    {
    if (SKIP_USERS.indexOf(userName) !== -1)
    {
    console.log("We want to skip: " + userName);
    skipUser = true;
    }
    }
    }
    )
    }
    );

    //If we do not want to skip the user:
    if (!skipUser)
    {
    //Finds the unfollow button:
    Array.from(userContainer.querySelectorAll('[role=button]')).find
    (
    function(element)
    {
    //If the unfollow button is found, clicks it:
    if (element.textContent === followingButtonText)
    {
    element.click();
    nonFollowers++;
    }
    }
    );
    }
    }
    }
    );

    //If there is a confirmation dialog, press it automatically:
    if (nonFollowers > 0)
    {
    //Finds the confirmation button:
    Array.from(document.querySelectorAll('[role=button]')).find
    (
    function(element)
    Array.from(document.querySelectorAll('[role=button]')).find //Finds the confirmation button.
    (
    function(element)
    {
    //If the confirmation button is found, clicks it:
    if (element.textContent === confirmationButtonText)
    {
    //If the confirmation button is found, clicks it:
    if (element.textContent === confirmationButtonText)
    {
    element.click();
    }
    element.click();
    }
    );
    }
    }
    );

    return nonFollowers; //Returns the number of non-followers.
    }
    @@ -93,7 +141,7 @@ var usersFollowingMe = function(followsYouText, followingButtonText, confirmatio
    var scrollAndUnfollow = function()
    {
    window.scrollTo(0, document.body.scrollHeight);
    usersFollowingMe(followsYouText, followingButtonText, confirmationButtonText); //For english, you can try to call it without parameters.
    usersFollowingMe(WORDS[LANGUAGE].followsYouText, WORDS[LANGUAGE].followingButtonText, WORDS[LANGUAGE].confirmationButtonText); //For English, you can try to call it without parameters.
    setTimeout(scrollAndUnfollow, 10);
    };
    scrollAndUnfollow();
  22. @jalbam jalbam revised this gist Jul 21, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion unfollow-non-followers-twitter.js
    Original file line number Diff line number Diff line change
    @@ -74,7 +74,7 @@ var usersFollowingMe = function(followsYouText, followingButtonText, confirmatio
    //Finds the confirmation button:
    Array.from(document.querySelectorAll('[role=button]')).find
    (
    function (element)
    function(element)
    {
    //If the confirmation button is found, clicks it:
    if (element.textContent === confirmationButtonText)
  23. @jalbam jalbam revised this gist Jul 21, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions unfollow-non-followers-twitter.js
    Original file line number Diff line number Diff line change
    @@ -36,7 +36,7 @@ var usersFollowingMe = function(followsYouText, followingButtonText, confirmatio
    Array.prototype.filter.call
    (
    userContainers,
    function (userContainer)
    function(userContainer)
    {
    //Checks whether the user is following you:
    var followsYou = false;
    @@ -74,7 +74,7 @@ var usersFollowingMe = function(followsYouText, followingButtonText, confirmatio
    //Finds the confirmation button:
    Array.from(document.querySelectorAll('[role=button]')).find
    (
    function(element)
    function (element)
    {
    //If the confirmation button is found, clicks it:
    if (element.textContent === confirmationButtonText)
  24. @jalbam jalbam revised this gist Jul 21, 2019. 1 changed file with 12 additions and 1 deletion.
    13 changes: 12 additions & 1 deletion unfollow-non-followers-twitter.js
    Original file line number Diff line number Diff line change
    @@ -12,6 +12,17 @@
    * Gist by Joan Alba Maldonado: https://gist.github.com/jalbam/d7678c32b6f029c602c0bfb2a72e0c26
    */


    /*
    Note:
    * For English language web site, remember to change "Te sigue" for "Follows you", "Siguiendo" for "Following" and "Dejar de seguir" for "Unfollow" (I am not totally sure about this one).
    * For another languages, change those three parameters to your language.
    */
    var followsYouText = "Te sigue"; //English: "Follows you".
    var followingButtonText = "Siguiendo"; //English: "Following".
    var confirmationButtonText = "Dejar de seguir"; //English: "Unfollow" (I am not totally sure).


    //Function that unfollows non-followers on Twitter:
    var usersFollowingMe = function(followsYouText, followingButtonText, confirmationButtonText)
    {
    @@ -82,7 +93,7 @@ var usersFollowingMe = function(followsYouText, followingButtonText, confirmatio
    var scrollAndUnfollow = function()
    {
    window.scrollTo(0, document.body.scrollHeight);
    usersFollowingMe("Te sigue", "Siguiendo", "Dejar de seguir"); //Spanish language. For english, call without parameters. For other languages, edit these two parameters.
    usersFollowingMe(followsYouText, followingButtonText, confirmationButtonText); //For english, you can try to call it without parameters.
    setTimeout(scrollAndUnfollow, 10);
    };
    scrollAndUnfollow();
  25. @jalbam jalbam revised this gist Jul 21, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion unfollow-non-followers-twitter.js
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@
    IMPORTANT: before pressing enter, remember to change the three parameters to adapt it to your language.
    3) Wait until you see it has finished.
    * Gist by Joan Alba Maldonado:
    * Gist by Joan Alba Maldonado: https://gist.github.com/jalbam/d7678c32b6f029c602c0bfb2a72e0c26
    */

    //Function that unfollows non-followers on Twitter:
  26. @jalbam jalbam created this gist Jul 21, 2019.
    88 changes: 88 additions & 0 deletions unfollow-non-followers-twitter.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,88 @@
    /*
    Unfollow (stop following) those people who is not following you back on Twitter.
    This will work for new Twitter web site code structure (it was changed from July 2019, causing other unfollow-scripts to stop working).
    Instructions:
    1) On Twitter web site, go to the section where it shows all the people you are following.
    2) Once there, open the JavaScript console (F12 key), paste all the code there and press enter.
    IMPORTANT: before pressing enter, remember to change the three parameters to adapt it to your language.
    3) Wait until you see it has finished.
    * Gist by Joan Alba Maldonado:
    */

    //Function that unfollows non-followers on Twitter:
    var usersFollowingMe = function(followsYouText, followingButtonText, confirmationButtonText)
    {
    var nonFollowers = 0;
    followsYouText = followsYouText || "Follows you"; //Text that informs that follows you. Spanish: "Te sigue".
    followingButtonText = followingButtonText || "Following"; //Text of the "Following" button. Spanish: "Following".
    confirmationButtonText = confirmationButtonText || "Unfollow" //Text of the confirmation button. Spanish: "Dejar de seguir". TODO: confirm real text in English!

    //Looks through all the containers of each user:
    var userContainers = document.querySelectorAll('[data-testid=UserCell]');
    Array.prototype.filter.call
    (
    userContainers,
    function (userContainer)
    {
    //Checks whether the user is following you:
    var followsYou = false;
    Array.from(userContainer.querySelectorAll("*")).find
    (
    function(element)
    {
    if (element.textContent === followsYouText) { followsYou = true; }
    }
    );

    //If the user is not following you:
    if (!followsYou)
    {
    //Finds the unfollow button:
    Array.from(userContainer.querySelectorAll('[role=button]')).find
    (
    function(element)
    {
    //If the unfollow button is found, clicks it:
    if (element.textContent === followingButtonText)
    {
    element.click();
    nonFollowers++;
    }
    }
    );
    }
    }
    );

    //If there is a confirmation dialog, press it automatically:
    if (nonFollowers > 0)
    {
    //Finds the confirmation button:
    Array.from(document.querySelectorAll('[role=button]')).find
    (
    function(element)
    {
    //If the confirmation button is found, clicks it:
    if (element.textContent === confirmationButtonText)
    {
    element.click();
    }
    }
    );
    }

    return nonFollowers; //Returns the number of non-followers.
    }


    //Scrolls and unfollows non-followers, constantly:
    var scrollAndUnfollow = function()
    {
    window.scrollTo(0, document.body.scrollHeight);
    usersFollowingMe("Te sigue", "Siguiendo", "Dejar de seguir"); //Spanish language. For english, call without parameters. For other languages, edit these two parameters.
    setTimeout(scrollAndUnfollow, 10);
    };
    scrollAndUnfollow();