Connor9994 / Twitter-Filter

JS to filter Twitter posts

Repository from Github https://github.comConnor9994/Twitter-FilterRepository from Github https://github.comConnor9994/Twitter-Filter

Twitter Word Filter

Overview

This user script 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 :)

Features

  • 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

Installation

  1. Install a userscript manager:

  2. Install the script:

Configuration

Customize the filter by editing these values in the script:

// Words/emojis to filter (case-insensitive)
const TARGET_WORDS = ['๐Ÿ‡บ๐Ÿ‡ฆ', '๐Ÿ‡ฎ๐Ÿ‡ฑ','NAFO','Trump','Elon']; 

// How often to check for new tweets (milliseconds)
const CHECK_INTERVAL = 1000; 

To modify:

  1. Open Tampermonkey dashboard
  2. Find "Twitter Word Filter" script
  3. Click "Edit"
  4. Modify the TARGET_WORDS array
  5. Save changes with Ctrl+S / Cmd+S

How It Works

  1. Scans your timeline every second (configurable)
  2. Checks all text content within tweets
  3. Examines image alt-text for emojis and keywords
  4. Removes entire tweets containing any target word/emoji
  5. Monitors DOM changes to handle new tweets as they load

Compatibility

  • Browsers: Chrome, Firefox, Edge, Safari
  • Sites: twitter.com, x.com
  • Userscript Managers: Tampermonkey, Greasemonkey, Violentmonkey

Troubleshooting

  • If tweets aren't being removed:

    1. Refresh the page
    2. Check Tampermonkey dashboard to ensure script is enabled
    3. Verify target words match exactly (including emojis)
    4. Open browser console (F12) to check for error messages
  • To see removal logs in console:

    1. Open browser developer tools (F12)
    2. Navigate to "Console" tab
    3. Look for "Removed tweet containing:" messages

Limitations

  • Doesn't work with Twitter's mobile site or app
  • Twitter/X DOM changes may require script updates

Contributing

Contributions are welcome! Please open an issue or pull request.

About

JS to filter Twitter posts


Languages

Language:JavaScript 100.0%