This Tampermonkey userscript allows you to customize the appearance of tweets on X (formerly Twitter) based on user-defined rules. Apply CSS styles based on the content of tweets, such as author, stats (likes, retweets, views), text content, and more.
- Custom CSS Classes: Define your own CSS classes with specific styles.
- Rule-Based Styling: Create rules to apply these classes to tweets based on various criteria.
- Dynamic Updates: Changes to rules and styles are applied in real-time.
- Persistent Settings: Your custom rules and classes are saved and loaded automatically.
- Hideable Menu: Discreetly manage your rules with a hideable menu.
- Install Tampermonkey (or a similar userscript manager) in your browser.
- Copy the code from
tweet-display-filter.js
. - Create a new userscript in Tampermonkey and paste the copied code.
- Save the script.
- Open X (Twitter): Go to x.com.
- Open the Menu: A small "Show" button will appear in the top-right corner of the page. Click it to open the menu.
- Manage CSS Classes:
- Add Class: Click the "+ Class" button to add a new class.
- Edit Class: Enter the class name and CSS properties in the respective text boxes.
- Delete Class: Click the "×" button to remove a class.
- Manage Rules:
- Add Rule: Click the "+ Rule" button to add a new rule.
- Edit Rule:
- Field: Select the tweet property to check (author id, likes, text, etc.) from the first dropdown.
- Relation: Select the comparison operator (contains, equals, at least, etc.) from the second dropdown.
- Argument: Enter the value to compare against in the text box.
- Classes: Enter a comma-separated list of classes to apply if the rule matches.
- Enable: Check the box to enable the rule.
- Delete Rule: Click the "×" button to remove a rule.
- Hide the Menu: Click the "Hide" button to collapse the menu, keeping your customizations active.
Here are a few examples to get you started:
-
Blur Tweets with Many Likes:
- Field:
likes
- Relation:
at least
- Argument:
100
- Classes:
blur-popular
- CSS Class
blur-popular
:filter: blur(0.5px);
- Field:
-
Hide Tweets from a Specific User:
- Field:
id
- Relation:
equals
- Argument:
@annoyinguser
- Classes:
hidden-tweet
- CSS Class
hidden-tweet
:display: none;
- Field:
id
: The author's Twitter handle (e.g., @username).views
: The number of views the tweet has received.likes
: The number of likes the tweet has received.retweets
: The number of retweets the tweet has received.replies
: The number of replies the tweet has received.text
: The text content of the tweet.date
: The date the tweet was posted. It is of the form Month Day or, for recent tweets, Number[smhd], where s, m, h, d corresponds to seconds, minutes, hours, and days respectively, the number representing how long ago it was since the tweet was posted.images
: An array of image URLs included in the tweet.reposter id
: The Twitter handle of the user who reposted the tweet.
contains
: Checks if the field contains the argument (case-insensitive).doesn't contain
: Checks if the field does not contain the argument (case-insensitive).equals
: Checks if the field is exactly equal to the argument.doesn't equal
: Checks if the field is not exactly equal to the argument.at least
: Checks if the field is greater than or equal to the argument (numeric fields only).at most
: Checks if the field is less than or equal to the argument (numeric fields only).exists
: Checks if the field has a value. Checks if array-valued fields are nonempty for array fieldsdoesn't exist
: Checks if the field is does not have a value, or is an empty array.