Created
February 22, 2020 07:43
-
-
Save jeffwesson/261bed672cb1b5aba56fe04eefcdb2a9 to your computer and use it in GitHub Desktop.
This file contains 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
const config = { childList: true, subtree: true }; | |
const $target = document.querySelector('body'); | |
const removeAds = () => { | |
const selector = '[data-testid="placementTracking"]'; | |
document.querySelectorAll(selector).forEach(e => { | |
console.log('Another ad bites the dust!'); | |
e.parentElement.removeChild(e); | |
}); | |
}; | |
removeAds(); | |
const observer = new MutationObserver(mutations => { | |
for (let mutation of mutations) { | |
if (mutation.type === 'childList') { | |
if ([...mutation.addedNodes].length) { | |
removeAds(); | |
} | |
} | |
} | |
}); | |
observer.observe($target, config); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment