# ublockorigin/ubol-home architecture

> Architecture diagram of the GitHub repository ublockorigin/ubol-home, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ublockorigin/ubol-home
- Repository: https://github.com/ublockorigin/ubol-home

## Overview

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: [`chromium/popup.html`](https://github.com/ublockorigin/ubol-home/blob/main/chromium/popup.html) (Chrome UI), [`Makefile`](https://github.com/ublockorigin/ubol-home/tree/main/Makefile) (Makefile), [`chromium/js/background.js`](https://github.com/ublockorigin/ubol-home/blob/main/chromium/js/background.js) (SW background), [`firefox/background.html`](https://github.com/ublockorigin/ubol-home/blob/main/firefox/background.html) (BG page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shared["Shared core"]
  node_package["Package tools<br/>build/release<br/>[package.json]"]
  node_makefile["Makefile<br/>build orchestration"]
  node_publish["Publish tool<br/>release script"]
  node_root_uo["UBO source<br/>source sync"]
  node_release_meta["Release meta<br/>distribution metadata<br/>[updates.json]"]
end

subgraph group_chromium["Chromium build"]
  node_chromium_manifest["Chromium manifest<br/>extension manifest<br/>[manifest.json]"]
  node_chromium_bg(("SW background<br/>runtime coordinator<br/>[background.js]"))
  node_chromium_ui["Chrome UI<br/>ui surface<br/>[popup.html]"]
  node_chromium_state["Settings core<br/>state management<br/>[settings.js]"]
  node_chromium_ruleset_mgr["Ruleset mgr<br/>ruleset control<br/>[ruleset-manager.js]"]
  node_chromium_scripting_mgr["Scripting mgr<br/>declarative scripting"]
  node_chromium_rulesets[("DNR rulesets<br/>compiled filtering assets")]
  node_chromium_resources["Helper payloads<br/>web resources"]
  node_chromium_scripting["Injected scripts<br/>page injection"]
  node_chromium_locale["Locales<br/>translations"]
end

subgraph group_firefox["Firefox build"]
  node_firefox_manifest["Firefox manifest<br/>extension manifest<br/>[manifest.json]"]
  node_firefox_bg(("BG page<br/>runtime coordinator<br/>[background.html]"))
  node_firefox_ui["Firefox UI<br/>ui surface<br/>[popup.html]"]
  node_firefox_state["Settings core<br/>state management<br/>[settings.js]"]
  node_firefox_rulesets[("Declarative rules<br/>compiled filtering assets")]
  node_firefox_scripting["Scripting assets<br/>page injection"]
  node_firefox_resources["Helper payloads<br/>web resources"]
  node_firefox_locale["Locales<br/>translations"]
end

subgraph group_safari["Safari dist"]
  node_safari_dist["Safari wrapper<br/>packaging target"]
end

node_package -->|"drives"| node_makefile
node_package -->|"publishes"| node_publish
node_makefile -->|"assembles"| node_chromium_manifest
node_makefile -->|"assembles"| node_firefox_manifest
node_makefile -->|"packages"| node_safari_dist
node_root_uo -->|"source"| node_chromium_rulesets
node_root_uo -->|"source"| node_firefox_rulesets
node_chromium_manifest -->|"boots"| node_chromium_bg
node_chromium_manifest -->|"exposes"| node_chromium_ui
node_chromium_bg -->|"coordinates"| node_chromium_state
node_chromium_bg -->|"enables"| node_chromium_ruleset_mgr
node_chromium_bg -->|"dispatches"| node_chromium_scripting_mgr
node_chromium_state -->|"serves"| node_chromium_ui
node_chromium_ruleset_mgr -->|"selects"| node_chromium_rulesets
node_chromium_scripting_mgr -->|"builds"| node_chromium_scripting
node_chromium_scripting -->|"uses"| node_chromium_resources
node_chromium_rulesets -->|"references"| node_chromium_resources
node_chromium_ui -->|"configures"| node_chromium_ruleset_mgr
node_chromium_ui -->|"updates"| node_chromium_state
node_firefox_manifest -->|"boots"| node_firefox_bg
node_firefox_manifest -->|"exposes"| node_firefox_ui
node_firefox_bg -->|"coordinates"| node_firefox_state
node_firefox_bg -->|"enables"| node_firefox_rulesets
node_firefox_bg -->|"dispatches"| node_firefox_scripting
node_firefox_state -->|"serves"| node_firefox_ui
node_firefox_rulesets -->|"includes"| node_firefox_scripting
node_firefox_rulesets -->|"references"| node_firefox_resources
node_firefox_ui -->|"updates"| node_firefox_state
node_release_meta -->|"feeds"| node_publish
node_chromium_locale -->|"localizes"| node_chromium_ui
node_firefox_locale -->|"localizes"| node_firefox_ui

click node_package "https://github.com/ublockorigin/ubol-home/blob/main/package.json"
click node_makefile "https://github.com/ublockorigin/ubol-home/tree/main/Makefile"
click node_publish "https://github.com/ublockorigin/ubol-home/tree/main/publish-extension"
click node_root_uo "https://github.com/ublockorigin/ubol-home/tree/main/uBlock"
click node_chromium_manifest "https://github.com/ublockorigin/ubol-home/blob/main/chromium/manifest.json"
click node_chromium_bg "https://github.com/ublockorigin/ubol-home/blob/main/chromium/js/background.js"
click node_chromium_ui "https://github.com/ublockorigin/ubol-home/blob/main/chromium/popup.html"
click node_chromium_state "https://github.com/ublockorigin/ubol-home/blob/main/chromium/js/settings.js"
click node_chromium_ruleset_mgr "https://github.com/ublockorigin/ubol-home/blob/main/chromium/js/ruleset-manager.js"
click node_chromium_scripting_mgr "https://github.com/ublockorigin/ubol-home/blob/main/chromium/js/scripting-manager.js"
click node_chromium_rulesets "https://github.com/ublockorigin/ubol-home/tree/main/chromium/rulesets"
click node_chromium_resources "https://github.com/ublockorigin/ubol-home/tree/main/chromium/web_accessible_resources"
click node_chromium_scripting "https://github.com/ublockorigin/ubol-home/tree/main/chromium/js/scripting"
click node_chromium_locale "https://github.com/ublockorigin/ubol-home/tree/main/chromium/_locales"
click node_firefox_manifest "https://github.com/ublockorigin/ubol-home/blob/main/firefox/manifest.json"
click node_firefox_bg "https://github.com/ublockorigin/ubol-home/blob/main/firefox/background.html"
click node_firefox_ui "https://github.com/ublockorigin/ubol-home/blob/main/firefox/popup.html"
click node_firefox_state "https://github.com/ublockorigin/ubol-home/blob/main/firefox/js/settings.js"
click node_firefox_rulesets "https://github.com/ublockorigin/ubol-home/tree/main/firefox/rulesets"
click node_firefox_scripting "https://github.com/ublockorigin/ubol-home/tree/main/firefox/rulesets/scripting"
click node_firefox_resources "https://github.com/ublockorigin/ubol-home/tree/main/firefox/web_accessible_resources"
click node_firefox_locale "https://github.com/ublockorigin/ubol-home/tree/main/firefox/_locales"
click node_safari_dist "https://github.com/ublockorigin/ubol-home/tree/main/dist/safari"
click node_release_meta "https://github.com/ublockorigin/ubol-home/blob/main/dist/firefox/updates.json"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_package,node_makefile,node_publish,node_root_uo,node_release_meta toneBlue
class node_chromium_manifest,node_chromium_bg,node_chromium_ui,node_chromium_state,node_chromium_ruleset_mgr,node_chromium_scripting_mgr,node_chromium_rulesets,node_chromium_resources,node_chromium_scripting,node_chromium_locale toneAmber
class node_firefox_manifest,node_firefox_bg,node_firefox_ui,node_firefox_state,node_firefox_rulesets,node_firefox_scripting,node_firefox_resources,node_firefox_locale toneMint
class node_safari_dist toneRose
```

## Components

### Shared core

Repository-wide build tooling and browser-agnostic logic reused across delivery targets.

- [Package tools](https://github.com/ublockorigin/ubol-home/blob/main/package.json): build/release · Root build and publish entry points for assembling target-specific distributions. · `package.json`
- [Makefile](https://github.com/ublockorigin/ubol-home/tree/main/Makefile): build orchestration · Top-level build orchestration used by release and packaging commands. · `Makefile`
- [Publish tool](https://github.com/ublockorigin/ubol-home/tree/main/publish-extension): release script · Repository-level publication helper for extension packaging and release flow. · `publish-extension`
- [UBO source](https://github.com/ublockorigin/ubol-home/tree/main/uBlock): source sync · Upstream uBlock Origin source subtree referenced by the lite build. · `uBlock`
- [Release meta](https://github.com/ublockorigin/ubol-home/blob/main/dist/firefox/updates.json): distribution metadata · 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](https://github.com/ublockorigin/ubol-home/blob/main/chromium/manifest.json): extension manifest · Chromium target configuration and declared capabilities. · `chromium/manifest.json`
- [SW background](https://github.com/ublockorigin/ubol-home/blob/main/chromium/js/background.js): runtime coordinator · Chromium service-worker style background entry point coordinating state and messaging. · `chromium/js/background.js`
- [Chrome UI](https://github.com/ublockorigin/ubol-home/blob/main/chromium/popup.html): ui surface · Primary user-facing pages for popup, dashboard, matching, reporting, and tools. · `chromium/popup.html`
- [Settings core](https://github.com/ublockorigin/ubol-home/blob/main/chromium/js/settings.js): state management · Chromium configuration boundary for modes, theme, settings, and ruleset enablement. · `chromium/js/settings.js`
- [Ruleset mgr](https://github.com/ublockorigin/ubol-home/blob/main/chromium/js/ruleset-manager.js): ruleset control · Chromium ruleset selection and activation logic. · `chromium/js/ruleset-manager.js`
- [Scripting mgr](https://github.com/ublockorigin/ubol-home/blob/main/chromium/js/scripting-manager.js): declarative scripting · Chromium scripting pipeline that compiles and dispatches CSS/scriptlet assets. · `chromium/js/scripting-manager.js`
- [DNR rulesets](https://github.com/ublockorigin/ubol-home/tree/main/chromium/rulesets): compiled filtering assets · Chromium declarative filtering artifacts: main, regex, scripting, strictblock, urlskip, and related outputs. · `chromium/rulesets`
- [Helper payloads](https://github.com/ublockorigin/ubol-home/tree/main/chromium/web_accessible_resources): web resources · Web-accessible shims, no-op assets, and anti-detection helper payloads exposed to pages. · `chromium/web_accessible_resources`
- [Injected scripts](https://github.com/ublockorigin/ubol-home/tree/main/chromium/js/scripting): page injection · Chromium injected CSS/scriptlet modules used by the declarative filtering plane. · `chromium/js/scripting`
- [Locales](https://github.com/ublockorigin/ubol-home/tree/main/chromium/_locales): translations · Chromium localized UI strings and messages. · `chromium/_locales`

### Firefox build

Firefox extension tree with background page and Firefox-specific declarative filtering artifacts.

- [Firefox manifest](https://github.com/ublockorigin/ubol-home/blob/main/firefox/manifest.json): extension manifest · Firefox target configuration and declared capabilities. · `firefox/manifest.json`
- [BG page](https://github.com/ublockorigin/ubol-home/blob/main/firefox/background.html): runtime coordinator · Firefox background page and script entry point coordinating state and messaging. · `firefox/background.html`
- [Firefox UI](https://github.com/ublockorigin/ubol-home/blob/main/firefox/popup.html): ui surface · Primary user-facing pages for popup, dashboard, and matched-rules views. · `firefox/popup.html`
- [Settings core](https://github.com/ublockorigin/ubol-home/blob/main/firefox/js/settings.js): state management · Firefox configuration boundary for modes, theme, settings, and ruleset enablement. · `firefox/js/settings.js`
- [Declarative rules](https://github.com/ublockorigin/ubol-home/tree/main/firefox/rulesets): compiled filtering assets · Firefox filtering artifacts including main, regex, redirect, removeparam, modify-headers, and scriptlet/CSS outputs. · `firefox/rulesets`
- [Scripting assets](https://github.com/ublockorigin/ubol-home/tree/main/firefox/rulesets/scripting): page injection · Firefox declarative and procedural CSS/scriptlet assets compiled for page-level neutralization. · `firefox/rulesets/scripting`
- [Helper payloads](https://github.com/ublockorigin/ubol-home/tree/main/firefox/web_accessible_resources): web resources · Firefox web-accessible helper payloads and no-op assets used by rulesets. · `firefox/web_accessible_resources`
- [Locales](https://github.com/ublockorigin/ubol-home/tree/main/firefox/_locales): translations · Firefox localized UI strings and messages. · `firefox/_locales`

### Safari dist

Safari app and extension wrapper used for packaged release distribution.

- [Safari wrapper](https://github.com/ublockorigin/ubol-home/tree/main/dist/safari): packaging target · Safari app and extension packaging tree used for distribution. · `dist/safari`

## Connections

- 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.
