Skip to content

A Chrome Extension that blocks, skips, and removes advertisements on YouTube and across all websites automatically.

Notifications You must be signed in to change notification settings

swapmali/AdZero

Repository files navigation

AdZero

A production-quality Chrome Extension (Manifest V3) that blocks, skips, and removes advertisements on YouTube and across all websites automatically.

Features

YouTube Ad Blocking

  • Automatically detects and skips video ads (clicks "Skip Ad" button)
  • Fast-forwards unskippable ads to completion
  • Mutes audio during ad playback, restores it after
  • Removes overlay ads on the video player
  • Removes banner ads below videos
  • Removes sidebar sponsored content
  • Removes homepage promoted content
  • Handles YouTube SPA navigation without requiring page refresh

Global Ad Blocking (All Websites)

  • CSS-based instant hiding of known ad containers (AdSense, GPT, Outbrain, Taboola, MGID, sticky ads)
  • DOM cleaning via MutationObserver to catch dynamically loaded ads
  • Network-level blocking of 300+ ad/tracking domains using Chrome's declarativeNetRequest API (zero JS overhead)
  • Covers Google Ads, Amazon Ads, Criteo, Rubicon, PubMatic, OpenX, Media.net, and hundreds more

Popup UI

  • Independent on/off toggles for YouTube and Global blocking
  • Live counters for YouTube ads blocked and web ads blocked
  • Clean dark-themed interface
  • Reset button to clear counters

Installation

  1. Clone or download this repository
  2. Open chrome://extensions in Chrome
  3. Enable Developer Mode (top-right toggle)
  4. Click Load unpacked
  5. Select the AdZero folder

The extension activates immediately on all websites.

Project Structure

AdZero/
├── manifest.json              # Manifest V3 configuration
├── background.js              # Service worker: state, badge, network rules
├── content.js                 # YouTube ad blocking entry point
├── contentGeneric.js          # Global ad blocking entry point
├── modules/
│   ├── utils.js               # Shared helpers, logging, DOM utilities
│   ├── adDetector.js          # YouTube ad detection selectors & logic
│   ├── adSkipper.js           # Skip, fast-forward, mute/unmute logic
│   ├── domCleaner.js          # YouTube DOM ad removal
│   ├── observer.js            # YouTube MutationObserver
│   ├── genericDetector.js     # Generic ad detection (AdSense, GPT, iframes)
│   └── genericCleaner.js      # Generic DOM ad removal
├── css/
│   ├── ads.css                # YouTube ad hiding rules
│   └── genericAds.css         # Global ad hiding rules
├── popup/
│   ├── popup.html             # Popup UI markup
│   ├── popup.js               # Popup logic (toggles, stats, reset)
│   └── popup.css              # Popup dark theme styles
├── rules/
│   └── ad-rules.json          # 300 declarativeNetRequest blocking rules
└── icons/
    ├── icon16.png
    ├── icon48.png
    └── icon128.png

Architecture

AdZero runs two independent blocking pipelines:

YouTube Pipeline (runs on youtube.com only)

  • adDetector.js identifies ad states (.ad-showing, skip buttons, overlay containers)
  • adSkipper.js clicks skip, fast-forwards, and manages mute/unmute
  • domCleaner.js hides banner, sidebar, and homepage ads
  • observer.js watches the player and page via MutationObserver

Global Pipeline (runs on all websites, including YouTube as an extra layer)

  • genericDetector.js finds AdSense, GPT slots, ad iframes, native widgets, and sticky overlays
  • genericCleaner.js hides detected elements and reports counts
  • contentGeneric.js manages the observer and lifecycle
  • ad-rules.json blocks 300 ad domains at the network level via declarativeNetRequest

On YouTube, both pipelines run simultaneously for maximum coverage.

Permissions

Permission Reason
activeTab Access the current tab for content script injection
scripting Programmatic script injection support
storage Persist toggle state and blocked-ad counters
declarativeNetRequest Block network requests to ad-serving domains
<all_urls> (host) Run content scripts and network rules on all websites

Tech Stack

  • JavaScript (ES6+)
  • Chrome Extension Manifest V3
  • No external libraries or dependencies
  • Fully local execution (no external servers)

Performance

  • MutationObserver-based detection (no polling)
  • Throttled callbacks (200ms YouTube, 500ms global) to prevent redundant work
  • CSS rules provide instant visual hiding before JavaScript runs
  • Network rules execute in Chrome's network stack with zero JS overhead
  • Processed elements are marked with data-adzero-hidden to avoid reprocessing

License

MIT

About

A Chrome Extension that blocks, skips, and removes advertisements on YouTube and across all websites automatically.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published