Last active
August 9, 2023 13:17
Revisions
-
tizee revised this gist
Aug 9, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -30,7 +30,7 @@ if ( [...spans] .map((span) => span.innerHTML) .some((txt) => txt == "Promoted" || txt == "Ad") ) { tweet.style.display = "none"; console.debug("block promoted tweet", tweet); -
tizee revised this gist
Jul 15, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -42,7 +42,7 @@ }); } const regex = /^https:\/\/twitter.com\/.*$/; const observer = new MutationObserver(function (mutationList, observer) { if (!regex.test(window.location.href)) { -
tizee revised this gist
Jul 15, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ // @version 0.1 // @description Block twitter promoted tweets at home timeline // @author tizee // @match https://twitter.com/* // @icon https://www.google.com/s2/favicons?sz=64&domain=twitter.com // @grant none // ==/UserScript== -
tizee created this gist
Jul 15, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,59 @@ // ==UserScript== // @name Twitter promoted blocker // @namespace http://tampermonkey.net/ // @version 0.1 // @description Block twitter promoted tweets at home timeline // @author tizee // @match https://twitter.com/home // @icon https://www.google.com/s2/favicons?sz=64&domain=twitter.com // @grant none // ==/UserScript== (function () { "use strict"; const hiddenTweets = new WeakSet(); function watchTweetNodes(mutationList) { mutationList.forEach(function (mutationRecord) { mutationRecord.addedNodes.forEach(function (node) { if (node && typeof node.querySelector == "function") { const tweet = node.querySelector( `div[data-testid="cellInnerDiv"] article[data-testid="tweet"]` ); if (tweet) { if (hiddenTweets.has(tweet)) { return; } const spans = tweet.querySelectorAll("span"); if ( [...spans] .map((span) => span.innerHTML) .some((txt) => txt == "Promoted") ) { tweet.style.display = "none"; console.debug("block promoted tweet", tweet); hiddenTweets.add(tweet); } } } }); }); } const regex = /^https:\/\/twitter.com\/home$/; const observer = new MutationObserver(function (mutationList, observer) { if (!regex.test(window.location.href)) { return; } watchTweetNodes(mutationList); }); observer.observe(document.documentElement, { childList: true, subtree: true, }); })();