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-24 提交的版本,查看 最新版本

// ==UserScript==
// @name         Youtube Ad Cleaner(Include Non-Skippable Ads- works)
// @namespace    http://tampermonkey.net/
// @version      1.39.1
// @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(adCleaner ,500);
setInterval(killAd ,1);

function adCleaner()
{
    var ytplayer,adState;
    try{
           ytplayer = document.getElementById("movie_player");
           adState = ytplayer.getAdState();
           if (adState === 1) //adState(1):Ad is playing  adState(-1): Video is playing
           {
               console.log('skipped video ad');
               ytplayer.cancelPlayback();
               setTimeout(()=>{ytplayer.playVideo();},1);
               if (ytplayer.getPlayerState() === -1) //State(1):Video is playing   State(2):Video is Paused   State(-1):unknown
               {
                  ytplayer.stopVideo();
                  setTimeout(()=>{ytplayer.playVideo();},1);
               }
            }
        }
     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"],
    "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();})}
}

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址