How ublockorigin/ubol-home works
1. What this repo is
- This is uBO Lite, a browser extension that blocks ads/trackers using the browser’s declarative MV3-style filtering APIs rather than a continuously running blocking engine.
- The main architectural idea is: filter lists are compiled into static rulesets and helper assets, then the browser applies them directly at network/page-injection time.
2. Targeted runtimes
- The repository is split into browser-specific delivery trees:
- chromium/ for Chrome/Edge-class browsers
- firefox/ for Firefox
- dist/safari/ for the Safari app + extension wrapper
- Each target has its own manifest.json, UI HTML pages, localized strings, and ruleset layout, reflecting platform API differences.
3. Control plane vs. filtering plane
- The control plane is the extension UI and background logic: popup, dashboard/options, troubleshooting, developer pages, and storage/settings management.
- The filtering plane is declarative: compiled rulesets, CSS injection rules, scriptlet resources, redirect resources, and other browser-consumed assets that apply even when the extension’s background process is inactive.
4. Background/runtime entry points
- Chromium uses a service-worker style background (chromium/js/background.js), while Firefox uses a background page (firefox/background.html + firefox/js/background.js).
- These runtime entry points coordinate state, ruleset enablement, mode selection, and messaging between UI surfaces and the declarative filtering assets.
5. User-facing surfaces
- Main interaction points are:
- popup.html / js/popup.js for quick mode toggles and status
- dashboard.html / js/dashboard.js for configuration and ruleset selection
- browser-specific support pages such as matched-rules, report, picker/unpicker/zapper, strictblock, and troubleshooting views
- These pages do not implement filtering themselves; they drive configuration and expose debugging/inspection tooling.
6. Rulesets as the core data model
- The rulesets/ trees are the heart of the system.
- They contain prebuilt JSON/JS/CSS artifacts grouped by function: main, regex, scripting, scriptlet, strictblock, urlskip, redirect, modify-headers, removeparam, and similar.
- The default configuration includes uBlock Origin’s built-in lists plus well-known list sources such as EasyList, EasyPrivacy, and Peter Lowe’s list.
7. How page/network blocking is applied
- Network-level blocking comes from declarative rules derived from the ruleset files.
- Page-level blocking is handled by injected CSS rules and scriptlets that neutralize common anti-adblock, popup, overlay, cookie, and tracking behaviors.
- More specialized logic is split by browser: Chromium leans heavily on DNR-style JSON rules, while Firefox includes declarative CSS and additional rule classes where supported.
8. Scriptlet and resource subsystem
- web_accessible_resources/ contains helper payloads the extension may expose to pages, such as no-op resources, ad-tech shims, and anti-detection helpers.
- js/resources/ and firefox/rulesets/scripting/scriptlet/ hold reusable scriptlet implementations used by the compiled rulesets.
- This layer is what lets the extension modify page behavior without a persistent content script process.
9. Browser-specific feature differences
- Chromium has a richer set of UI/tooling modules like picker/zapper/unpicker, DNR editors, strictblock, report, and ruleset parsers for Chromium’s declarative rules model.
- Firefox has parallel concepts but a different ruleset taxonomy, including modify-headers, redirect, and removeparam, plus declarative CSS-heavy filtering artifacts.
- The architecture is therefore “same product, different platform adapters,” not a single shared runtime.
10. State, policy, and localization
- Settings and runtime state are stored in extension storage; managed_storage.json shows support for administrator-controlled policy via managed storage.
- Localized strings live under _locales/ in both browser trees, making the UI and messages translation-driven.
- theme.js, settings.js, mode-manager.js, and ruleset-manager.js form the main state-management boundary for configuration and user preferences.
11. Build/release structure
- The root-level package.json, Makefile, and publish-extension tooling indicate a build/release pipeline that assembles browser-specific distributions.
- dist/ contains release-target artifacts, including Firefox update metadata and the Safari Xcode project wrapper, while .github/workflows/ automates beta/release publication.
12. Useful architecture diagram framing
- A good diagram would show:
- User/UI surfaces on one side
- Background/control logic in the middle
- Compiled rulesets + resources as the declarative execution layer
- Browser enforcement APIs as the actual blocker
- Optional admin policy and storage as external configuration inputs
- The key boundary is that the extension mostly configures blocking rather than executing it continuously.
Main entry points: popup.html Chrome UI · Makefile Makefile · background.js SW background · background.html BG page
Components 24
Shared core
Repository-wide build tooling and browser-agnostic logic reused across delivery targets.
- Package tools · Root build and publish entry points for assembling target-specific distributions.
package.json - Makefile · Top-level build orchestration used by release and packaging commands.
Makefile - Publish tool · Repository-level publication helper for extension packaging and release flow.
publish-extension - UBO source · Upstream uBlock Origin source subtree referenced by the lite build.
uBlock - Release meta · Release/update metadata used for browser distribution channels.
dist/firefox/updates.json
Chromium build
Chrome/Edge-class extension tree with service-worker background and DNR-centric rulesets.
- Chromium manifest · Chromium target configuration and declared capabilities.
chromium/manifest.json - SW background · Chromium service-worker style background entry point coordinating state and messaging.
chromium/js/background.js - Chrome UI · Primary user-facing pages for popup, dashboard, matching, reporting, and tools.
chromium/popup.html - Settings core · Chromium configuration boundary for modes, theme, settings, and ruleset enablement.
chromium/js/settings.js - Ruleset mgr · Chromium ruleset selection and activation logic.
chromium/js/ruleset-manager.js - Scripting mgr · Chromium scripting pipeline that compiles and dispatches CSS/scriptlet assets.
chromium/js/scripting-manager.js - DNR rulesets · Chromium declarative filtering artifacts: main, regex, scripting, strictblock, urlskip, and related outputs.
chromium/rulesets - Helper payloads · Web-accessible shims, no-op assets, and anti-detection helper payloads exposed to pages.
chromium/web_accessible_resources - Injected scripts · Chromium injected CSS/scriptlet modules used by the declarative filtering plane.
chromium/js/scripting - Locales · Chromium localized UI strings and messages.
chromium/_locales
Firefox build
Firefox extension tree with background page and Firefox-specific declarative filtering artifacts.
- Firefox manifest · Firefox target configuration and declared capabilities.
firefox/manifest.json - BG page · Firefox background page and script entry point coordinating state and messaging.
firefox/background.html - Firefox UI · Primary user-facing pages for popup, dashboard, and matched-rules views.
firefox/popup.html - Settings core · Firefox configuration boundary for modes, theme, settings, and ruleset enablement.
firefox/js/settings.js - Declarative rules · Firefox filtering artifacts including main, regex, redirect, removeparam, modify-headers, and scriptlet/CSS outputs.
firefox/rulesets - Scripting assets · Firefox declarative and procedural CSS/scriptlet assets compiled for page-level neutralization.
firefox/rulesets/scripting - Helper payloads · Firefox web-accessible helper payloads and no-op assets used by rulesets.
firefox/web_accessible_resources - Locales · Firefox localized UI strings and messages.
firefox/_locales
Safari dist
Safari app and extension wrapper used for packaged release distribution.
- Safari wrapper · Safari app and extension packaging tree used for distribution.
dist/safari
Connections 31
- Package tools → Makefile: drives · Package scripts invoke build orchestration.
- Package tools → Publish tool: publishes · Package metadata feeds release publication.
- Makefile → Chromium manifest: assembles · Build pipeline assembles Chromium target artifacts.
- Makefile → Firefox manifest: assembles · Build pipeline assembles Firefox target artifacts.
- Makefile → Safari wrapper: packages · Build pipeline prepares Safari distribution wrapper.
- UBO source → DNR rulesets: source · Shared upstream filter content is compiled into Chromium rulesets.
- UBO source → Declarative rules: source · Shared upstream filter content is compiled into Firefox rulesets.
- Chromium manifest → SW background: boots · Manifest selects the Chromium runtime entry point.
- Chromium manifest → Chrome UI: exposes · Manifest declares user-facing extension pages.
- SW background → Settings core: coordinates · Background logic manages settings and mode state.
- SW background → Ruleset mgr: enables · Background logic controls ruleset activation.
- SW background → Scripting mgr: dispatches · Background logic coordinates scriptlet and CSS asset loading.
- Settings core → Chrome UI: serves · UI reads and updates extension state.
- Ruleset mgr → DNR rulesets: selects · Ruleset manager selects compiled declarative assets.
- Scripting mgr → Injected scripts: builds · Scripting manager emits injected page scripts.
- Injected scripts → Helper payloads: uses · Injected scripts rely on helper payloads and shims.
- DNR rulesets → Helper payloads: references · Compiled rulesets reference exposed helper resources.
- Chrome UI → Ruleset mgr: configures · UI surfaces configure ruleset selection and diagnostics.
- Chrome UI → Settings core: updates · UI surfaces update settings and modes.
- Firefox manifest → BG page: boots · Manifest selects the Firefox runtime entry point.
- Firefox manifest → Firefox UI: exposes · Manifest declares user-facing extension pages.
- BG page → Settings core: coordinates · Background page manages settings and mode state.
- BG page → Declarative rules: enables · Background page controls ruleset activation.
- BG page → Scripting assets: dispatches · Background page coordinates declarative and procedural assets.
- Settings core → Firefox UI: serves · UI reads and updates extension state.
- Declarative rules → Scripting assets: includes · Ruleset layout includes CSS and scriptlet artifacts.
- Declarative rules → Helper payloads: references · Compiled rulesets reference helper resources.
- Firefox UI → Settings core: updates · UI surfaces update settings and modes.
- Release meta → Publish tool: feeds · Release metadata supports publication workflows.
- Locales → Chrome UI: localizes · Localized strings drive Chromium UI text.
- Locales → Firefox UI: localizes · Localized strings drive Firefox UI text.