Greasy Fork

来自缓存

Greasy Fork is available in English.

promotion free twitter

hides promoted tweets

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        promotion free twitter
// @namespace   twitter_goes_droopy
// @description hides promoted tweets
// @match       https://x.com/*
// @version     1.1
// @run-at      document-end
// @license     MIT
// @grant       none
// ==/UserScript==


(function() {
//    'use strict';

    var n=0;
    var observer = new MutationObserver(cleanup);
    var observerConfig = {subtree:true, childList:true};
    var observenode="";
    var observer2 = new MutationObserver(start);
    var observerConfig2 = {subtree: true, characterData: true, childList: true };
    var observenode2="";

    start();

    function start(){
        observer2.disconnect();
        if(!document.querySelector('[data-testid="primaryColumn"]')){
            setTimeout(function(){start();}, 2000);
            return;
        }
        observenode2=document.getElementsByTagName('title')[0];
        observer2.observe(observenode2, observerConfig2);
        observenode=document.querySelector('[data-testid="primaryColumn"]');
        observer.observe(observenode, observerConfig);
    }

    function cleanup(){
        var tweets=document.querySelectorAll('[data-testid="tweet"]');
        for (n=0;n<tweets.length ; n++){
            if (tweets[n].querySelector('[d="M19.498 3h-15c-1.381 0-2.5 1.12-2.5 2.5v13c0 1.38 1.119 2.5 2.5 2.5h15c1.381 0 2.5-1.12 2.5-2.5v-13c0-1.38-1.119-2.5-2.5-2.5zm-3.502 12h-2v-3.59l-5.293 5.3-1.414-1.42L12.581 10H8.996V8h7v7z"]')){
                tweets[n].style.display="none";
            }
        }
    }

})();