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

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

目前為 2020-03-17 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Youtube Ad Cleaner (Include Non-Skippable Ads- works)
// @namespace    http://tampermonkey.net/
// @version      1.38
// @description  (Chrome ONLY) Bypass all youtube ads including in video ads, skippable and non-skippable Ads
// @author       BjDanny
// @run-at          document-start
// @match        *://*.youtube.com/*
// ==/UserScript==
'use strict';
setInterval(killAd,1);
var timer1;
var timer2;
var to1;
var to2;
//window.addEventListener("load", checkHome);
window.addEventListener("DOMContentLoaded", 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/'){
    timer1 = setInterval(checkv,1);
    timer2 = setInterval(killInVideoAd,1);
    to1 = setTimeout(cfmReload,2000);
    to2 = setTimeout(fastHomeListener, 1000);
    }
    else{
     clearInterval(timer1);
     clearInterval(timer2);
     clearTimeout(to1);
     clearTimeout(to2);
    }
}

function killAd(){

           if (document.getElementById("masthead-ad") !==null && document.getElementById("masthead-ad") !==undefined){
            document.getElementById("masthead-ad").remove();}

           if (document.getElementById("player-ads") !==null && document.getElementById("player-ads") !==undefined){
            document.getElementById("player-ads").remove();}

      if (document.getElementById("top-container") !==null && document.getElementById("top-container") !==undefined){
            document.getElementById("top-container").remove();}


           if (document.getElementById("offer-module")!==null && document.getElementById("offer-module")!==undefined){
            document.getElementById("offer-module").remove();}

           if (document.getElementById("pyv-watch-related-dest-url")!==null && document.getElementById("pyv-watch-related-dest-url")!==undefined){
            document.getElementById("pyv-watch-related-dest-url").remove();}

         if (document.getElementsByClassName('style-scope ytd-search-pyv-renderer')[0]!==null && document.getElementsByClassName('style-scope ytd-search-pyv-renderer')[0]!==undefined){
            document.getElementsByClassName('style-scope ytd-search-pyv-renderer')[0].remove();}


           if (document.getElementById('ytd-promoted-video-renderer')!==null && document.getElementById('ytd-promoted-video-renderer')!==undefined){
            document.getElementById('ytd-promoted-video-renderer').remove();}

        if (document.getElementsByClassName('style-scope ytd-search-pyv-renderer')[0] !==null && document.getElementsByClassName('style-scope ytd-search-pyv-renderer')[0] !==undefined){
           document.getElementsByClassName('style-scope ytd-search-pyv-renderer')[0].remove();}

           if (document.getElementsByTagName('ytd-promoted-sparkles-text-search-renderer')[0] !==null && document.getElementsByTagName('ytd-promoted-sparkles-text-search-renderer')[0] !==undefined){
                   document.getElementsByTagName('ytd-promoted-sparkles-text-search-renderer')[0].remove();}

}

function checkv(){
	var v = document.querySelector("#player .ad-interrupting video");
	if (v && v.src!=""){
		v.src = "";
        console.log("Skipped Ads");
	}
}

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(){
//   console.log('timer2');
    try{
    if (document.getElementsByClassName("video-ads")[0] !== undefined){
        document.getElementsByClassName("video-ads")[0].remove();
        console.log('Overlay ads - removed');
    }
}catch(e){return;}
}

function fixLoop(){
   console.log('fixLoop is triggered');
   let 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();
    }