Portfolio / JavaScript lane / YoutubeAdblock
EXT

YoutubeAdblock

Undetectable YouTube ad blocker

JavaScriptExtension
Delivery
Source-first
Browse code, README, and release notes on GitHub.
Primary lane
JavaScript lane
The clearest adjacent context for this project inside the portfolio.
Freshness
Updated Apr 26, 2026
Latest release
v0.4.0
Published Apr 22, 2026

Preview

Using the generated project card as a clean fallback until a live capture is available.

YoutubeAdblock card

Source at github.com/SysAdminDoc/YoutubeAdblock.

README

Cached at build time, cleaned up for in-site reading, and linked back to the canonical GitHub source.

Youtube Adblock

Version License Platform

YoutubeAdblock

A document-start YouTube ad blocker with a split-context proxy engine, remote rule support, and a premium Control Center for tuning protection.

Quick Start

Userscript (Tampermonkey / Violentmonkey)

  1. Install Tampermonkey or Violentmonkey
  2. Click here to install YoutubeAdblock
  3. Confirm installation when prompted, then reload YouTube
  4. Open your userscript menu and use the built-in commands to open the Control Center, pause or resume protection, or refresh rules on demand

Chrome / Edge / Brave (Chromium 121+, MV3 extension, unpacked)

  1. Clone or download the repo, then run powershell -ExecutionPolicy Bypass -File .\Build-Extension.ps1 to regenerate extension/main.js from the userscript
  2. Visit chrome://extensions, enable Developer mode, and click Load unpacked
  3. Select the extension/ folder
  4. Click the YoutubeAdblock toolbar button (or press Ctrl+Shift+Y) to open the Control Center

Because the MV3 manifest intentionally includes both background.service_worker and background.scripts for Chrome + Firefox compatibility, the unpacked extension target is Chromium 121 or newer.

If you need a packaged Chromium artifact for release distribution, run powershell -ExecutionPolicy Bypass -File .\Build-CRX.ps1. It writes a signed .crx plus a reusable private key into dist/, so future CRX builds keep the same extension ID. Keep in mind that Chrome generally does not allow normal local-file .crx installs outside developer-mode, Linux self-hosting, or managed-policy flows, so the unpacked install path remains the best default for most users.

Firefox (MV3 extension, temporary install)

  1. Build the extension as above
  2. Visit about:debugging#/runtime/this-firefox
  3. Click Load Temporary Add-on and pick extension/manifest.json
  4. Click the YoutubeAdblock toolbar button to open the Control Center

The extension ships the same blocking engine as the userscript plus declarativeNetRequest rules that block ad-serving endpoints (/pagead/, /api/stats/ads, /youtubei/v1/player/ad_break, googlevideo ctier=SA segments, doubleclick.net and googlesyndication.com from YouTube origins) at the browser network layer — outside the reach of any page-level anti-adblock countermeasure. If you trigger the extension while you are not already on YouTube, YoutubeAdblock opens a YouTube tab and carries the action forward there automatically.

Highlights

  • Blocks ads before they render by pruning payloads in JSON.parse, fetch(), and XMLHttpRequest
  • Handles anti-detection paths like abnormality callbacks, clean iframe bypasses, and playback timers
  • Keeps cosmetic cleanup separate from payload blocking so the interface stays tidy after the heavy lifting is done
  • Ships with a local fallback rule set, cached remote rules, and a diagnostics-friendly Control Center

Features

Feature Description Default
JSON.parse Proxy Strips ad payloads from YouTube API responses at the data level Enabled
Fetch Proxy Intercepts /youtubei/v1/player, /browse, /search, /next and prunes ad fields Enabled
XHR Proxy Catches XMLHttpRequest-based ad delivery channels Enabled
appendChild Proxy Blocks ad-related script and iframe injection into the DOM Enabled
setTimeout Proxy Neutralizes timed ad triggers and delayed ad insertion Enabled
Promise.then Proxy Intercepts promise-chained ad delivery pipelines Enabled
Property Traps Prevents YouTube from reading/writing ad-related player properties Enabled
CSS Cosmetic Filters 150+ selectors hiding ad containers, banners, and promotions Enabled
SSAP Auto-Skip Automatically clicks the skip button on skippable video ads Enabled
Anti-Detect Bypass Defeats YouTube's abnormality/adblock detection system Enabled
Iframe Fetch-Lift Defense Rebridges contentWindow.fetch, XMLHttpRequest, and JSON.parse in same-origin iframes so YouTube can't lift pristine globals Enabled
Aggressive Anti-Stall Fast-forwards 17-second bound timers YouTube uses to stall playback when a blocker is suspected Enabled
Video Ad Fast-Forward Mutes and accelerates any ad that slips past pruning (last-resort safety net) Enabled
SponsorBlock Auto-Skip Silently skips sponsor, self-promo, intro, outro, interaction, preview, music-off-topic, and filler segments using the privacy-preserving SponsorBlock hash-prefix API Enabled
toString Proxy Mask Patches Function.prototype.toString so every hooked native still reports [native code] to YouTube's detection paths Enabled
ServiceWorker Block Proxies navigator.serviceWorker.register / getRegistration{s} so YouTube can't install a worker that bypasses the request proxies Enabled
Webpack Chunk Prune Rewrites ad-rendering factory modules inside self.webpackChunk_youtube_player.push before they execute Enabled
DeArrow Titles & Thumbnails Replaces clickbait titles and thumbnails with crowd-submitted alternatives via the privacy-preserving DeArrow hash-prefix API Optional
Return YouTube Dislike Restores the public dislike count under the like button Optional
Volume Boost Web Audio gain stage up to 5x with an inline slider in the player controls Optional
Clutter-Free Mode Eight Unhook-style toggles: home feed, Shorts shelves, Shorts tab, related videos, comments, end-screen cards, live chat, merch shelves Optional
Channel + Keyword Blocklist Strips videos whose channel or title matches a local blocklist from every intercepted feed payload Optional
Shorts → /watch Redirect Rewrites /shorts/VIDEO_ID to the full watch player Optional
DNR Network Blocking (extension only) Blocks /pagead/*, /pagead/adview, /pagead/interaction, /api/stats/ads, /api/stats/atr, /pcs/activeview, /youtubei/v1/player/ad_break, /youtubei/v1/log_event (POST), /youtubei/v1/att/log (POST), googlevideo ctier=SA, ctier=SR, initplayback?...adformat=, generate_204, doubleclick.net, googlesyndication.com, googleadservices.com Enabled
Remote Filter List Fetches and applies uBO-compatible filter lists from a configurable URL Enabled
Control Center Protection overview, quick actions, module toggles, rule refresh, blocklist editors, diagnostics, and recovery tools Enabled
Live Stats Real-time counters for blocked, pruned, SSAP skipped, sponsor skipped, DeArrow replaced, and feed filtered Enabled
TrustedHTML Safe Full CSP/TrustedTypes compliance — no innerHTML violations Always

How It Works

┌──────────────────────────────────────────────────────────────────────┐
│                        document-start                                │
│                                                                      │
│  ┌─────────────────────┐    ┌──────────────────────────────────┐    │
│  │  PHASE 1: Page Ctx  │    │  PHASE 2: Sandbox                │    │
│  │  (injected <script>)│    │  (Tampermonkey GM_* APIs)        │    │
│  │                     │    │                                  │    │
│  │  • JSON.parse proxy │    │  • 150+ CSS cosmetic selectors   │    │
│  │  • fetch() proxy    │    │  • DOM MutationObserver cleanup  │    │
│  │  • XHR proxy        │    │  • SSAP auto-skip delegation     │    │
│  │  • appendChild proxy│    │  • GM_getValue/setValue storage   │    │
│  │  • setTimeout proxy │    │  • Remote filter list fetching   │    │
│  │  • Promise.then     │    │  • CSS re-injection protection   │    │
│  │  • Property traps   │    │  • Control Center UI             │    │
│  │  • Video ad skipper │    │                                  │    │
│  └─────────────────────┘    └──────────────────────────────────┘    │
│              │                            │                          │
│              ▼                            ▼                          │
│     Real window object            Shared DOM access                  │
│     (YouTube sees proxies)        (CSS/elements work from sandbox)   │
└──────────────────────────────────────────────────────────────────────┘

Tampermonkey's @grant GM_* directives wrap userscripts in a sandbox where window is a proxy — YouTube's scripts never see modifications made in the sandbox. YoutubeAdblock solves this by injecting the proxy engine into the real page context via a <script> element at document-start, before any YouTube scripts execute. CSS injection, DOM observers, and settings management stay in the sandbox since they operate on the shared DOM.

Each proxy installation is individually try/catch wrapped using a safeOverride() helper (direct assign → Object.defineProperty → delete+redefine fallback), so one engine failure never prevents the others from loading.

Configuration

All settings persist via GM_setValue. Open the userscript menu and choose YoutubeAdblock: Open Control Center to adjust protection without leaving YouTube.

Control Center

Setting Description Default
Protection Overview Live status, active source, current YouTube surface, quick actions, and jump navigation Available
Master Switch Enable or pause every blocking engine without uninstalling the script On
Rule Library Choose a compatible raw list and refresh it on demand; the recommended source is the safest default for extension installs youtube-adblock-filters.txt
Core Blocking Control JSON pruning, fetch/XHR interception, property traps, and request rewriting On
Anti-Detection Control abnormality bypass, iframe bypass prevention, SSAP skipping, spoofing, and timer neutralization On
Interface Cleanup Control cosmetic cleanup, Premium upsell blocking, and Shorts ad removal On
Diagnostics & Recovery Copy diagnostics, reset local counters, or restore recommended defaults safely Available

Filter List

The default remote filter list is hosted in this repo at `youtube-adblock-filters.txt`. It uses uBO-compatible filter syntax and is parsed on fetch. The userscript build can point the Rule Library field at any compatible raw list URL; the extension build works best with sources that allow direct browser fetches from YouTube pages, so the recommended GitHub-hosted source is the safest default there. If a refresh fails, YoutubeAdblock keeps the last working rules or the built-in fallback active so protection does not drop unexpectedly.

Pruned API Fields

The proxy engine strips these fields from YouTube API responses before they reach the player:

adPlacements · adSlots · playerAds · adBreakHeartbeatParams · auxiliaryUi.messageRenderers.upsellDialogRenderer · responseContext.adSignalsInfo · frameworkUpdates

Intercepted Endpoints

/youtubei/v1/player · /youtubei/v1/get_watch · /youtubei/v1/browse · /youtubei/v1/search · /youtubei/v1/next · /youtubei/v1/guide · /watch?

Supported Sites

Site URL
YouTube https://www.youtube.com/*
YouTube Mobile https://m.youtube.com/*
YouTube Music https://music.youtube.com/*
YouTube TV https://tv.youtube.com/*
YouTube No-Cookie https://www.youtube-nocookie.com/*
YouTube Kids https://youtubekids.com/*, https://www.youtubekids.com/*

FAQ / Troubleshooting

Ads still showing after install? Make sure no other YouTube ad-blocker userscripts are running simultaneously — they can conflict with the proxy engine. Disable competing scripts and reload.

YouTube detects my ad blocker? Ensure the Anti-Detect setting is enabled. If YouTube recently changed their detection, check for a script update or open an issue.

Works on Firefox? Yes, with Violentmonkey or Tampermonkey. All features are cross-browser.

How do I use a different filter list? Point the Rule Library field at a compatible raw list that includes the selectors you want, then refresh the rules from the Control Center.

How do I reset settings? Open the Control Center and use Restore Defaults. That resets the master switch and feature toggles to the recommended starting state without requiring DevTools.

Contributing

Issues and PRs welcome. When reporting bugs, include:

  • Browser and version
  • Userscript manager and version
  • Console errors (F12 → Console, filter by YoutubeAdblock)
  • Which settings are enabled

License

MIT — Matthew Parker

Read on GitHub → github.com/SysAdminDoc/YoutubeAdblock

Recent Releases

Latest tagged notes pulled from GitHub release history for this project.

  • v0.4.0

    Major capability release. Three pillars: · - **`Function.prototype.toString` mask** — every hooked native (`JSON.parse`, `fetch`, XHR, `appendChild`/`insertBefore`/`replaceChild`, `Promise.then`, `setTimeout`, `serviceWo

  • v0.3.3

    **Full Changelog**: https://github.com/SysAdminDoc/YoutubeAdblock/compare/v0.3.2...v0.3.3

  • v0.3.2

    **Full Changelog**: https://github.com/SysAdminDoc/YoutubeAdblock/compare/v0.3.1...v0.3.2

  • v0.3.1

    **Full Changelog**: https://github.com/SysAdminDoc/YoutubeAdblock/compare/v0.0.3...v0.3.1