-
-
Save dnalob/fac7d2a7d313feb337bb2234f606af2e to your computer and use it in GitHub Desktop.
Unfollow All for Twitter
This file contains 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
/* | |
* Unfollow All for Twitter | |
* | |
* Go to https://twitter.com/<YourUserName>/following and run the | |
* below code in the console to gradually unfollow all accounts | |
* you are following, this should play nice with any rate limiting. | |
* Built on current Firefox (2021-08-26) though may work for others. | |
* | |
* Author: https://twitter.com/OatyCreates | |
* Copyright 2021-Present @oatycreates | |
*/ | |
toUnfollow = []; | |
setInterval(() => { | |
if (toUnfollow.length === 0) { | |
// Ran out of data, fetch new | |
// NOTE - This uses the accessibility label text and will need to be updated for other languages | |
toUnfollow = Array.from(document.querySelectorAll('[aria-label^="Following"]')); | |
} | |
if (toUnfollow.length >= 0) { | |
// Unfollow one by one | |
unfollowPerson(toUnfollow.shift()); | |
} | |
if (toUnfollow.length === 0) { | |
// Finished data, bring new elements into view | |
window.scrollTo(0, document.body.scrollHeight); // Scroll to load fresh data over time | |
} | |
}, 500); // Load data or unfollow an account every interval | |
unfollowPerson = (unfollowBtn) => { | |
unfollowBtn.click(); | |
// There is a follow-up confirmation prompt so click that too | |
// NOTE - This ID may change, it is trying to find the button element for the unfollow confirmation | |
unfollowConfirmBtns = document.querySelectorAll('[data-testid="confirmationSheetConfirm"]'); | |
unfollowConfirmBtns.forEach((btn) => btn.click()); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment