Skip to content

A defensive security Chrome extension that protects users from intrusive advertising by blocking full-screen overlays, popup ads, and malicious redirects using advanced heuristic detection algorithms

Notifications You must be signed in to change notification settings

B143KC47/AdsBlock

Repository files navigation

AdBlock Shield - Chrome Extension

A powerful Chrome extension that blocks full-screen ad overlays and malicious redirect/popup ads using intelligent detection algorithms.

Features

  • Smart Overlay Blocking: Uses heuristic scoring to detect and remove full-screen ad overlays while preserving legitimate site modals
  • Popup Prevention: Blocks popup ads and popunders by intercepting window.open() calls
  • Redirect Protection: Prevents malicious redirects from ad networks and suspicious links
  • Whitelist Management: Easily add/remove sites from whitelist to support your favorite websites
  • Real-time Statistics: Track how many ads have been blocked (overlays, popups, redirects)
  • User-Friendly Interface: Clean popup UI with toggle controls and statistics display
  • Manifest V3 Compliant: Built with the latest Chrome extension standards

Installation

Generate Icons First

  1. Open icons/generate-icons.html in your browser
  2. Click "Generate Icons" button
  3. Right-click each generated icon and save as:
    • Small icon → icon16.png
    • Medium icon → icon48.png
    • Large icon → icon128.png
  4. Save all three files in the icons/ folder

Load Extension in Chrome

  1. Open Chrome and navigate to chrome://extensions/
  2. Enable "Developer mode" (toggle in top-right corner)
  3. Click "Load unpacked"
  4. Select the AdsBlock folder
  5. The extension should now appear in your extensions list!

Usage

Basic Usage

  1. Click the AdBlock Shield icon in your Chrome toolbar
  2. The extension is enabled by default and will automatically block ads
  3. View blocking statistics in the popup

Whitelist a Website

  1. Navigate to the website you want to whitelist
  2. Click the AdBlock Shield icon
  3. Click "Add to Whitelist"
  4. The page will reload and ads will no longer be blocked on that site

Disable Extension

  1. Click the AdBlock Shield icon
  2. Toggle the switch at the top to disable
  3. Toggle again to re-enable

Clear Statistics

  1. Click the AdBlock Shield icon
  2. Click "Clear Statistics" button at the bottom

How It Works

Overlay Detection (Moderate Approach)

The extension uses a scoring system to identify ad overlays:

  • Z-index check: High z-index values (>999) indicate overlays
  • Position check: position: fixed or absolute elements
  • Dimensions check: Full-screen or near-full-screen elements
  • Keyword detection: Ad-related class names/IDs
  • Ad network detection: Iframes from known ad networks

Elements scoring >60 points are classified as ad overlays and removed.

Link & Redirect Blocking

The extension blocks suspicious links based on:

  • External links with target="_blank" and suspicious patterns
  • Links to known ad networks (doubleclick.net, googlesyndication.com, etc.)
  • Links with tracking parameters (utm_, fbclid, gclid)
  • onclick handlers that call window.open()
  • Rapid-fire popup attempts (<500ms between clicks)

Performance Optimization

  • Uses MutationObserver for efficient DOM monitoring
  • Scans for new overlays only when relevant elements are added
  • Periodic fallback scans every 5 seconds
  • Event delegation for link click monitoring

Extension Structure

AdsBlock/
├── manifest.json          # Extension configuration (Manifest V3)
├── background.js          # Service worker for state management
├── content.js             # Main ad blocking logic
├── utils.js               # Shared utilities and detection algorithms
├── popup.html             # Popup interface
├── popup.css              # Popup styling
├── popup.js               # Popup logic
├── icons/                 # Extension icons
│   ├── icon16.png
│   ├── icon48.png
│   ├── icon128.png
│   ├── icon.svg           # Source SVG
│   └── generate-icons.html # Icon generator tool
└── README.md              # This file

Technical Details

Manifest V3 Features

  • Service worker background script
  • Content scripts with proper permissions
  • Chrome storage API for settings persistence
  • Message passing between scripts

Permissions

  • storage: Save settings and statistics
  • activeTab: Access current tab information
  • scripting: Inject content scripts
  • tabs: Manage tab state
  • <all_urls>: Run on all websites

Storage Schema

{
  enabled: true/false,
  whitelist: ['example.com', 'trusted-site.com'],
  stats: {
    overlaysBlocked: 0,
    popupsBlocked: 0,
    redirectsBlocked: 0
  }
}

Known Limitations

  • Cannot block ads on Chrome internal pages (chrome://, chrome-extension://)
  • Some sophisticated ad networks may bypass detection
  • Extremely fast redirects may not be caught in time
  • Cannot close popup windows opened by the browser itself

Troubleshooting

Extension not blocking ads

  1. Make sure the extension is enabled (check toggle in popup)
  2. Verify the site is not whitelisted
  3. Try refreshing the page after enabling the extension
  4. Check browser console for any errors

Legitimate modals being blocked

  1. Add the site to the whitelist
  2. The moderate detection approach should minimize false positives
  3. Report persistent issues by checking console logs

Statistics not updating

  1. Refresh the popup by closing and reopening it
  2. Statistics update every 2 seconds when popup is open
  3. Check if the extension is properly loaded in chrome://extensions/

Privacy

  • No data is collected or sent to external servers
  • All blocking happens locally in your browser
  • Settings are stored using Chrome's sync storage (synced across devices)
  • No tracking, no analytics, no external connections

Browser Compatibility

  • Chrome 88+ (Manifest V3 support required)
  • Chromium-based browsers (Edge, Brave, Opera) with Manifest V3 support

Version History

v1.0.0 (Initial Release)

  • Smart overlay detection and blocking
  • Popup and redirect prevention
  • Whitelist management
  • Statistics tracking
  • User-friendly popup interface

Support

For issues, feature requests, or contributions, please check the console logs for debugging information.

License

This extension is provided as-is for personal use.


Note: This extension is designed for defensive security purposes only. It blocks intrusive ads that harm user experience while respecting legitimate website functionality.

About

A defensive security Chrome extension that protects users from intrusive advertising by blocking full-screen overlays, popup ads, and malicious redirects using advanced heuristic detection algorithms

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published