Greasy Fork is available in English.
(Chrome ONLY) Bypass all youtube ads including in video ads, skippable and non-skippable Ads
当前为
// ==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();})}
}