Last active
August 13, 2019 00:38
-
-
Save phocks/d09309f1daa991a027f4e5089edbc79c to your computer and use it in GitHub Desktop.
Hide Twitter ads on desktop site
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
// Find ads every 5 seconds and hide them | |
setInterval(function() { | |
var tags = document.getElementsByTagName("span"); | |
var searchText = "Promoted"; | |
var found; | |
for (var i = 0; i < tags.length; i++) { | |
if (tags[i].textContent == searchText) { | |
found = tags[i]; | |
break; | |
} | |
} | |
if (found) { | |
var ad = | |
found.parentElement.parentElement.parentElement.parentElement | |
.parentElement; | |
console.log("hiding", ad); | |
ad.style.display = "none"; | |
} | |
}, 5000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Quick and dirty script that scans the page every 5 seconds for an ad and then hides it. Works with:
https://chrome.google.com/webstore/detail/custom-javascript-for-web/ddbjnfjiigjmcpcpkmhogomapikjbjdk
or
https://chrome.google.com/webstore/detail/violentmonkey/jinjaccalgkegednnccohejagnlnfdag