Silent ad blocker that stays invisible to detection scripts.
Blocks ads at the network & DOM level β without being detected as an adblocker.
| Feature | Description |
|---|---|
| π Network-Level Blocking | Uses Declarative Net Request (DNR) to block 50+ ad networks at the network layer |
| π§Ή DOM Cleanup | Removes ad containers, iframes, and banners from the page |
| π‘οΈ Stealth Mode | Patches detection APIs β sites can't tell you're using an adblocker |
| π Fake Ad APIs | Provides dummy googletag, adsbygoogle so anti-adblock scripts pass |
| π Block Stats | Track how many ads blocked today and total (with batching) |
| β‘ Lightweight | Zero external dependencies, pure vanilla JavaScript |
| π Silent Operation | No notifications, no popups β just blocks silently |
| π― Site-Specific Bypasses | Custom anti-detection for YouTube, Facebook, and more |
GhostBlock is specifically designed to bypass common adblocker detection methods:
| Technique | How It Works |
|---|---|
Fake googletag API |
Provides a complete dummy window.googletag object so detector scripts don't flag the page |
Fake adsbygoogle array |
Sites checking for window.adsbygoogle will find it exists as expected |
Patched MutationObserver |
Filters out mutations caused by our ad removal β detector observers won't see anything suspicious |
| Delayed DOM Removal | Ad elements are removed after 100ms instead of instantly, avoiding race-condition detectors |
| Stealth CSS injection | Ad containers are hidden at document_start β no flash of ad content |
| XHR/fetch interception | Ad requests are blocked in the page context, not via detectable extension APIs |
Patched getComputedStyle |
Prevents detectors from spotting hidden ad elements via style inspection |
| Type-safe URL checking | Handles Request, URL, Blob, and string inputs without crashing |
-
Clone this repository:
git clone https://github.com/Irnhakim/ghost-block.git
-
Open Chrome and navigate to:
chrome://extensions/ -
Enable Developer mode (top-right toggle)
-
Click Load unpacked and select the
ghost-block/folder -
π Done! GhostBlock is now active (π» icon in toolbar)
Coming soon
| Action | How |
|---|---|
| Toggle on/off | Click the π» icon β toggle the switch |
| View stats | See blocked ads today & total in the popup |
| Default mode | Protection is ON by default after installation |
ghost-block/
βββ manifest.json # Manifest V3 configuration
βββ background.js # Service worker β DNR rules & messaging
βββ content.js # MAIN world β DOM cleanup + network intercept + site bypasses
βββ bridge.js # ISOLATED world β cross-context communication (MAIN β background)
βββ popup.html # Extension popup UI
βββ popup.js # Popup logic
β
βββ css/
β βββ stealth.css # Pre-render ad hiding (100+ selectors)
β
βββ lib/
β βββ filter-rules.js # Blocklists: hosts, selectors, keywords
β βββ dnr-rules.json # Declarative Net Request static rules (40+ rules)
β βββ inject-stealth.js # Stealth API patches (googletag, MutationObserver, K3)
β
βββ icons/
βββ icon16.png
βββ icon48.png
βββ icon128.png
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β BROWSER LAYER β
β ββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β DNR Static Rules (dnr-rules.json) β β
β β β Blocks 50+ known ad domains β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββ€ β
β β Dynamic Rules (background.js) β β
β β β User-added custom domains β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β PAGE LAYER (MAIN world) β
β ββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Stealth CSS (stealth.css) β β
β β β Hides ad containers before render β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββ€ β
β β DOM Cleanup (content.js) β β
β β β Removes ad nodes, iframes, banners β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββ€ β
β β Network Intercept (content.js) β β
β β β Patches fetch/XHR to block ad URLs β β
β β β YouTube exempt (stealth strategy) β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββ€ β
β β API Spoofing (inject-stealth.js) β β
β β β Fakes googletag, adsbygoogle, K3, etc. β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββ€ β
β β Site-Specific Bypasses (content.js) β β
β β β YouTube, Facebook, online-fix, otakudesu β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β BRIDGE (ISOLATED world) β
β ββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β cross-context messaging (postMessage) β β
β β β MAIN world β bridge.js β background.js β β
β β β Batched AD_BLOCKED messages (200ms) β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
content.js (MAIN world)
β markAndRemove() every 5 ad removals
β window.postMessage("__GB_ADBLOCKED__")
bridge.js (ISOLATED world)
β listen postMessage
β batch 200ms
β chrome.runtime.sendMessage("AD_BLOCKED", count)
background.js (service worker)
β blockedStats.total += count
β blockedStats.today += count
β chrome.storage.local.set({ blockedStats })
popup.js
β GET_STATUS β render(today, total)
Click to see full list (50+ networks)
pagead2.googlesyndication.comadservice.google.comgoogleads.g.doubleclick.nettpc.googlesyndication.comwww.googleadservices.com
adnxs.comβ Xandr/AppNexusadsrvr.orgβ The Trade Deskamazon-adsystem.comβ Amazon Advertisingbidswitch.netβ IPONWEBcasalemedia.comβ Index Exchangecriteo.com/criteo.netβ Criteodoubleclick.netβ Google DoubleClickindexww.comβ Index Exchangemedia.netβ Media.netopenx.netβ OpenXpubmatic.comβ PubMaticrlcdn.comβ Rocket Fuelrubiconproject.comβ Magnitesharethrough.comβ Sharethroughtaboola.comβ Taboolateads.tvβ Teadsturn.comβ Amobee
hotjar.comβ Hotjarmoatads.comβ Oracle Moatscorecardresearch.comβ comScore
coinhive.comβ CoinHivecoin-hive.comβ Coin-Hive
popads.netβ PopAdspopcash.netβ PopCashpropellerads.comβ PropellerAdsexoclick.comβ ExoClickadskeeper.comβ AdsKeeper
ads.themoneytizer.comβ TheMoneyTizertds.mediapays.infoβ Mediapays TDS
d2ng6x3yyemlxz.cloudfront.netβ LootLabsd2dxy39sqorbhv.cloudfront.netβ LootLabsacscdn.comβ ADCash
bowersorgamy.comβ Galaksionlekachmididae.comβ Galaksionbarkersceleb.comβ Galaksionwpadmngr.comβ AdManager
botradar.techβ Bot detection (anti-adblock)ads.desustream.comβ OtakuDesu adsrebrand.lyβ Affiliate redirect (betting)web.tolstoycomments.comβ Comment widget ad vectorpixel.facebook.comβ Facebook trackinganalytics.facebook.comβ Facebook analytics
| Permission | Why It's Needed |
|---|---|
storage |
Save toggle state, custom rules, and block statistics |
activeTab |
Interact with the current tab for future features |
scripting |
Inject scripts when needed |
webNavigation |
Monitor page navigation for rule application |
declarativeNetRequest |
Block ad network requests at the browser level |
declarativeNetRequestWithHostAccess |
Block requests across all sites |
host_permissions: <all_urls> |
Required to intercept and block ad network requests across all sites |
Note: GhostBlock does NOT collect, transmit, or store any browsing data. All processing happens locally.
- Google Chrome 120+ (or Chromium-based browser)
- Basic text editor
git clone https://github.com/Irnhakim/ghost-block.git
cd ghost-block
# No build step needed β load directly in Chrome- Load the extension in developer mode
- Visit a site with ads (e.g., news sites, YouTube, Facebook)
- Open DevTools β Console to verify no errors
- Check the popup for block statistics
- Edit
lib/dnr-rules.jsonβ add a new rule object with unique ID - Edit
lib/filter-rules.jsβ add hostname toadHostsand patterns toadScriptPatterns - Edit
background.jsβ add toDEFAULT_AD_HOSTSarray - Edit
css/stealth.cssβ add iframe/DOM selectors if needed
- Edit
content.jsβpatchAntiAdblock()function - Add hostname check:
if (hostname.includes("example.com")) { ... } - Add CSS selectors to
stealth.css - Add hostnames to
filter-rules.jsβadHosts - Add hostnames to
background.jsβDEFAULT_AD_HOSTS - Add DNR rules to
lib/dnr-rules.json
GhostBlock is designed with privacy as a priority:
- β No data collection β zero telemetry
- β No remote connections β everything runs locally
- β No analytics β we don't track your usage
- β Open source β full code transparency
- β Minimal permissions β only what's needed to function
MIT License β see LICENSE for details.
Irnhakim β @Irnhakim
If GhostBlock saved you from ads, consider supporting:
| Platform | Link |
|---|---|
| Saweria | saweria.co/irnhakim |
| Buy Me a Coffee | buymeacoffee.com/irnhakim |
π» GhostBlock β Silent. Invisible. Undetectable.
Made with β by @Irnhakim