Last active
December 24, 2023 01:10
-
-
Save codiac-killer/87e027a2c4d5d5510b4af2d25bca5b01 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Auto Skip YouTube Ads | |
// @version 1.0.2 | |
// @description Speed up and skip YouTube ads automatically | |
// @author codiac-killer | |
// @match *://*.youtube.com/* | |
// @exclude *://*.youtube.com/subscribe_embed?* | |
// ==/UserScript== | |
let main = new MutationObserver(() => { | |
// Get skip button and click it | |
let btn = document.getElementsByClassName("ytp-ad-skip-button ytp-button").item(0) | |
if (btn) { | |
btn.click() | |
} | |
// (unskipable ads) If skip button didn't exist / was not clicked speed up video | |
const ad = [...document.querySelectorAll('.ad-showing')][0]; | |
if (ad) { | |
// Speed up and mute | |
document.querySelector('video').playbackRate = 16; | |
document.querySelector('video').muted = true; | |
} | |
}) | |
main.observe(document.getElementsByClassName("video-ads ytp-ad-module").item(0), {attributes: true, characterData: true, childList: true}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment