Last active
September 6, 2024 11:54
-
-
Save chorn/8469492eb3312a8578029ef7af5fd27f to your computer and use it in GitHub Desktop.
Remove Promoted Tweets - RunAt: document-start
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 characters
// ==UserScript== | |
// @name Twitter Remove Promotions | |
// @description Remove Promoted Tweets | |
// @author chorn | |
// @match https://twitter.com/* | |
// @match https://x.com/* | |
// @include https://twitter.com/* | |
// @include https://x.com/* | |
// @run-at document-start | |
// @version 1.1.0 | |
// ==/UserScript== | |
function nerfPromotionsForTag(tag) { | |
const elements = document.getElementsByTagName(tag); | |
let len = elements.length; | |
let i; | |
let removed = 0; | |
for (i = 0; i < len && removed <= 25; i++) { | |
if( | |
elements[i] && | |
elements[i].innerHTML && | |
elements[i].innerHTML.startsWith("Promoted") | |
) { | |
elements[i].parentElement.parentElement.parentElement.parentElement.parentElement.remove(); | |
removed++; | |
} | |
} | |
} | |
setInterval(function() { | |
nerfPromotionsForTag('div'); | |
nerfPromotionsForTag('span'); | |
}, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment