Skip to content

Instantly share code, notes, and snippets.

@jonkpirateboy
Last active March 20, 2026 10:56
Show Gist options
  • Select an option

  • Save jonkpirateboy/58c00963273405b416f3ec443f455ffc to your computer and use it in GitHub Desktop.

Select an option

Save jonkpirateboy/58c00963273405b416f3ec443f455ffc to your computer and use it in GitHub Desktop.
Tampermonkey: YouTube Auto Skip Ads. Install Tampermonkey https://www.tampermonkey.net/ and add the script. Done.
// ==UserScript==
// @name YouTube Auto Skip Ads
// @description Skips ads on YouTube
// @namespace https://pirateboy.net
// @version 1.1
// @author Jonk
// @match https://www.youtube.com/*
// @grant none
// ==/UserScript==
(function () {
'use strict';
function skipAds() {
const video = document.querySelector('video');
if (video && document.querySelector('.ad-showing')) {
video.currentTime = video.duration || 9999;
}
const skipBtn = document.querySelector('.ytp-ad-skip-button, .ytp-ad-skip-button-modern');
if (skipBtn) skipBtn.click();
}
const observer = new MutationObserver(skipAds);
observer.observe(document.body, { childList: true, subtree: true });
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment