Hide All Replies and Threads on X.com

Completely hide all replies, including self-replies and threads, on X.com

目前为 2024-09-19 提交的版本。查看 最新版本

// ==UserScript==
// @name         Hide All Replies and Threads on X.com
// @namespace    http://tampermonkey.net/
// @version      1.8
// @description  Completely hide all replies, including self-replies and threads, on X.com
// @author       
// @match        https://x.com/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    const tweetSelector = '[data-testid="cellInnerDiv"]';
    const replySelector = '[aria-label^="Replying to"]'; // Targets replies, self-replies, and threads

    function hideRepliesAndThreads() {
        const tweets = document.querySelectorAll(tweetSelector);
        tweets.forEach((tweet) => {
            const isReply = tweet.querySelector(replySelector);
            if (isReply) {
                tweet.style.display = 'none';
                console.debug('Hid a reply, self-reply, or thread.');
            }
        });
    }

    // Observes DOM changes and applies the hiding function dynamically
    const observer = new MutationObserver(hideRepliesAndThreads);
    observer.observe(document.body, { childList: true, subtree: true });

    // Initial run to hide existing replies/threads
    hideRepliesAndThreads();
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址