Greasy Fork

Greasy Fork is available in English.

Youtube Ad Cleaner(Include Non-Skipable Ads)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==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.23
// @description  Bypass all youtube ads including in video ads, skipable and non-skipable Ads
// @author       BjD
// @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 timer1;
var timer2;
var ytplayer;

setInterval(killAd, 1000);

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

checker();

function mainTimer(){
    if(window.location.href == "https://www.youtube.com/") {
        stopMonitor();
    }
    else{
        startMonitor();
    }
}

function startMonitor(){
    console.log('Monitoring Youtube Ads');
    timer1 = setInterval(KillNoSkipAd, 2000);
    timer2 = setInterval(killInVideoAd, 10000);
}

function stopMonitor(){
    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(){


    ytplayer = document.getElementById("movie_player");
    VTime = Math.round(ytplayer.getCurrentTime());
    VideoURL = ytplayer.getVideoUrl();
    if ($('.ad-showing') [0] !== undefined){

        console.log('No Skip Ad caught');
        window.location.href = VideoURL;
    }
     console.log(VTime);
     console.log(VideoURL);
}


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