// ==UserScript== // @name Twitter Promoted // @namespace http://tampermonkey.net/ // @version 0.1 // @description Get rid of stupid promoted tweets // @author Mac Gaulin // @match http*://twitter.com/* // @grant none // ==/UserScript== (function() { 'use strict'; // source: https://stackoverflow.com/a/59687531 function contains(selector, text) { var elements = document.querySelectorAll(selector); return Array.from(elements).filter(function(element) { return RegExp(text).test(element.textContent); }); } function removePromoted() { let found = contains("span", "^Promoted"); console.log("Found " + found.length + " promoted tweets."); for (let i = 0; i < found.length; i++) { let elem = found[i]; let art = elem.closest("article"); if (art) { art.style.display = 'none'; art.parentNode.style.backgroundColor = "red"; console.log("Hid promoted tweet " + i); } else { console.log("Promoted tweet wasn't an article", elem); } } } setTimeout(removePromoted, 7000); })();