Block YouTube ads by stripping ad config before the player reads it. No delays, fully reactive.
Blocks all YouTube ads by intercepting ad configuration before the player processes it. No visual flicker, no empty boxes.
Six-layer defense running at document-start:
| Layer | What it does |
|---|---|
| Property trap | Intercepts ytInitialPlayerResponse and ytInitialData before the player reads them |
| JSON.parse override | Catches ad data in inline JSON and data: URLs |
| Response.json override | Strips ads from SPA navigation API responses |
| fetch/XHR interception | Blocks ad video stream requests |
| CSS hiding | Hides any ad UI elements that slip through |
| MutationObserver | Removes enforcement popups and empty ad containers from the DOM |
Edit the CONFIG object at the top of the script:
const CONFIG = {
blockShorts: true, // Hide Shorts from homepage/subscriptions feed
};
@run-at document-start support