Tutorial Twitter

Unblock all blocked Twitter accounts at once

  • Update 21.04.2020: The code still works, but only if you set the account language to English.
  • Update 23.11.2019: There are reports that Twitter started to prevent the automated unblocking of accounts. After some 50 to 100 unblocks, the page with blocked accounts get blocked. As a result the script may currently not work.
  • Update 17.11.2019: The old code only worked in Firefox. I updated it to work in Chrome as well.
  • Update 12.07.2019: NewTwitter also known as Twitter Web has a completely new interface. I updated the code accordingly.

If you have blocked hundreds of accounts, unblocking them one by one takes a lot of time. But there is a quick and easy way to unblock them all at once. You don’t need to give any app write permissions to your account for it to work.

Short version

Got to the blocked accounts setting page and enter the following code. It will unblock all visible accounts.

document.querySelectorAll('[aria-label="Blocked"]').forEach(function(account) {
         account.click()
     });

Long version

1. Go to the settings

On this page you see all accounts your are blocking at the moment:
https://twitter.com/settings/blocked

2. Open the Developer Tools

Quickest way: Press F12 on Windows/Linux or Command+Option+I on MacOS. Tested on Chrome and Firefox.
You can go through the menu as well. Firefox: Extras -> Web Developers. Chrome: Other Tools -> Developer Tools.

You should now see a new area in your browser. Either on the right side or on the bottom of the window.

3. Open the Browser Console

Either by pressing “Esc” or selecting it in the top menu of the developer tools. With the console you can execute any JavaScript commands.

4. Execute autoUnblock-snippet in the browser console

The Twitter web interface got a new design. NewTwitter (also known as Twitter Web App) is written in React and it unloads elements while scrolling. Because of that we need to scroll just a bit, unblock all visible accounts, scroll again, unblock some more and so on.

The following code sets up an interval which fires every second (1000 milliseconds). After each second it scrolls down one page, selects all unblockable accounts and clicks the unblock button.

let autoUnblock = setInterval(function() {
    window.scrollBy(0, window.innerHeight);
    document.querySelectorAll('[aria-label="Blocked"]').forEach(function(account) {
        account.click()
    });
}, 1000);

5. Stop the autoUnblocker once it’s done

Once all accounts are unblocked, you can stop it by executing the following code in the browser console. Alternatively, just close the browser tab.

clearInterval(autoUnblock)

Done

All accounts should now be unblocked. If you have any questions, let me know on Twitter.

Optional one-time reversal of the process

With the new code you can’t accidentally follow the once blocked accounts anymore. That’s great. Additionally it is possible to block them again. But only while the browser tab is open. Once the tab is closed, the list of accounts is gone.

Execute the following snippet to block all the accounts you just unblocked. The only change is from ‘Blocked’ to ‘Block’ in the aria-label.

let autoBlock = setInterval(function() {
    window.scrollBy(0, window.innerHeight);
    document.querySelectorAll('[aria-label="Block"]').forEach(function(account) {
        account.click()
    });
}, 1000);

This code needs to be stopped as well.

clearInterval(autoBlock)

Bonus: Unmute all muted accounts

Some people asked me how to umute all accounts they ever muted. With the new code snippet that’s easy as well.

Go to the settings page with the muted accounts: https://mobile.twitter.com/settings/muted/all

let autoUnmute = setInterval(function() {
    window.scrollBy(0, window.innerHeight);
    document.querySelectorAll('[aria-label^="Unmute"]').forEach(function(account) {
        account.click()
    });
}, 1000);

Once all accounts are unmuted, stop it:

clearInterval(autoUnmute)

To reverse it (only while possible while you haven’t left the page), change the name from ‘autoUnmute’ to ‘autoMute’ (or anything else) and replace ‘[aria-label^=”Unmute”] with ‘[aria-label^=”Mute”]’.

Technical explanation: The ‘ ^ ‘ is necessary because the aria-labels for Muting/Unmuting contain the account name. ‘ ^ ‘ says, that the aria-label starts with the phrase, but it can contain other stuff. For the blocked accounts that isn’t necessary because they all have the same aria-label.

13 Comments Add New Comment

  1. Although Twitter does turn on a block on the API if one executes your code as written, if you make the API execution less frequent — change to 10000 instead of 1000 msec — it seems to run unabated as long as you leave the browser window open. Yes, it will take longer to complete the unblocking, but I have searched and found no other way of mass unblocking. Note that the amount of time needed between unblock attempts (10000 vs 1000) depends on the screen height – and specifically, the number of accounts unblocked in each unblocking attempt. If more accounts are unblocked, a longer wait time is proportionately required, else Twitter will return, after a few attempts, an error. I find the correct proportion is along the lines of 3 seconds per account blocked.

    I subscribed to a blocklist which blocked 90,000 accounts. There was no way to unblock them that I could find – except this description you give. So, I thank you, for this!

    By my estimation, it will take 3.5 days to complete the unblocking. Clearly, Twitter should provide an easier way to accomplish this.

  2. Thank you! I used it today on Chrome and it worked non stop and finally could unblock thousand of accounts.
    It didn´t work for me a few months ago.

  3. This worked for me today, April 2020:

    document.querySelectorAll(‘[aria-hidden=”true”]’).forEach(function(account) {
    if (account.textContent == “Blocked”) {
    account.click()
    }
    });

  4. I had to set mine to 4000 to keep from Twitter locking me out. Thanks for the script to unblock about 90k, given the script appeared to be doing about 30k an hour..

Leave a Reply

Your email address will not be published. Required fields are marked *