Last active
September 14, 2024 23:38
-
-
Save nathan130200/3d9e05bea724f9e67f1e584edc85ca29 to your computer and use it in GitHub Desktop.
Automatic skip-ad and hide ad elements in youtube without use AD-Block, this script don't remove AD-Elements, just hide from page.
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 YoutubeSkipAd | |
// @version 1.6.3 | |
// @description Automatic skip-ad and hide in youtube. | |
// @author FRNathan13 | |
// @include /(http|https):\/\/www.youtube.com\/(.*) | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
setInterval(function() { | |
var overlay_close_button = document.querySelector('.ytp-ad-overlay-close-button'); | |
if(overlay_close_button != undefined){ | |
overlay_close_button.click(); | |
console.log("[YOUTUBE-AD] Element '.ytp-ad-overlay-close-button' hidden."); | |
} | |
var ad_skip_button = document.querySelector('.ytp-ad-skip-button.ytp-button'); | |
if(ad_skip_button != undefined) { | |
ad_skip_button.click(); | |
console.info("[YOUTUBE-AD] Ad button '.ytp-ad-skip-button.ytp-button' clicked."); | |
} | |
var google_companion_ad_div = document.querySelector('#google_companion_ad_div') | |
if(google_companion_ad_div != undefined && google_companion_ad_div.style.display != 'none') { | |
google_companion_ad_div.style.display = 'none'; | |
console.info("[YOUTUBE-AD] Element '#google_companion_ad_div' hidden."); | |
} | |
var container_iframe = document.querySelector("#container > iframe"); | |
if(container_iframe != undefined && container_iframe.style.display != 'none') { | |
container_iframe.style.display = 'none'; | |
console.info("[YOUTUBE-AD] Container Element '#container > iframe' hidden."); | |
} | |
document.querySelectorAll('.style-scope.ytd-action-companion-ad-renderer') | |
.forEach(e => { e.style.display = 'none' }); | |
var player_ads = document.querySelector('#player-ads'); | |
if(player_ads != undefined && player_ads.style.display != 'none') { | |
player_ads.style.display = 'none'; | |
console.info("[YOUTUBE-AD] Element '#player-ads' hidden."); | |
} | |
var ad_skip_text = document.querySelector('.ytp-ad-text.ytp-ad-skip-button-text'); | |
if(ad_skip_text != undefined){ | |
ad_skip_text.click(); | |
console.log("[YOUTUBE-AD] Ad button '.ad_skip_text' clicked."); | |
} | |
}, 0.25); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment