Skip to content

Instantly share code, notes, and snippets.

@Hazem-Gamall
Created October 20, 2023 11:05
Show Gist options
  • Save Hazem-Gamall/945ead96d9e06498f413381bc048b360 to your computer and use it in GitHub Desktop.
Save Hazem-Gamall/945ead96d9e06498f413381bc048b360 to your computer and use it in GitHub Desktop.
A Tampermonkey script to skip ads on YouTube since they are blocking ad-blockers and i hate ads
// ==UserScript==
// @name Youtube ad skipper
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://www.youtube.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Your code here...
const f =() => {
const btn = document.querySelector('.ytp-ad-skip-button');
const adText = document.querySelector('.ytp-ad-text');
const v = document.querySelector('video');
if(adText){
v.currentTime = v.duration
}
if(btn){
v.currentTime = v.duration
btn.click();
}
}
setInterval(f, 100);
})();
@shmudivel
Copy link

🙌🫶

@ShaonPro
Copy link

Not Working - Need to Update

@ShaonPro
Copy link

Updated Version

const f =() => { const btn = document.querySelector('.ytp-skip-ad-button'); const adText = document.querySelector('.ytp-skip-ad-button__text'); const v = document.querySelector('video'); if(adText){ v.currentTime = v.duration } if(btn){ v.currentTime = v.duration btn.click(); } } setInterval(f, 100); })();

@Hazem-Gamall
Copy link
Author

Sorry i no longer use or maintain it since i just use uBlock origin now which does a great job blocking youtube ads and ads in general.

@Mohamed7422
Copy link

It ain't work

@ShaonPro
Copy link

ShaonPro commented Nov 6, 2024

@Mohamed7422
Show your codes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment