Skip to content

Instantly share code, notes, and snippets.

@phocks
Last active August 13, 2019 00:38
Show Gist options
  • Save phocks/d09309f1daa991a027f4e5089edbc79c to your computer and use it in GitHub Desktop.
Save phocks/d09309f1daa991a027f4e5089edbc79c to your computer and use it in GitHub Desktop.
Hide Twitter ads on desktop site
// 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);
@phocks
Copy link
Author

phocks commented Aug 13, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment