NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name AutoClickYouTubeSkipAdButton // @namespace net.maiware.userscript // @description user.js for click "Skip Ad" button automatically. // @version 1.1.3 // @grant none // @match https://www.youtube.com/* // @license MIT // ==/UserScript== /*jshint esversion: 6 */ (function () { // callback for `MutationObserver` constructor const callback = (mutationRecords, observer) => { const skipButtons = document.querySelectorAll(".ytp-ad-skip-button"); for (const skipButton of skipButtons) { skipButton.click(); } // make overlay-ads hidden const overlayAds = document.querySelectorAll(".ytp-ad-overlay-slot"); for (const overlayAd of overlayAds) { overlayAd.style.visibility = "hidden"; } }; // observer instance const observer = new MutationObserver(callback); // observation options const options = { childList: true, subtree: true, }; // start MutationObserver#observe() const startObservation = (targetNode) => { if (targetNode) { observer.observe(targetNode, options); } }; const target = document.documentElement; startObservation(target); })();