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.

34 Comments Add New Comment

  1. Thank you! This was really helpful. I have 60k people blocked and while this process is slow for me, it’s the only one that works ^^

  2. Is there any way you could (please) update this again for the new twitter theme? It would be greatly appreciated!

  3. 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.

  4. 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.

  5. This worked for me today, April 2020:

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

  6. 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..

  7. This is what I used to unmute “a lot of” people, it uses the class name which I am sure will change frequently. Finding the class name and replacing the one here will work like a charm.
    Thanks for setting up the Tutoral Luca!

    let autoUnblock = setInterval(function() {
    window.scrollBy(0, window.innerHeight);
    document.getElementsByClassName(‘css-18t94o4 css-1dbjc4n r-1niwhzg r-1iofnty r-sdzlij r-1phboty r-rs99b7 r-1w2pmg r-1vuscfd r-53xb7h r-1ny4l3l r-mk0yit r-o7ynqc r-6416eg r-lrvibr’).forEach(function(account) {
    account.click()
    });
    }, 1000);

  8. THANK YOU!! I had thousands of accounts blocked because of a blocklist and I was looking for a way to unblock them all without having to go through all of them, and finally this worked! thank you again!

  9. Does this still work? I figure I should unblock all the ones I have blocked over the years.
    How long do you think it would take to unblock over 600K 🙂

    1. 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.
      ==========

      This is still happening I take it.
      I had gone to unblock & after about 2 hours my web browser crashed. I had signed back in and when I went to my block page no blocked accounts are there anymore. But when I go on the Twitter App, I still have 10’s of thousands of blocked accounts.
      So now my question is.
      Does the blocked page ever become unblocked?
      It would be nice of Twitter to somehow let users unblock in bulk.

  10. I tried many different ways to unblock alot of accounts and this was by far the best and most reliable method.

  11. I tried this, stopped it after 7000 accounts because it wasn’t showing if the button was unclicked. And now I’m unable to see my list of blocked users. It shows on the app 100K but I can’t see them. I can add new blocked accounts but not load the old ones. Pretty unfortunate because it basically broke my Twitter account it seems.

  12. Don’t know if this will be seen or not. So I used the first script provided and I figured I would scroll down as much as I could, I had used a block list that I wanted to undo since the people blocked were not the ones that the blocklist said it would block. So after a bit I used the first script thinking it would unblock the huge chunk I scrolled through, it only unblocked some and I decided to refresh the page and now it shows no one in my block list and even though there were some accounts I wanted to reblock and went to those accounts it said they were still blocked. How can I fix this?

  13. I can’t believe this still works! Unblocked everyone blocked using the @blockNYT script. I’ll probably end up muting most of them, but have decided to use ‘block’ more judiciously.
    Also figured out how to unmute on my own by adjusting the script, then I scrolled down and found the code for that too. It also worked, but Twitter/X is *very slow* to show all of the prompts indicating successful unmuting and I’m afraid to leave the page until it catches up…

Leave a Reply

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