Last active
November 14, 2023 12:33
-
-
Save mrkvn/627d66d31501c10db8eeca91ef0c78c6 to your computer and use it in GitHub Desktop.
Youtube Ad Skipper with Tampermonkey
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 Youtube Ad Skipper | |
// @namespace http://tampermonkey.net/ | |
// @version 0.3 | |
// @description Youtube Ad Skipper | |
// @author mrkvn | |
// @match https://*.youtube.com/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com | |
// @grant none | |
// ==/UserScript== | |
(function () { | |
"use strict"; | |
setInterval(() => { | |
try { | |
// ad playing | |
var adImage = document.querySelector(".ytp-ad-preview-image-modern"); | |
var adText = document.querySelector(".ytp-ad-preview-text-modern") | |
if (adImage || adText) { | |
var adVideo = document.querySelector(".video-stream.html5-main-video"); | |
// finish ad | |
adVideo.currentTime = adVideo.duration; | |
setTimeout(() => {}, 50); | |
} | |
var skipAdBtn = document.querySelector(".ytp-ad-skip-button.ytp-button"); | |
if (skipAdBtn) { | |
// skip ad | |
skipAdBtn.click() | |
} | |
var skipAdBtn2 = document.querySelector(".ytp-ad-skip-button-modern.ytp-button"); | |
if (skipAdBtn2) { | |
// skip ad | |
skipAdBtn2.click() | |
} | |
} catch (error) { | |
if (error instanceof TypeError) { | |
} else { | |
} | |
} | |
}, 500); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment