您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Hide comments and posts from verified (blue check) users on Twitter (x.com) except whitelisted users
- // ==UserScript==
- // @name Hide Verified X Users with Whitelist
- // @namespace http://tampermonkey.net/
- // @version 2024-10-10
- // @description Hide comments and posts from verified (blue check) users on Twitter (x.com) except whitelisted users
- // @author You
- // @match *://x.com/*
- // @icon https://www.google.com/s2/favicons?sz=64&domain=x.com
- // @grant none
- // @license MIT
- // ==/UserScript==
- (function() {
- 'use strict';
- const whitelist = ["elonmusk"];
- function hideBlueCheckUsers() {
- const posts = document.querySelectorAll('article');
- posts.forEach(post => {
- const usernameElement = post.querySelector('div[dir="ltr"] a[role="link"]');
- const blueCheck = post.querySelector('svg[data-testid="icon-verified"]');
- if (blueCheck && usernameElement) {
- const username = usernameElement.getAttribute('href').replace('/', '').trim();
- if (!whitelist.includes(username)) {
- post.style.display = 'none';
- }
- }
- });
- }
- function waitForElements() {
- const observer = new MutationObserver((mutations, obs) => {
- const posts = document.querySelectorAll('article');
- if (posts.length > 0) {
- hideBlueCheckUsers();
- obs.disconnect();
- const pageObserver = new MutationObserver(hideBlueCheckUsers);
- pageObserver.observe(document.body, { childList: true, subtree: true });
- }
- });
- observer.observe(document.body, { childList: true, subtree: true });
- }
- waitForElements();
- })();