Skip to content

Instantly share code, notes, and snippets.

@leo-pfeiffer
Created February 14, 2022 14:39
Show Gist options
  • Save leo-pfeiffer/6a40717fc6f98614f9b5dbaada483347 to your computer and use it in GitHub Desktop.
Save leo-pfeiffer/6a40717fc6f98614f9b5dbaada483347 to your computer and use it in GitHub Desktop.
YouTube Ad Skipper Script for Tampermonkey
// ==UserScript==
// @name YouTube Ad Skipper
// @namespace https://github.com/leo-pfeiffer
// @version 0.1
// @description Skip ads on youtube
// @match *://www.youtube.com/*
// ==/UserScript==
(function() {
let checkInterval;
let resetInterval = function() {
if (checkInterval) {
clearTimeout(checkInterval);
checkInterval = setTimeout(skip, 500);
}
checkInterval = setTimeout(skip, 500)
}
let skip = function() {
let btn = document.querySelector(".ytp-ad-skip-button.ytp-button") ||
document.querySelector(".videoAdUiSkipButton");
if (btn) {
btn.click();
resetInterval();
}
else {
resetInterval();
}
}
skip();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment