I had several thousand (?) accounts blocked because of twitter advertising.
Thanks to this I could no longer tell whether or not twitter “bugs” were blocking people without my consent. So I decided to unblock most of the accounts (most of them companies). The problem though, is this was taking forever to do manually. So I came up with a way to do it automatically (for the most part).
Step 1 — Grab the block list
Go here: https://twitter.com/settings/blocked/all
Then right-click and inspect an element in the block list.
In Brave’s HTML inspector, right-click on the very first element just above the list of <div></div>
elements, the one that represents the <div>
containing the list:
Select "Store as global variable"
from the menu.
This should bring up the console and store the list in a temp1
variable.
Step 2 — Create the unblock function
Paste the following into the console to create unblockFn
and press enter:
var unblockFn = function () {
Array.from(temp1.children).forEach((e) => {
let button = e.querySelector('[aria-label="Blocked"]');
if (button) {
button.click()
}
})
}
UPDATE August 6th: I’ve updated the code to be more resilient to changes by twitter! It will not match the old code shown in the screenshots below.
This code will need slight adjustments if twitter updates this page, but the idea will remain the same.
Step 3 — Run the unblock function while scrolling the page
Type unblockFn()
and hit Enter
.
Everything you see should be unblocked.
If you have a huge block list, you will need to scroll a bit and then run the function again. Scroll some more, run it again. Repeat until all accounts are unblocked.
Then you can re-block whatever accounts you want.
Is it possible to only mass unblock people who follow a certain account? I’m on stan twitter, and I do chain blocks, but I want to unblock only the people who follow a certain celebrity. Is that possible?
I don’t know what stan twitter is, and yes it’s probably possible but you’d have to figure out the code for it (which would probably be considerably more complex).
The code I’ve written for that involves DOM scrawling of an account’s followers to find the buttons that have “Blocked” as their ‘innerText’; this code is subject to breakage if Twitter decides to alter the element hierarchy. This also isn’t accessible in the first place if the account you want to undo chain-block on is protected or has blocked you in turn.
How do you do chain blocks?
it says temp4 for me how do i change it 🙁
You can close your browser and try following the instructions from the start, or you can write in the console:
> temp1 = temp4
Hello, I am getting this error and the code does not run for me:
Uncaught TypeError: Cannot read property ‘firstElementChild’ of undefined
at :3:86
at Array.forEach ()
at unblockFn (:2:30)
at :1:1
(anonymous) @ VM76:3
unblockFn @ VM76:2
(anonymous) @ VM93:1
Thanks for the bug report Sanjana! I just updated the code and significantly improved it! It should now be much more resilient to any changes Twitter makes!
dude im using this on someone who has 22,000 blocked accounts will it still work??
Yes.
It would take an obscene and inhumane number of hours to sit and scroll through hundreds to 10s of thousands of blocks if you’ve amassed a giant list over the years or used Twitter Block Chain. This code auto-scrolls and unblocks. ^ Source below.
^ https://lucahammer.com/2018/08/09/unblock-all-blocked-twitter-accounts-at-once/
Nice! Thank you for the contribution!
This is glorious, thank you!
Thanks to both Greg and Khloe! I’ve been looking for this for a while now. The solutions I’ve seen before this seem to all be obsoleted by twitter changes. This looks like it should survive changes and I have it running my 1.000s of blocks into unblocks. I’ll slowly build them up again but at least I know I’ll have a fix if I need it again.