This user script provides two functions and both can be enabled/disabled:
- Automatically filters out tweets containing specific words, phrases, or emojis from your Twitter/X timeline. It runs in the background while you browse Twitter/X and removes matching tweets in real-time. The default block feature on Twitter only blocks content in the body of the post. This will also filter out users with those items in their names.
- Avoid spoilers
- Avoid politics
- Avoid bots
- Avoid parody accounts
- Avoid triggering content
- Avoid anything :)
- Removes sections with suggested accounts to follow, which can become distracting when you want to focus only on accounts you follow. The sections are removed from the main timeline as well as from the side panel.
- Real-time filtering: Continuously scans your timeline as you browse
- Emoji support: Filters tweets containing specific emojis (e.g., flags)
- Dynamic content handling: Works with Twitter/X's infinite scrolling
- Case-insensitive matching: Ignores capitalization differences
- Customizable word list: Easily modify the filter terms
- Console logging: Optionally displays removed tweets for debugging
-
Install a userscript manager:
- Tampermonkey (Chrome, Firefox, Safari, Edge)
- Greasemonkey (Firefox)
-
Install the script:
- Direct Install Link
- Or copy/paste the script code into a new userscript
Customize the filter by editing these values in the script:
// Enable or disable words filter and "Who to follow" sections remover
const WORDS_FILTER_ENABLED = true;
const WHO_TO_FOLLOW_REMOVAL_ENABLED = true;
// Words/emojis to filter (case-insensitive)
const TARGET_WORDS = ['🇺🇦', '🇮🇱','NAFO','Trump','Elon']; To modify:
- Open Tampermonkey dashboard
- Find "Twitter Word Filter" script
- Click "Edit"
- Modify
WORDS_FILTER_ENABLEDandWHO_TO_FOLLOW_REMOVAL_ENABLEDvalues to false as you wish - Modify the
TARGET_WORDSarray - Save changes with Ctrl+S / Cmd+S
- Checks all text content within tweets
- Examines image alt-text for emojis and keywords
- Removes entire tweets containing any target word/emoji
- Removes "Who to follow" sections from the layout
- Monitors DOM changes to handle new tweets as they load
- Browsers: Chrome, Firefox, Edge, Safari
- Sites: twitter.com, x.com
- Userscript Managers: Tampermonkey, Greasemonkey, Violentmonkey
-
If tweets aren't being removed:
- Refresh the page
- Check Tampermonkey dashboard to ensure script is enabled
- Verify target words match exactly (including emojis)
- Open browser console (F12) to check for error messages
-
To see removal logs in console:
- Open browser developer tools (F12)
- Navigate to "Console" tab
- Look for "Removing tweet with text match:", "Removing tweet with image alt match:", "Removing elements related to Who to follow section" or "Removing a Who to follow aside section" messages
- Doesn't work with Twitter's mobile site or app
- Twitter/X DOM changes may require script updates
Contributions are welcome! Please open an issue or pull request.