Skip to content

Instantly share code, notes, and snippets.

@nikhilbhatt
Last active November 6, 2023 06:27
Show Gist options
  • Save nikhilbhatt/85b7d42543f9fe6c1e58a6cb1fe5238b to your computer and use it in GitHub Desktop.
Save nikhilbhatt/85b7d42543f9fe6c1e58a6cb1fe5238b to your computer and use it in GitHub Desktop.
Skip You Tube Ad script
javascript:(function(){setInterval(()=>{const skipButton = document.querySelector('.ytp-ad-skip-button'); const adOverlay= document.querySelector('.ytp-ad-overlay-close-container'); if(adOverlay !=undefined) adOverlay.click(); if(skipButton != undefined) skipButton.click();}, 2000)})();
setInterval(()=>{
const adOverlay = document.querySelector('.ytp-ad-overlay-close-container');
const skipButton = document.querySelector('.ytp-ad-skip-button');
if(adOverlay !=undefined)
adOverlay.click();
if(skipButton != undefined)
skipButton.click();
}, 2000);

Javascript Code to skip youtube ad

code 1. js_console_code.txt

steps to follow:-

  1. press ctrl+shift+i in youtube window or open console in youtube window.
  2. paste the code from js_console_code.txt file.
  3. press enter
  4. close the cosole tab and you are good to go. run the above code in console and you will not see the any ad for that particular session.

But it is difficult to remember this code everytime. other simple way is:

code 2. bookmarks_code.txt

  1. Open bookmarks tab. 2 create new bookmark.
  2. add code from bookmarks_code.txt into URL and give it a name.
  3. now when you go to youtube. click over this bookmark link and you will not see any ad again.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment