Last active
November 12, 2023 18:12
-
-
Save szepeviktor/25d8cbae43e1dcbcc5e103e7dee89b25 to your computer and use it in GitHub Desktop.
Auto Fast-forward YouTube ads -> https://github.com/szepeviktor/fast-forward-youtube-ads
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
document.querySelector("#container video.html5-main-video").onwaiting = (event) => { | |
var to; | |
var cnt = 0; | |
var ov = event.target.volume; | |
if (document.querySelector("#movie_player.ad-created") === null) { | |
return; | |
} | |
to = setTimeout(() => { | |
var skip = document.querySelector("[id^=ad-text].ytp-ad-skip-button-text"); | |
cnt = cnt + 1; | |
console.log("Looking for skip button"); | |
if (skip !== null) { | |
console.log("Clicking skip button"); | |
event.target.playbackRate = 1; | |
event.target.volume = ov; | |
skip.click(); | |
clearTimeout(to); | |
} else if (document.querySelector("#movie_player.ad-created") !== null) { | |
console.log("Fast-forwarding ad"); | |
event.target.volume = 0.01; | |
event.target.playbackRate = 10; | |
} else if (document.querySelector("#movie_player.ad-created") === null) { | |
console.log("Ad has finished"); | |
event.target.playbackRate = 1; | |
event.target.volume = ov; | |
clearTimeout(to); | |
} else if (cnt >= 10) { | |
console.log("10+ runs"); | |
clearTimeout(to); | |
} | |
}, 1000); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Get storyboard URL