Greasy Fork 还支持 简体中文。

Hide Twitter Crap

Hide noise on Twitter ("Who to follow", etc)

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        Hide Twitter Crap
// @namespace   Violentmonkey Scripts
// @match       https://x.com/*
// @grant       none
// @version     1.0
// @author      turtlebasket
// @run-at      document-idle
// @license     MIT
// @description Hide noise on Twitter ("Who to follow", etc)
// ==/UserScript==


// https://stackoverflow.com/a/61511955
function waitForEl(selector) {
    return new Promise(resolve => {
        if (document.querySelector(selector)) {
            return resolve(document.querySelector(selector));
        }

        const observer = new MutationObserver(mutations => {
            if (document.querySelector(selector)) {
                observer.disconnect();
                resolve(document.querySelector(selector));
            }
        });

        // If you get "parameter 1 is not of type 'Node'" error, see https://stackoverflow.com/a/77855838/492336
        observer.observe(document.body, {
            childList: true,
            subtree: true
        });
    });
}


for (let label of [
  '[aria-label="Premium"]',
  '[aria-label="Trending"]',
]) {
  waitForEl(label).then((el) => {
    el.style.display = 'none';
  })
}

// draft:
// hide "what's happening", "who to follow", etc; this attempts to leave the searchbar intact

// waitForEl('[aria-label="Trending"]').then((trendingEl) => {
//   let trendingContainerEls = trendingEl.childNodes[0].childNodes;
//   console.log(trendingContainerEls)
//   for (let elIndex of [2, 3]) {
//     trendingContainerEls[elIndex].style.display = 'none';
//   }
// })