# Architecture – Overview ## Building blocks ```text Thunderbird / Betterbird ├── Background script (src/background.js) event page, Manifest V3 │ ├── registers the compose script (scripting.compose) │ ├── keeps the on/off state per compose window (storage.session, else in memory) │ ├── "Inline Comment" toolbar button (composeAction, badge "on"/"off") │ └── delivers the configuration: settings + identity + on/off + plain text? │ ├── Compose script (src/compose/compose.js) in the editor document of every compose window │ ├── intercepts typed characters inside a quote (keydown, fallback: beforeinput) │ ├── splits the quote (editor command insertParagraph, fallback: manual split) │ └── inserts the comment with its marker (insertHTML or insertText) │ ├── Options page (src/options/) settings in storage.local, localized texts │ ├── Translations (src/_locales/{en,de}/messages.json) default locale: en │ └── Shared library (src/lib/) classic UMD scripts, testable under Node ├── settings.js defaults, validation, profiles per identity, compose script file list ├── marker.js placeholders, initials, comment as DOM node or plain text ├── quote.js quote and gap detection, manual split, caret placement └── i18n.js localizeDocument() for data-i18n attributes (options page) ``` The library files attach their functions to `globalThis.InlineComment` and also export them through `module.exports`, so the same file runs in the add-on and in the Node tests. They are classic scripts rather than ES modules because compose scripts cannot load modules. ## What runs where | Context | Scripts, in load order | Defined in | | -------------- | ------------------------------------------------------------------------ | ------------------------------------------- | | Background | `lib/settings.js`, `lib/marker.js`, `background.js` | `manifest.json` → `background` | | Compose window | `lib/settings.js`, `lib/marker.js`, `lib/quote.js`, `compose/compose.js` | `COMPOSE_SCRIPT_FILES` in `lib/settings.js` | | Options page | `lib/settings.js`, `lib/marker.js`, `lib/i18n.js`, `options/options.js` | `