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

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

اعتبارا من 09-08-2019. شاهد أحدث إصدار.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name         Youtube Ad Cleaner(Include Non-Skippable Ads- works)
// @namespace    http://tampermonkey.net/
// @version      1.34
// @description  (Chrome ONLY) Bypass all youtube ads including in video ads, skippable and non-skippable Ads
// @author       BjDanny
// @match        *://*.youtube.com/*
// ==/UserScript==
setInterval(killAd,1000);
var home;
var myWin;
var timer1;
var to1;
var to2;
var timer3;
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');
    clearInterval(timer1);
    clearTimeout(to1);
    clearInterval(timer3);
    console.log('At home =', home);
    window.location.href = 'https://www.youtube.com';
}

function checkHome() {
if(window.location.href !=='https://www.youtube.com/'){
    home = false;
    console.log('At home =', home);
    timer1 = setInterval(KillNoSkipAd,1000);
    to1 = setTimeout(cfmReload,2000);
    to2 = setTimeout(fastHomeListener, 1000);
    timer3 = setInterval(killInVideoAd,1000);
    }
    else{
    home = true;
    }
}

function killAd(){

           if(document.getElementById("masthead-ad") !==null){
            document.getElementById("masthead-ad").remove();}
           if(document.getElementById("player-ads") !==null){
            document.getElementById("player-ads").remove();}
           if(document.getElementById("offer-module")!==null){
            document.getElementById("offer-module").remove();}
           if(document.getElementById("pyv-watch-related-dest-url")!==null){
            document.getElementById("pyv-watch-related-dest-url").remove();}
           if(document.getElementById('ytd-promoted-video-renderer')!==null){
            document.getElementById('ytd-promoted-video-renderer').remove();}
          if (document.getElementsByClassName("videoAdUiRedesign")[0] !==undefined){
                    document.getElementsByClassName("video-stream").attr("src", "");
}}

function KillNoSkipAd(){
    var ytplayer = document.getElementById("movie_player");
    var VdoTime;
    try{
        VdoTime = ytplayer.getCurrentTime();
  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(), 1);
             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;}
}

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();
    }