Last active
October 19, 2022 20:57
-
-
Save keesiemeijer/b12191e2ea55eb60df867d56a7ae0578 to your computer and use it in GitHub Desktop.
Youtube skip ads and remove overlay ads after 3 seconds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Youtube SkipAd | |
// @namespace keesiemeijer | |
// @version 0.1 | |
// @description Automatically skips ads after 5 seconds | |
// @author keesiemeijer | |
// @match https://www.youtube.com/* | |
// @grant none | |
// ==/UserScript== | |
function addGlobalStyle(css) { | |
var head, style; | |
head = document.getElementsByTagName('head')[0]; | |
if (!head) { return; } | |
style = document.createElement('style'); | |
style.type = 'text/css'; | |
style.innerHTML = css; | |
head.appendChild(style); | |
} | |
addGlobalStyle('.ytp-ad-overlay-slot { display: none !important; }'); | |
addGlobalStyle('.ytp-ad-image-overlay { display: none !important; }'); | |
addGlobalStyle('.ytp-ad-overlay-image { display: none !important; }'); | |
addGlobalStyle('.ytp-ad-overlay-container { display: none !important; }'); | |
window.setInterval( | |
function () { | |
var elmButton = document.querySelector('.ytp-ad-skip-button'); | |
if (elmButton) { | |
elmButton.click(); | |
} | |
}, | |
3000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment