腾讯视频跳过广告

跳过腾讯视频广告

// ==UserScript==
// @name         腾讯视频跳过广告
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  跳过腾讯视频广告
// @author       zengGking
// @match        https://v.qq.com/x/cover/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=qq.com
// @grant        unsafeWindow
// @run-at       document-end
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    var $ = unsafeWindow.$;
    console.log("【加载跳过广告】..........");
    var btn=document.createElement("button");
    $(btn).text("跳过广告");
    $(btn).css({"margin-left":"20px","left":"0","top":"100px","z-index": "9999999","color":"white","cursor": "pointer"});
    $(btn).on("click",function(){
        var v=$(".txp_ad").find("txpdiv").find("video");
        v[0].currentTime =100;
        v[1].currentTime =100;
        console.log("跳过广告");
    })
    var once=0;
    var cb= function (evt) {

        if(evt.target.nodeName=="TXPDIV"&&evt.target.className=="txp_ad"&&once==0){
            //console.log("跳过广告",evt);
            once++;
            $(evt.target).ready(function(){
                $(".txp_ad").find("txpdiv.txp_ad_skip").find("txpdiv.txp_ad_skip_text")[1].remove();
                $(".txp_ad").find("txpdiv.txp_ad_skip").find("button.txp_btn.txp_btn_close")[1].remove();
                $(".txp_ad").find("txpdiv.txp_ad_skip").find("txpdiv.txp_ad_countdown")[1].after(btn);
            })
            document.querySelector("body").removeEventListener("DOMSubtreeModified",cb);
        }
    }
    document.querySelector("body").addEventListener("DOMSubtreeModified",cb, false);

})();