A production-ready Chrome Extension that automatically rejects optional cookies and accepts only necessary cookies when visiting websites. Built with Manifest V3, Vite, React 18, and TypeScript.
- Automatic detection and dismissal of cookie consent banners
- Heuristic support for OneTrust, Cookiebot, TrustArc, and generic banners
- Per-domain override controls
- Global enable/disable toggle
- Clean popup UI with status reporting
- Zero external UI dependencies
- Minimal permission footprint
src/
background/index.ts Service worker: tab events, script injection
content/
index.ts Content script entry: MutationObserver + retry logic
cookieHandler.ts Banner detection and button clicking
popup/
App.tsx React popup UI with toggle controls
ErrorBoundary.tsx Error boundary with user-friendly fallback
main.tsx React entry point
Popup.css Standalone popup styles
lib/
storage.ts chrome.storage.sync typed abstraction
domUtils.ts DOM visibility and element helpers
keywordMatcher.ts Case-insensitive keyword matching engine
manifest.json Manifest V3 configuration
public/
icons/ Extension icons (16, 32, 48, 128)
popup.html Popup HTML shell
vite.config.ts Multi-target Vite build config
- Node.js 18+
- npm 9+ or pnpm
npm installnpm run buildThis runs a three-stage Vite build:
- Popup (React app with HTML entry)
- Content script (IIFE bundle)
- Background service worker (ES module)
The final output lands in dist/.
npm run devRebuilds automatically when source files change.
- Open
chrome://extensions/ - Enable "Developer mode" (top-right toggle)
- Click "Load unpacked"
- Select the
dist/folder - The shield icon appears in your toolbar
After rebuilding, return to chrome://extensions/ and click the refresh icon on the Minimal Cookie Guard card. Then reload the target webpage.
MutationObserver over polling. The content script observes DOM mutations instead of polling, which avoids performance overhead. A debounce window (500ms) collapses rapid mutations into a single scan. The observer disconnects itself after a successful action.
Heuristic detection over fragile selectors. Rather than hardcoding CSS selectors for specific consent platforms, the extension matches button text against a keyword list. This approach survives platform UI updates better than selector-based strategies.
Three-pass Vite build. Chrome extensions require different module formats for each context: IIFE for content scripts (no ES module support in page context), ES modules for the service worker, and standard Vite output for the popup. The build script orchestrates all three passes.
Minimal permissions. The extension requests only storage, activeTab, and scripting. The <all_urls> host permission is required for chrome.scripting.executeScript to inject content scripts on any domain.
| Permission | Reason |
|---|---|
storage |
Persist user preferences via chrome.storage.sync |
activeTab |
Read the current tab URL for per-domain controls |
scripting |
Programmatically inject the content script |
<all_urls> |
Allow injection on any website the user visits |
Before submitting:
- Replace placeholder SVG icons in
public/icons/with production PNG artwork at 16, 32, 48, and 128px - Update
versioninsrc/manifest.jsonandpackage.json - Include the privacy statement (see
PRIVACY.md) - Create promotional screenshots (1280x800 or 640x400)
- Write a store description highlighting the privacy-first approach
- Zip the contents of
dist/(not the folder itself) for upload
npm run cleanRemoves the dist/ directory.
MIT