Youtube Ad Cleaner(Include Non-Skipable Ads)

Bypass all youtube ads including in video ads, skipable and non-skipable Ads

当前为 2019-06-28 提交的版本,查看 最新版本

// ==UserScript==
// @name         Youtube Ad Cleaner(Include Non-Skipable Ads)
// @require      http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js
// @namespace    http://tampermonkey.net/
// @version      1.24
// @description  Bypass all youtube ads including in video ads, skipable and non-skipable Ads
// @author       BjDanny
// @match        https://www.youtube.com/*
// ==/UserScript==
// The script runs in the backgound, monitoring all youtube ads.
// When non-skipable ads are found, the script will redirect the browser to previous page and then revisits the current URL.
// Depends on the amount of non-skipable ads, the browser may refresh couple times automatically.

var VTime;
var VideoURL;
var ytplayer = document.getElementById("movie_player");

function videoOnPause(){
     var pauseOrNot = document.getElementsByClassName('ytp-play-button ytp-button')[0].getAttribute('title');
    if (pauseOrNot == "Play (k)"){return true;} else {return false;}
}

setInterval(killAd, 4000);

function checker(){
    setInterval(mainTimer, 2000);
}

checker();

function mainTimer(){
    if(window.location.href == "https://www.youtube.com/" || videoOnPause()) {
   //     console.log('stopped 2 timers');
        return false;
    }
    else{
        startMonitor();
//        console.log('started 2 timers');
        directSkipAd();
        return true;
    }
}

function startMonitor(){

var timer1 = setInterval(KillNoSkipAd, 1000);
var timer2 = setInterval(killInVideoAd, 1000);
     if (mainTimer !== true){
             clearInterval(timer1);
             clearInterval(timer2);
                                  }
}


function killAd(){
    if ($(".videoAdUiRedesign")[0] !==undefined){
        $(".video-stream").attr("src", "");
    }

    $("#player-ads").remove();
    $("#masthead-ad").remove();
    $("#offer-module").remove();
    $(".video-ads").remove();
    $("#pyv-watch-related-dest-url").remove();
}

function KillNoSkipAd(){

    VTime = Math.round(ytplayer.getCurrentTime());
    VideoURL = ytplayer.getVideoUrl();
    if ($('.ad-showing') [0] !== undefined){
        ytplayer = document.getElementById("movie_player");
        console.log('No Skip Ad killer is running');
        window.location.href = VideoURL;
    }
//     console.log(VTime);
//     console.log(VideoURL);
}


function killInVideoAd(){
    if ($(".video-ads")[0] !== undefined){
        console.log('In Video Ads killer is running');
        $(".video-ads").remove();
    }
}

function directSkipAd(){
                                   if( document.querySelector('.ytp-ad-text.ytp-ad-skip-button-text') !== undefined){
                                   document.querySelector('.ytp-ad-text.ytp-ad-skip-button-text').click();}
                                  }

QingJ © 2025

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