Greasy Fork

Greasy Fork is available in English.

Youtube Ad Cleaner(Include Non-Skippable Ads- works)

(Chrome ONLY) Bypass all youtube ads including in video ads, skippable and non-skippable Ads

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Youtube Ad Cleaner(Include Non-Skippable Ads- works)
// @namespace    http://tampermonkey.net/
// @version      1.32
// @description  (Chrome ONLY) Bypass all youtube ads including in video ads, skippable and non-skippable Ads
// @author       BjDanny
// @match        *://*.youtube.com/*
// ==/UserScript==

var home;
var myWin;
window.addEventListener("load", checkHome);
window.addEventListener("yt-navigate-start", checkHome);

function fastHomeListener(){
if(document.getElementById('logo')){
   document.getElementById('logo').addEventListener("click", fasterBackHome);
    console.log('fastHomeListener is activated');
}}

function fasterBackHome(){
     var ytplayer = document.getElementById("movie_player");
    ytplayer.cancelPlayback();
    console.log('Home logo is clicked');
    window.location.href = 'https://www.youtube.com';
}

function checkHome() {

if(window.location.href !=='https://www.youtube.com/'){
    home = false;
    console.log('At home =', home);

    var timer1 = setInterval(KillNoSkipAd,1000);
    var to1 = setTimeout(cfmReload,2000);
    var to2 = setTimeout(fastHomeListener, 1000);
    var timer3 = setInterval(killInVideoAd,1000);
    setTimeout(killAd,1000);
    }
    else{
    home = true;
    console.log('timer1 cleared');
    clearInterval(timer1);
    if(to1){
    console.log('to1 cleared');
    clearTimeout(to1);
    }
    console.log('timer3 cleared');
    clearInterval(timer3);
    console.log('At home =', home);
    setTimeout(killAd,1000);
    }
}

function killAd(){
    try{
    if (document.getElementsByClassName("videoAdUiRedesign")[0] !==undefined){
        document.getElementsByClassName("video-stream").attr("src", "");
    }
    document.getElementById("player-ads").remove();
    document.getElementById("masthead-ad").remove();
    document.getElementById("offer-module").remove();
    document.getElementById("pyv-watch-related-dest-url").remove();
    document.getElementById('ytd-promoted-video-renderer').remove();
    console.log('Sponsored cards - removed');
    }
    catch(e){return;}
}

function KillNoSkipAd(){
    var ytplayer = document.getElementById("movie_player");
    var VdoTime = ytplayer.getCurrentTime();
    try{
  var adChannelName = document.getElementsByClassName('ytp-title-channel-name')[0].text;
           if (document.getElementsByClassName('ad-showing') [0] !== undefined || adChannelName !==""){
            console.log('skipped in-video ad');
            ytplayer.cancelPlayback();
             setTimeout(ytplayer.playVideo(), 1000);
             setTimeout(function() {if (ytplayer.getCurrentTime() == VdoTime){location.reload(); fixLoop(); console.log('Reloaded again !!!');}}, 2000);
           }
    }catch(e){return;}
}

function cfmReload(){
    var ytplayer = document.getElementById("movie_player");
    try{
    var pauseOrNot = document.querySelector('.ytp-play-button.ytp-button').getAttribute('title');
        if (pauseOrNot == 'Pause (k)' && ytplayer.getCurrentTime() == 0){
        location.reload();
        fixLoop();
        console.log('Skipped Preload Video Ad');
     }
    else{console.log('No preload video Ad. Good !');}}
catch(e){return;}}

function killInVideoAd(){
    try{
    if (document.getElementsByClassName("video-ads")[0] !== undefined){
        document.getElementsByClassName("video-ads")[0].remove();
        console.log('Overlay ads - removed');
    }
}catch(e){return;}

    //below function skips the Next Video count down circle. If you don't like it,just comment it out or delete it.
    noWaitToNextVdo();
}

function fixLoop(){
   console.log('fixLoop is triggered');
   myWin = window.open('', '_blank');
   myWin.document.write("<script>function closeIt(){window.close();} window.onload=setTimeout(closeIt, 1000);<\/script><p>Skipping Ad ... auto close!!</p>");
   myWin.focus();
    }

function noWaitToNextVdo(){
    try{ if(!document.getElementsByClassName('ytp-svg-autoplay-ring')[0].getAttribute('stroke-dashoffset').startsWith('-211')){
               console.log('Jumping to next video');
               document.getElementsByClassName('ytp-upnext-autoplay-icon')[0].click();}
    }
    catch(err){return;}
}