OpenCode AI e9899d2e6d
Some checks failed
Android CI Build / check (push) Has been cancelled
Android CI Build / package-apks (push) Has been cancelled
Docs Deploy / build (push) Has been cancelled
Module Market Check / Validate modules/ (push) Has been cancelled
Module Market Publish / Generate submissions.json (push) Has been cancelled
Docs Deploy / deploy (push) Has been cancelled
Initial DruksCode V2: fresh fork of web-to-app (f3b488e) with DruksCode identity
- Package rename com.webtoapp -> br.com.drukstech.codeapp
- Product rename WebToApp/web-to-app -> DruksCode/drukscode
- Design system Wta* -> Dkc*
- applicationId br.com.drukstech.codeapp (.play for gplay flavor)
- rootProject.name DruksCode
- Fresh git history (upstream kept as remote for sync)
2026-09-12 02:42:02 +02:00

39 lines
2.2 KiB
Markdown

# Extension Authoring
DruksCode stays extensible after an app ships. You can add four kinds of extensions, all managed by a single `ExtensionManager` and injected by the WebView at page-lifecycle hooks:
| Type | What it is | Good for |
| --- | --- | --- |
| **[JS Module](/extensions/js-module)** | A `module.json` manifest + `main.js` (+ optional CSS) | Custom features with a config UI and floating panel |
| **[CSS Module](/extensions/css-module)** | A pure style override (still needs a `main.js` stub) | Theming, restyling, dark mode |
| **[Userscript](/extensions/userscript)** | Tampermonkey/Greasemonkey-style `.user.js` | Porting existing userscripts; `GM_*` APIs |
| **[Chrome MV3](/extensions/chrome-mv3)** | A Manifest V3 Chrome extension | Porting browser extensions; `chrome.*` APIs |
## How injection works
All four types are normalized into one internal `ExtensionModule` model. At runtime, `WebViewManager` injects each module at its configured **run time**:
| Run time | Fires at |
| --- | --- |
| `DOCUMENT_START` | `onPageStarted` |
| `DOCUMENT_END` | `onPageFinished` (DOMContentLoaded) |
| `DOCUMENT_IDLE` | after load (default) |
| `CONTEXT_MENU` | on context menu |
| `BEFORE_UNLOAD` | before unload |
Each module also carries **URL match rules** (Chrome-style globs or regex) that decide which pages it runs on.
::: warning Important accuracy notes
A few behaviors differ from what other extension platforms imply. These are documented on the relevant pages, but worth knowing up front:
- **Userscript `GM_*` functions are not gated by `@grant`** — all are exposed unconditionally.
- **Chrome `ISOLATED` vs `MAIN` world is not truly isolated** — Android WebView has a single JS context; isolation is simulated.
- **`GM_notification` only logs**; the MV3 "background service worker" is a hidden WebView, not a real service worker.
:::
## Where to go next
- [JS Modules](/extensions/js-module) — the most capable native format.
- [Userscripts](/extensions/userscript) — the `GM_*` / `GM.*` API reference.
- [Chrome MV3](/extensions/chrome-mv3) — the supported `chrome.*` surface.
- [Publish to the Market](/extensions/publish) — share JS/CSS modules with the community.