Greasy Fork

Greasy Fork is available in English.

Youtube All Ads Cleaner(Include Non-Skipable Ads 100% works)

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

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

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Youtube All Ads Cleaner(Include Non-Skipable Ads 100% works)
// @require      http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js
// @namespace    http://tampermonkey.net/
// @version      1.25
// @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 checkTimers;
var videoOnPauseState;
var atHome;
setInterval(killAd, 4000);
setInterval(isAtHome, 4000);
checker();

function videoOnPause(){
     var pauseOrNot;
     $(document).ready(function(){ pauseOrNot =document.querySelector('.ytp-play-button.ytp-button').getAttribute('title');});
    atHome = isAtHome(); //must include this statement, otherwise the return result will be wrong
    if (pauseOrNot == "Play (k)" && atHome === false ){
              return true ;
                       }
    else  {
               return false;
             }
}

function isAtHome(){
    if(window.location.href == 'https://www.youtube.com/'){
        return true;
        }
    else{
        return false;
        }
}

function checker(){
    setInterval(mainTimer, 1000);
    setInterval(directSkipAd, 2000);
    setInterval(logMsg, 1000);
}

function logMsg(){
         atHome = isAtHome(); //must include this statement, otherwise the return result will be wrong
         checkTimers = mainTimer(); //must include this statement,otherwise the return result will be wrong
//         console.log('Main timers running is ' + checkTimers);
//         console.log('video paused is ' + videoOnPauseState);
//         console.log('At Home page is ' + atHome);
//         console.log('Current Url is ' + window.location.href);
         if (checkTimers === false){
                console.log('2 timers are stopped');
         }
         else{
               console.log('All timers are running');
         }}

function mainTimer(){
    var timer1 = setInterval(KillNoSkipAd, 1000);
    var timer2 = setInterval(killInVideoAd, 1000);
    videoOnPauseState = videoOnPause(); //must include this statement, otherwise the return result will be wrong
    atHome = isAtHome(); //must include this statement, otherwise the return result will be wrong
    if(atHome === true || videoOnPauseState ===true) {
                              clearInterval(timer1);
                              clearInterval(timer2);
                              return false;
                              }
   else{
           return true;
        }
}

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(){
    atHome = isAtHome(); //must include this statement, otherwise the return result will be wrong
    var ytplayer = document.getElementById("movie_player");
    var adChannelName = $('.ytp-title-channel-name')[0].text;
    var VTime = Math.round(ytplayer.getCurrentTime());
    var VideoURL = ytplayer.getVideoUrl();
    if(!atHome){
           if ($('.ad-showing') [0] !== undefined || adChannelName !==""){
           window.location = VideoURL;
    }
     }
}


function killInVideoAd(){
    if ($(".video-ads")[0] !== undefined){
        console.log('An in-video ad was removed');
        $(".video-ads").remove();
    }
}

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