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

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

27.09.2020 itibariyledir. En son verisyonu görün.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği yüklemek için Tampermonkey gibi bir uzantı yüklemeniz gerekir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

Bu stili yüklemek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için Stylus gibi bir uzantı kurmanız gerekir.

Bu stili yükleyebilmek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı kurmanız gerekir.

Bu stili yükleyebilmek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         Youtube Ad Cleaner(Include Non-Skippable Ads- works)
// @namespace    http://tampermonkey.net/
// @version      1.39.6
// @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(adMonitor ,500);
setInterval(removeSp,2000);
setInterval(killAd ,1);
setInterval(()=>{counter = 0; console.log("Counter is reset by timer");} ,60000);
window.addEventListener("click", ()=>{setTimeout(()=>{counter = 0; console.log("Counter is reset by mouse click");},2000);});
var counter = 0;
var fixLoopInvoked = false;

function adMonitor()
{
    if (fixLoopInvoked){fixLoopInvoked=false;}
    try
    {
      let ytplayer = document.getElementById("movie_player");
      let adState = ytplayer.getAdState();
      if (adState === 1)
      {
          counter +=1;
          Ads.cancelVdoAd();
          if (ytplayer.getPlayerState() === -1) Ads.stopVdoAd();
          console.log("Current counter is:" + counter);
          if (counter >=2) {counter=0;console.log("Invoked fixLoop");fixLoopInvoked = true;Ads.fixLoop();}; //remove stubbon video ad
      }
    }
    catch(e)
    {
        return;
    }
}


function removeSp()
{
    try
    {
        if (document.getElementById("support").innerText.includes("Ad"))
        {
               let sp = document.getElementsByClassName("style-scope ytd-rich-grid-renderer");

                if(sp)
                {
                    sp[5].remove();
                }
            }
        }
   catch(e)
    {
        return;
    }

 }

function killAd()
{
    Ads.removeByID();
    Ads.removeByClassName();
    Ads.removeByTagName();

}

var Ads = {
    "aId":["masthead-ad","player-ads","top-container","offer-module","pyv-watch-related-dest-url","ytd-promoted-video-renderer"],
    "aClass":["style-scope ytd-search-pyv-renderer","video-ads","ytd-compact-promoted-video-renderer","style-scope ytd-carousel-ad-renderer"],
    "aTag":["ytd-promoted-sparkles-text-search-renderer"],
    "removeByID":function(){this.aId.forEach(i=>{ var AdId = document.getElementById(i);if(AdId) AdId.remove();})},
    "removeByClassName":function(){this.aClass.forEach(c=>{ var AdClass = document.getElementsByClassName(c);if(AdClass[0]) AdClass[0].remove();})},
    "removeByTagName":function(){this.aTag.forEach(t=>{ var AdTag = document.getElementsByTagName(t);if(AdTag[0]) AdTag[0].remove();})},
    "cancelVdoAd":function(){ console.log('cancelled video ad'); document.getElementById("movie_player").cancelPlayback();setTimeout(()=>{document.getElementById("movie_player").playVideo();},1);},
    "stopVdoAd":function(){ console.log('stopped video ad'); document.getElementById("movie_player").stopVideo();setTimeout(()=>{document.getElementById("movie_player").playVideo();},1);},
    "fixLoop":function(){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();}
}