Hide Verified Posts

Hides posts from verified accounts

目前為 2024-10-17 提交的版本,檢視 最新版本

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

You will need to install an extension such as Tampermonkey to install this script.

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Hide Verified Posts
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  Hides posts from verified accounts
// @author       bmpq
// @match        https://x.com/*
// @match        https://twitter.com/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    function hideVerifiedAccountPosts() {
        const currentPage = window.location.pathname;

        const articles = document.querySelectorAll('article');
        articles.forEach(article => {
            const authorLink = article.querySelector('a[href^="/"][role="link"]');
            const verifiedSvg = article.querySelector('svg[data-testid="icon-verified"]');

            if (verifiedSvg && authorLink) {
                let profileUrl = authorLink.getAttribute('href');
                let username = authorLink.getAttribute('href').substring(1);

                if (currentPage.includes(profileUrl)) {
                    return;
                }

                const infoDiv = document.createElement('div');
                infoDiv.style.color = 'rgb(113, 118, 123)';
                infoDiv.style.fontFamily = 'TwitterChirp, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif';
                infoDiv.style.padding = '10px 10px';

                const link = document.createElement('a');
                link.href = profileUrl;
                link.textContent = `@${username}`;
                link.style.color = 'inherit';
                link.style.textDecoration = 'none';

                infoDiv.textContent = `Hidden verified post from `;
                infoDiv.appendChild(link);

                article.replaceWith(infoDiv);
            }
        });
    }

    const observer = new MutationObserver((mutations) => {
        mutations.forEach((mutation) => {
            hideVerifiedAccountPosts();
        });
    });

    observer.observe(document.body, {
        childList: true,
        subtree: true
    });
})();