Skip to content

Instantly share code, notes, and snippets.

@icze4r
Last active December 7, 2022 09:38
Show Gist options
  • Save icze4r/b991d4c974de2ff91ed57c81141da426 to your computer and use it in GitHub Desktop.
Save icze4r/b991d4c974de2ff91ed57c81141da426 to your computer and use it in GitHub Desktop.
If you have like 30,000+ people blocked, unblocking them is damned near impossible. Twitter provides no tool for it and no application is going to be able to get away with unblocking everybody without running into severe API limits(?). By that I mean, you're going to start getting into trouble for sending too many requests to the server. You don't want that, because that's going to log you out of your account, and even possibly suspend you.
Someone has already provided the code to unblock Twitter accounts: https://lucahammer.com/2018/08/09/unblock-all-blocked-twitter-accounts-at-once
But I found that it goes too fast. You run into limits. I have no idea what limitations there are in the API for how many people you can unblock. But this script seems to unblock 20-30 people at a time.
I've tested unblocking people for 6 hours at a polling rate of 60 seconds (it unblocks 20-30 people and advances the page so you can unblock more). I did not get rate-limited; I did not get in trouble. I have also tested unblocking people at a rate of every 10 seconds, and I ran into limits about 2-3 times, though that could've just been Twitter breaking under the strain of the World Cup.
10 seconds works well. 60 seconds works if you want to go to sleep and not worry about it.
----
How to do this:
* Navigate to https://twitter.com/settings/blocked/all
* Go into Console (I use Chrome) and put this in
let autoUnblock = setInterval(function() {
window.scrollBy(0, window.innerHeight);
document.querySelectorAll('[aria-label="Blocked"]').forEach(function(account) {
account.click()
});
}, 10000);
Hit enter
When you want it to stop, put in
clearInterval(autoUnblock)
and hit Enter.
If the page gets to be too big, click on someone who is still blocked so that you go to their page within the same tab. Then click the browser's back button: Twitter will cull all the unblocked people from the display, potentially freeing up memory.
At 3 seconds per unblock request I quickly would get rate-limited. At 10 seconds it seems I can do this perpetually, though you should be careful (I got logged out once, though this is probably just due to Elon's running of Twitter)
In about 8 hours I've unblocked 57,600 people (I probably have upwards of a million blocked). This is going to be an interesting experiment, and it's running well so far (◕ᴗ◕✿)
* EDIT: After about a day, 10 seconds also works just fine. It starts messing up at 6 seconds (page updates too slow)
* EDIT 2: Been using this since I published this and I want to add a note: if you block a lot of people who later get suspended, I'm talking, 20-30+ people, who all got suspended in a line (as in, you have 20-30 suspended accounts in your block list, consecutively), THEN TWITTER MIGHT JUST SHOW YOU A BLANK BLOCK PAGE BECAUSE IT HAS NO FAILBACK FOR WHEN THIS SORT OF THING HAPPENS.
That's right: Twitter never figured that you might block enough people where, when they all get suspended, they just don't show up in your list. They don't show up in your list because, though they're represented in the data that gets pulled when the Block page is updated, they just don't show up on the page.
If you run into this problem-- you have a blank Block page, but you KNOW you still have people blocked-- wait about 2-3 weeks. After that, the page will update, and you might get at least one person blocked to show up.
Okay. Once you have THAT, go to Developer Tools in Chrome, and use that to resize the page; or, just resize the window you're viewing this in a lot, until you hit the Responsive Media Queries (or whatever), that change the display of the page. THIS WILL ACTIVATE THE MECHANISM THAT LOADS MORE BLOCKED ACCOUNTS, and you can eventually force it to keep on loading accounts until you get through the line of Suspended accounts you cannot see.
After that, be sure to keep ONE person blocked, so that you can always force it to update when you want it to.
If you don't want to wait 2-3 weeks, then you're going to have to figure out how to trigger the "load more blocked accounts" thingy, becasue I can't.
** Tidbit: After a certain point, people you've blocked get sorted by THEIR account age. This is weird. But you can kind of tell how many people you have left to block, based on tracking the people you're unblocking with the script. It goes backwards: like Nov 2010, Oct 2010, etc. Unless there's some sort of error, you shouldn't expect to see any account made before March of 2006.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment