How efforg/privacybadger works
Privacy Badger is a browser extension that learns to block hidden trackers while sending GPC and Do Not Track signals. The principal flow is browser activity entering the background coordinator, where requests are evaluated and tracker decisions are persisted; content scripts and browser request handling enforce protections. Separate capabilities include click-to-activate widget replacements, social-link cleaning, and user controls. The source index supports the core coordinator and selected utilities, but several major feature implementations were not sampled; their relationships are shown only where the README documents them.
Main entry points: background.js Background coordinator · contentscripts Page protections · storage.js Privacy state · webrequest.js Request handling
Components 21
Extension runtime
- Background coordinator
src/js/background.js - Request handling
src/js/webrequest.js - Tab context
src/js/tabdata.js - Privacy state
src/js/storage.js - Runtime bootstrap
src/js/bootstrap.js - Domain utilities
src/lib/basedomain.js - Public suffix data
src/lib/publicSuffixList.js
Tracker defenses
- Tracker learning
src/js/heuristicblocking.js - First-party mapping
src/js/multiDomainFirstParties.js - Page protections
src/js/contentscripts
Privacy features
- DNT and GPC signals
src/js/contentscripts/dnt.js - Fingerprint defenses
src/js/contentscripts/fingerprinting.js - Storage protections
src/js/contentscripts/clobberstorage.js - Widget replacements
src/js/socialwidgetloader.js - Surrogate dispatch
src/js/surrogates.js - Surrogate definitions
src/data/surrogates.js - Social link cleaning
src/js/firstparties
User controls
- Toolbar controls
src/js/popup.js - Settings interface
src/js/options.js
Other components
- Browser activity
- Extension user
Connections 24
- Browser activity → Background coordinator: triggers
src/js/background.js - Background coordinator → Request handling: registers handling
src/js/background.js - Background coordinator → Privacy state: initializes state
src/js/background.js - Background coordinator → Tab context: uses tab context
src/js/background.js - Request handling → Domain utilities: extracts domains
src/js/webrequest.js - Domain utilities → Public suffix data: looks up suffixes
src/lib/basedomain.js - Privacy state → Domain utilities: gets base domains
src/js/storage.js - Privacy state → Runtime bootstrap: logs events
src/js/storage.js - Privacy state → DNT and GPC signals: subscribes script updates
src/js/storage.js - Background coordinator → Tracker learning: loads
src/js/background.js - Background coordinator → Widget replacements: loads
src/js/background.js - Request handling → Surrogate dispatch: uses redirects
src/js/webrequest.js - Surrogate dispatch → Surrogate definitions: loads mappings
src/js/surrogates.js - Extension user → Toolbar controls: opens controls
README.md - Extension user → Settings interface: configures privacy
README.md - Extension user → Background coordinator: browses
README.md - Background coordinator → Page protections: enforces protections
- Page protections → DNT and GPC signals: sends signals
README.md - Tracker learning → Privacy state: records decisions
- Request handling → First-party mapping: checks ownership
- Page protections → Fingerprint defenses: blocks tracking
- Page protections → Storage protections: protects storage
- Widget replacements → Surrogate dispatch: provides replacements
README.md - Page protections → Social link cleaning: cleans links
README.md