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
// @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 ,1000);
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()
{
removeByID();
removeByClassName();
removeByTagName();
killInVideoAd();
}
function removeByID()
{
var aId = ["masthead-ad","player-ads","top-container","offer-module","pyv-watch-related-dest-url","ytd-promoted-video-renderer"];
for (var i in aId)
{
var AdId = document.getElementById(aId[i]);
if (AdId)
{
AdId.remove();
}
}
}
function removeByClassName()
{
var aClass = ["style-scope ytd-search-pyv-renderer"];
for (var i in aClass)
{
var AdClass = document.getElementsByClassName(aClass[i]);
if (AdClass[0])
{
AdClass[0].remove();
}
}
}
function removeByTagName()
{
var aTag = ["ytd-promoted-sparkles-text-search-renderer"];
for (var i in aTag)
{
var AdTag = document.getElementsByTagName(aTag[i]);
if (AdTag[0])
{
AdTag[0].remove();
}
}
}
function killInVideoAd()
{
var overlayAd = document.getElementsByClassName("video-ads")[0];
try{
if (overlayAd)
{
overlayAd.remove();
console.log('Overlay ads - removed');
}
}
catch(e)
{
return;
}
}