Created
July 21, 2019 09:50
-
-
Save AJamesPhillips/82c4fda8d6c6e13ec2d191407cae9b7c to your computer and use it in GitHub Desktop.
Kills some ads
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
// Based off: https://gist.github.com/jasonleonhard/177b67f135c443719fe8 | |
function removeElement (element) { | |
element.parentNode.removeChild(element); | |
} | |
function removeElements (elements) { | |
for (var i = 0; i < elements.length; ++i) { | |
removeElement(elements[i]); | |
} | |
} | |
function killAds() { | |
console.log("Killing ads") | |
// remove all iframes | |
var iframes = document.getElementsByTagName("iframe"); | |
removeElements(iframes); | |
// remove all scripts | |
var scripts = document.getElementsByTagName("script"); | |
removeElements(scripts); | |
// remove other things | |
const otherClassNames = [".ad-container",".click-layer",".videoAdUi",".ytp-ad-progress","#masthead-positioner","#masthead-positioner-height-offset","#yt-masthead-container",".annotation",".ytp-block-autohide","ad-container"] | |
otherClassNames.forEach(className => { | |
const elements = document.getElementsByClassName(className); | |
removeElements(elements); | |
}) | |
} | |
setInterval(killAds); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment