Last active
October 26, 2023 08:25
-
-
Save H3mul/54145fbfafe89a03c2ce24fdcb66a868 to your computer and use it in GitHub Desktop.
Fix youtube adblock popups
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 popup killer | |
// @namespace https://gist.github.com/H3mul/ | |
// @version 1.0 | |
// @updateURL https://gist.github.com/H3mul/54145fbfafe89a03c2ce24fdcb66a868/raw/youtube-adblock-popup-killer.js | |
// @downloadURL https://gist.github.com/H3mul/54145fbfafe89a03c2ce24fdcb66a868/raw/youtube-adblock-popup-killer.js | |
// @description Closes youtube popups complaining about adblocker and resumes playback | |
// @author h3mul | |
// @match https://*.youtube.com/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
const debug = true; | |
window.addEventListener("yt-navigate-finish", () => { | |
const popupContainer = document.querySelector("body > ytd-app > ytd-popup-container"); | |
const pauseButton = document.querySelector("#movie_player > div.ytp-chrome-bottom > div.ytp-chrome-controls > div.ytp-left-controls > button"); | |
const observer = new MutationObserver((mutations) => { | |
const popup = popupContainer.querySelector("tp-yt-paper-dialog") | |
if (popup) { | |
popupContainer.removeChild(popup) | |
pauseButton && pauseButton.getAttribute("data-title-no-tooltip") == "Play" && pauseButton.click(); | |
console.log("Caught and removed yt adblock popup") | |
} | |
}); | |
observer.observe(popupContainer, { childList: true, subtree: true }); | |
log("Starting to listen to DOM changes in popup container"); | |
}, true); | |
function log(message) { | |
if (debug) console.log(message); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment