Last active
February 1, 2026 14:36
-
-
Save insin/14ae1639d46ed2c86708836c8d79be8e to your computer and use it in GitHub Desktop.
"Experiencing interruptions?" fixer for YouTube userscript - click "Raw" to install in your userscript manager
This file contains hidden or 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 "Experiencing interruptions?" fixer for YouTube | |
| // @version 2 | |
| // @match https://www.youtube.com/* | |
| // @run-at document-start | |
| // ==/UserScript== | |
| function observe(target, callbackFn, options = {childList: true}) { | |
| return new Promise((resolve) => { | |
| function callback(mutations, observer) { | |
| let value = callbackFn(mutations, observer) | |
| if (value != null) { | |
| observer.disconnect() | |
| resolve(value) | |
| } | |
| } | |
| let observer = new MutationObserver(callback) | |
| observer.observe(target, options) | |
| callback([], observer) | |
| }) | |
| } | |
| void async function() { | |
| let popupContainer = await observe( | |
| document.body || document.documentElement, | |
| () => document.querySelector('ytd-popup-container'), | |
| {childList: true, subtree: true} | |
| ) | |
| let notificationRenderer = await observe( | |
| popupContainer, | |
| () => popupContainer.querySelector('yt-notification-action-renderer') | |
| ) | |
| let toast = await observe( | |
| notificationRenderer, | |
| () => notificationRenderer.querySelector('tp-yt-paper-toast') | |
| ) | |
| observe(toast, () => { | |
| if (toast.getAttribute('aria-hidden') == 'true') return | |
| let text = toast.querySelector('#text-container #text') | |
| let link = toast.querySelector('#action-button a[href^="https://support.google.com/youtube/answer/3037019"]') | |
| if (!(link && text)) return | |
| text.textContent = 'Successfully blocked pre-roll ads!' | |
| let linkText = link.querySelector('[role="text"]') | |
| if (linkText) linkText.textContent = 'Good job' | |
| }, { | |
| attributes: true, | |
| attributeFilter: ['aria-hidden'] , | |
| childList: true, | |
| }) | |
| }() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment