Greasy Fork is available in English.
Hide replies and retweets in your X.com (Twitter) home timeline.
当前为
// ==UserScript==
// @name Hide Replies and Retweets from Timeline on X.com
// @namespace http://tampermonkey.net/
// @version 1.1
// @description Hide replies and retweets in your X.com (Twitter) home timeline.
// @author
// @match https://x.com/*
// @grant none
// @license MIT
// ==/UserScript==
(function() {
'use strict';
/**
* Function to hide reply tweets and retweets from the home timeline.
*/
function hideRepliesAndRetweets() {
// Select all tweets in the timeline
const tweets = document.querySelectorAll('div[data-testid="cellInnerDiv"]');
tweets.forEach((tweet) => {
// Check if the tweet is a reply
const isReply = tweet.querySelector('div[aria-label="Replying to"]') !== null;
// Check if the tweet is a retweet
const isRetweet = tweet.querySelector('svg[aria-label="Retweeted"]') !== null ||
tweet.innerText.includes('Retweeted');
if (isReply || isRetweet) {
// Hide the tweet if it's a reply or retweet
tweet.style.display = 'none';
}
});
}
// Run the function once the DOM content is loaded
document.addEventListener('DOMContentLoaded', hideRepliesAndRetweets);
// Observe changes to the timeline to hide new replies and retweets
const observer = new MutationObserver(hideRepliesAndRetweets);
observer.observe(document.body, { childList: true, subtree: true });
})();