Skip to content

Instantly share code, notes, and snippets.

@DGZN
Last active September 18, 2020 14:39
Show Gist options
  • Save DGZN/06a89ae7d24d78f732052ac625447e4d to your computer and use it in GitHub Desktop.
Save DGZN/06a89ae7d24d78f732052ac625447e4d to your computer and use it in GitHub Desktop.
JS Snippet to auto close text or video ads blocking video playback on Youtube

Youtube Ad Blocker

Run from DevTools as Snippet or paste in console

Open DevTools Command+Option+J (Mac) or Control+Shift+J (Windows)

if (window.location.href.indexOf('youtube.com')) {
  setInterval(function(){
    if (document.querySelector('.ytp-ad-info-dialog-mute-button')) {
      document.querySelector('.ytp-ad-info-dialog-mute-button').click()
      if (document.querySelector('.ytp-ad-feedback-dialog-reason-input').checked = true) {
        document.querySelector('.ytp-ad-feedback-dialog-confirm-button').click()    
      }
    }
  }, 500) 
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment