Created
October 9, 2021 16:59
-
-
Save tildebyte/de7ae798ad8a865bd3aaab0bb135800c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get a list of elements that match selectors, i.e. "Toggle to follow" buttons. | |
// Maintainers probably need to change the selector string for new FB versions | |
var follows = document.querySelectorAll('div[aria-label="Toggle to follow"]'); | |
// If you want to make sure this script doesn't click on the wrong buttons, go | |
// to the Elements tab, press Ctrl-F, enter "Toggle to follow" in the search | |
// bar, then find the button that is highlighed | |
var delay = 1500; // Delay between clicks to prevent being blocked by FB | |
var i = 0; // Initialize a counter of unfollows | |
function unfollow() { | |
// unfollow() calls itself recursively. If counter of unfollows reaches length | |
// of friend list, return | |
if (i == follows.length) { | |
return; | |
} | |
// Calculate remaining time based on the num. of friends not yet unfollowed | |
var remaining = ((follows.length - i) * delay / 1000).toFixed(2); | |
console.log( | |
'Unfollowing', i + 1, 'of', follows.length + ',', remaining + 's', | |
'remaining…'); | |
follows[i].click(); // Click! | |
i = i + 1; // Increment the counter of unfollows | |
// Recursively call itself with a 1500 s delay to keep on unfollowing | |
setTimeout(unfollow, delay); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment