您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Remove promoted tweets from Twitter
当前为
// ==UserScript== // @name Twitter - Remove Promoted Tweets // @description Remove promoted tweets from Twitter // @author Nick Stakenburg // @namespace https://gist.githubusercontent.com/staaky // @license MIT; https://opensource.org/licenses/MIT // @include http://twitter.com/* // @include https://twitter.com/* // @include http://*.twitter.com/* // @include https://*.twitter.com/* // @icon https://twitter.com/favicon.ico // @version 1.0.1 // ==/UserScript== (() => { // remove all tweets that contain an svg path that matches the promoted tweet icon // this avoids language based checks const pathDs = [ 'M20.75 2H3.25A2.25 2.25 0 0 0 1 4.25v15.5A2.25 2.25 0 0 0 3.25 22h17.5A2.25 2.25 0 0 0 23 19.75V4.25A2.25 2.25 0 0 0 20.75 2zM17.5 13.504a.875.875 0 1 1-1.75-.001V9.967l-7.547 7.546a.875.875 0 0 1-1.238-1.238l7.547-7.547h-3.54a.876.876 0 0 1 .001-1.751h5.65c.483 0 .875.39.875.874v5.65z' ]; function removeAdTweets() { // old and new twitter let articles = document.querySelectorAll('article:not([adschecked]), li[data-item-type="tweet"]:not([adschecked])'); for (let article of articles) { let removeElement = false; article.setAttribute('adschecked', 'adschecked'); for (let d of pathDs) { if (article.querySelectorAll(`svg path[d='${d}'], .Icon--promoted`).length > 0) { let parent = article.parentNode, removeElement = article, height = article.getBoundingClientRect().height; while (parent && (parent.getBoundingClientRect().height <= height + 1)) { removeElement = parent; parent = parent.parentNode; } // for debugging (blank out instead of remove) //removeElement.setAttribute('style', 'opacity: 0'); removeElement.remove(); } } } } let mutationObserver = new MutationObserver(removeAdTweets); mutationObserver.observe(document.body, { childList: true, subtree: true }); removeAdTweets(); })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址