YouTube Ad Skipper

Skip YouTube ad without waiting for 5 sec

当前为 2020-08-13 提交的版本,查看 最新版本

// ==UserScript==
// @name         YouTube Ad Skipper
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Skip YouTube ad without waiting for 5 sec
// @author       eggplants
// @homepage     https://github.com/eggplants
// @match        https://*.youtube.com/*
// @grant        none
// @license      MIT
// ==/UserScript==

function clickButton(elm){
    //console.log('clicked');
    if (elm){
        elm.click();
    }
}

function main(){
    let adPreviewBtn = document.getElementsByClassName('ytp-ad-text ytp-ad-preview-text');
    clickButton(adPreviewBtn[0])
    let adSkipBtn = document.getElementsByClassName('ytp-ad-skip-button ytp-button');
    clickButton(adSkipBtn[0])
    let adFlowBtn = document.getElementsByClassName('ytp-ad-overlay-close-button');
    clickButton(adFlowBtn[0])
}

setInterval(main, 100);