Skip to content

Instantly share code, notes, and snippets.

@rafaelcastrocouto
Last active October 14, 2018 00:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rafaelcastrocouto/d27e26c6ac3145e54cbff00f8d7f3663 to your computer and use it in GitHub Desktop.
Save rafaelcastrocouto/d27e26c6ac3145e54cbff00f8d7f3663 to your computer and use it in GitHub Desktop.
Twitter Ad Block
console.log('twitter ad block');
var clear = function () {
document.querySelectorAll('svg + div').forEach(function (a) {
if(a.textContent.search('Promoted') > -1) {
var p = a;
for(var c=0; c<7; c++){
if (p.tagName == 'A' && p.classList.contains('rn-1loqt21 ')) break;
p = p.parentElement;
}
if (p.classList.contains('rn-qklmqi') || p.classList.contains('rn-1loqt21 ')) {
console.log('ad blocked');
p.style.display = 'block';
}
}
});
};
var mutationObserver = new MutationObserver(clear);
mutationObserver.observe(document.documentElement, {
attributes: false,
characterData: false,
childList: true,
subtree: true,
attributeOldValue: false,
characterDataOldValue: false
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment