Last active
October 14, 2018 00:50
-
-
Save rafaelcastrocouto/d27e26c6ac3145e54cbff00f8d7f3663 to your computer and use it in GitHub Desktop.
Twitter Ad Block
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
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