YouTube Ad Skipper

Skip YouTube ads if they exist

目前為 2023-10-31 提交的版本,檢視 最新版本

// ==UserScript==
// @name         YouTube Ad Skipper
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Skip YouTube ads if they exist
// @author       You
// @match        https://www.youtube.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const checkElement = () => {
        const adElement = document.querySelector("#movie_player > div.video-ads.ytp-ad-module");
        if (adElement?.hasChildNodes()) {
            document.querySelector("#movie_player > div.html5-video-container > video").currentTime = 600;
            ["#skip-button\\:5", "#skip-button\\:6", "#skip-button\\:p > span > button"].forEach(selector => {
                let element = document.querySelector(selector);
                if (element) {
                    console.log("Element found: " + selector);
                    console.log(element);
                    element.click();
                }
            });
        }
    };

    // 1秒ごとにcheckElement関数を実行
    setInterval(checkElement, 1000);
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址