Last active
November 28, 2022 13:12
-
-
Save quienn/5072e037cdc30af1e6c7594af5c4957c to your computer and use it in GitHub Desktop.
Userscript that blocks YouTube 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
if (window.location.hostname === 'www.youtube.com') { | |
const adBlocker = setInterval(() => { | |
const ad = [...document.querySelectorAll('.ad-showing')][0]; | |
if (ad) { | |
document.querySelector('video').playbackRate = 10; | |
const btn = document.querySelector('.videoAdUiSkipButton,.ytp-ad-skip-button'); | |
if (btn) { | |
btn.click(); | |
} | |
} else { | |
clearInterval(adBlocker); | |
} | |
}, 50); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment