diff --git a/tampermonkey/README.md b/tampermonkey/README.md new file mode 100644 index 0000000..5f4c934 --- /dev/null +++ b/tampermonkey/README.md @@ -0,0 +1,16 @@ +# tampermonkey/ — script loader + +Install `loader.user.js` once (click it on the jsDelivr/raw URL). It loads other +userscripts from GitHub: a curated `registry.json` (auto-loaded per-domain) plus a +freeform field (URL or pasted snippet). Integrity via SRI tokens. + +- **Install:** open `https://cdn.jsdelivr.net/gh/mcint/userscripts@main/tampermonkey/loader.user.js` +- **Use:** Tampermonkey menu → "Open userscripts loader" +- **Config:** edit the `const` block at the top of `loader.user.js` + (`REQUIRE_SRI`, `DEFAULT_OWNER`, `REGISTRY_URL`, `REGISTRY_TTL_MS`). +- **Add a script:** add an entry to `registry.json` (see the design spec for the + schema); use the panel's "hash it" to fill `integrity`. +- **Tests:** `cd tampermonkey && node --test` +- **Phases & prior art:** see `refs/`. + +Design: `../docs/superpowers/specs/2026-06-15-tampermonkey-script-loader-design.md` diff --git a/tampermonkey/refs/inspiration.md b/tampermonkey/refs/inspiration.md new file mode 100644 index 0000000..5fa790a --- /dev/null +++ b/tampermonkey/refs/inspiration.md @@ -0,0 +1,12 @@ +# Inspiration (prior art we draw FROM) + +Kept separate from any future COMPARISON doc (methods convention). + +- jsDelivr `gh` passthrough — CDN delivery of repo files with JS content-type: + https://www.jsdelivr.com/documentation#id-github +- W3C Subresource Integrity — the `sha384-` token format: + https://www.w3.org/TR/SRI/ +- RFC 6920 `ni:` Named Information URIs; multihash/IPFS CIDs — hash-as-identifier. +- PEP 723 inline script metadata (`# /// script`) — header-config inspiration. +- Tampermonkey `@require`/`@resource` + `@downloadURL`/`@updateURL` — self-hosting + update model this loader mirrors. diff --git a/tampermonkey/refs/phases.md b/tampermonkey/refs/phases.md new file mode 100644 index 0000000..ad69175 --- /dev/null +++ b/tampermonkey/refs/phases.md @@ -0,0 +1,21 @@ +# Userscript phases & lifecycle + +`@run-at` controls when a userscript runs: + +| value | when | +|---|---| +| `document-start` | before any DOM is built; earliest hook (block/patch globals) | +| `document-body` | as soon as `` exists | +| `document-end` | at DOMContentLoaded (DOM ready, subresources maybe not) | +| `document-idle` | after load; default; safest for DOM reads (loader uses this) | +| `context-menu` | only when invoked from the page context menu (where supported) | + +Injection context: managers run scripts in an isolated sandbox; reaching page +globals needs `unsafeWindow` or a `