Remove ads and promoted tweets on Twitter

Removes ads and promoted tweets on Twitter, as well as the large bold "Promoted Tweet" headings

Author
keyboard-shortcuts
Daily installs
2
Total installs
669
Ratings
2 0 0
Version
1.2
Created
2023-01-22
Updated
2023-08-04
License
MIT
Applies to

Remove ads and promoted tweets on Twitter

As you browse Twitter the service will inject ads and promoted tweets into your timeline and in search results or in the middle of a sequence of tweet where they disrupt the original content. These ads are often intrusive and irrelevant, and due to the way Twitter has structured them as part of the regular content they are generally not detected and removed by ad blockers.

This short script looks for the text "Ad" or "Promoted tweet" in a specific label and removes both the promoted tweet and the large bold heading that is sometimes added just above it. It also removes promoted "trending topics" on the right side of the screen.

Screenshot



Code

The code is well documented, to be as transparent as possible to users and explain what it's doing on their computer and also as a way to help new developers learn how to build something like this.

Configuration

This script is short so there isn't a lot to configure.

By default it will first look for promoted tweets once it runs (that's when the page loads), and then do it again every 500ms to catch new promoted tweets that may have appeared as you scroll. You can change this frequency by updating the value of FIND_AND_REMOVE_FREQUENCY_MS in the source code, but be careful with the value you pick. If you change it to 10, the script will run 100 times every second and make the page very slow. Similarly if you set it to 10000 then a promoted tweet could be visible for up to 10 seconds before it is removed. 500 is a compromise, with a relatively low impact on resources while being fast enough that you'll never see a promoted tweet for more than a fraction of a second, if you see one at all.

You can also set LOG_REMOVALS to true if you want the script to log a message in the web developer console every time something is removed. This is not recommended unless you're reading the script or customizing it, as it needs the developer console to be open.