Press "Enter" to skip to content

油猴脚本屏蔽YouTube广告

安装Chrome油猴扩展:

https://chromewebstore.google.com/detail/%E7%AF%A1%E6%94%B9%E7%8C%B4/dhdgffkkebhmkfjojejmpbldmpobfkfo

Chrome扩展选择油猴脚本点击选项进入油猴配置页面,点击左侧新增按钮,增加脚本:

// ==UserScript==
// @name         自动跳过YouTube广告
// @namespace    youtube
// @version      1.0
// @description  在YouTube网页上自动跳过广告
// @author       Joey Gambler
// @match        *://www.youtube.com/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    function skipAd() {
        var skipButton = document.querySelector('.ytp-ad-text.ytp-ad-skip-button-text');
        if (skipButton) {
            skipButton.click();
            console.log("Click button");
        }
    }

    // 设置检测时间间隔
    var timer = setInterval(skipAd, 1000); // 1000毫秒 = 1秒
})();

原理:忽略广告按钮样式为:.ytp-ad-text.ytp-ad-skip-button-text

脚本一秒检测一次,检测到就进行忽略。

参考资料:

https://github.com/JoeyGambler/youtube-ad-skip/blob/main/ad-skip.js

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注