Skip to content

Instantly share code, notes, and snippets.

@phaticusthiccy
Created August 28, 2023 21:11
Show Gist options
  • Save phaticusthiccy/d12e65f50acec5c911ba63f0c5962ec6 to your computer and use it in GitHub Desktop.
Save phaticusthiccy/d12e65f50acec5c911ba63f0c5962ec6 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name No ADS - YouTube
// @namespace http://tampermonkey.net/
// @version 1.5
// @description - Skips all youtube ads - | - undetectable - | - skips ads instantly -
// @author GSRHackZ
// @match https://www.youtube.com/*
// @match https://m.youtube.com/*
// @icon https://i.ibb.co/X5f50Cg/Screen-Shot-2021-07-19-at-9-31-54-PM.png
// @grant none
// ==/UserScript==
let ogVolume=1;
let pbRate = 1;
// og copy of No ADS - YouTube
setInterval(function(){
if(document.getElementsByClassName("video-stream html5-main-video")[0]!==undefined){
let ad = document.getElementsByClassName("video-ads ytp-ad-module")[0];
let vid = document.getElementsByClassName("video-stream html5-main-video")[0];
if(ad==undefined){
pbRate = vid.playbackRate;
}
let closeAble = document.getElementsByClassName("ytp-ad-overlay-close-button");
for(let i=0;i<closeAble.length;i++){
closeAble[i].click();
//console.log("ad banner closed!")
}
if(document.getElementsByClassName("style-scope ytd-watch-next-secondary-results-renderer sparkles-light-cta GoogleActiveViewElement")[0]!==undefined){
let sideAd=document.getElementsByClassName("style-scope ytd-watch-next-secondary-results-renderer sparkles-light-cta GoogleActiveViewElement")[0];
sideAd.style.display="none";
//console.log("side ad removed!")
}
if(document.getElementsByClassName("style-scope ytd-item-section-renderer sparkles-light-cta")[0]!==undefined){
let sideAd_ = document.getElementsByClassName("style-scope ytd-item-section-renderer sparkles-light-cta")[0];
sideAd_.style.display="none";
//console.log("side ad removed!")
}
if(document.getElementsByClassName("ytp-ad-text ytp-ad-skip-button-text")[0]!==undefined){
let skipBtn=document.getElementsByClassName("ytp-ad-text ytp-ad-skip-button-text")[0];
skipBtn.click();
//console.log("skippable ad skipped!")
}
if(document.getElementsByClassName("ytp-ad-message-container")[0]!==undefined){
let incomingAd=document.getElementsByClassName("ytp-ad-message-container")[0];
incomingAd.style.display="none";
//console.log("removed incoming ad alert!")
}
if(document.getElementsByClassName("style-scope ytd-companion-slot-renderer")[0]!==undefined){
document.getElementsByClassName("style-scope ytd-companion-slot-renderer")[0].remove();
//console.log("side ad removed!")
}
if(ad!==undefined){
if(ad.children.length>0){
if(document.getElementsByClassName("ytp-ad-text ytp-ad-preview-text")[0]!==undefined){
vid.playbackRate=16;
//console.log("Incrementally skipped unskippable ad!")
}
}
}
}
},100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment