diff --git a/docs/superpowers/specs/2026-06-15-tampermonkey-script-loader-design.md b/docs/superpowers/specs/2026-06-15-tampermonkey-script-loader-design.md index 032c9fd..81ddc64 100644 --- a/docs/superpowers/specs/2026-06-15-tampermonkey-script-loader-design.md +++ b/docs/superpowers/specs/2026-06-15-tampermonkey-script-loader-design.md @@ -199,6 +199,12 @@ the *inclusion* mechanics through the console first. the version/update report; sign it (age / gpg) so a relayed/"gossiped" update notice is verifiable against the registry pubkey. Needs dev signing keys (generate; cache/store the *public* half in-source, never the private). +- **Content detection** to refine matching — beyond `match` globs, detect a wiki/app + at runtime (e.g. MediaWiki via `mw`/`mw.config`, ``, + `/w/api.php`) so an entry auto-loads on *any* MediaWiki without enumerating + domains, and the coarse `*/wiki/*` catch-all stops false-positiving on non-MW + sites that happen to use a `/wiki/` path. Schema would gain an optional `detect` + hook; matching becomes "glob match AND (no detector OR detector passes)". - SRI *enforcement by default*; GitHub-API auto-discovery; the cross-repo "suggest diff-bump" tooling (mw roadmap); storage-size limiting (§5). diff --git a/tampermonkey/registry.embedded.js b/tampermonkey/registry.embedded.js index a744368..4b1bca4 100644 --- a/tampermonkey/registry.embedded.js +++ b/tampermonkey/registry.embedded.js @@ -5,10 +5,23 @@ const EMBEDDED_REGISTRY_JSON = [ "repo": "mcint/userscripts", "path": "mw/nav-popups/popups.js", "ref": "main", - "match": ["*://*.wikipedia.org/*"], + "match": [ + "*://*.wikipedia.org/*", + "*://*.wiktionary.org/*", + "*://*.wikimedia.org/*", + "*://*.wikidata.org/*", + "*://*.wikisource.org/*", + "*://*.wikibooks.org/*", + "*://*.wikiquote.org/*", + "*://*.wikinews.org/*", + "*://*.wikiversity.org/*", + "*://*.wikivoyage.org/*", + "*://*.mediawiki.org/*", + "*://*/wiki/*" + ], "runAt": "document-idle", "grant": [], "integrity": null, - "desc": "Wikipedia hover previews (maintained fork)" + "desc": "Navigation popups (maintained fork) — MediaWiki hover previews. Matches Wikimedia family by domain + any */wiki/* path (coarse; content-detection planned)." } ]; diff --git a/tampermonkey/registry.json b/tampermonkey/registry.json index 2994bb7..e123b8b 100644 --- a/tampermonkey/registry.json +++ b/tampermonkey/registry.json @@ -5,10 +5,23 @@ "repo": "mcint/userscripts", "path": "mw/nav-popups/popups.js", "ref": "main", - "match": ["*://*.wikipedia.org/*"], + "match": [ + "*://*.wikipedia.org/*", + "*://*.wiktionary.org/*", + "*://*.wikimedia.org/*", + "*://*.wikidata.org/*", + "*://*.wikisource.org/*", + "*://*.wikibooks.org/*", + "*://*.wikiquote.org/*", + "*://*.wikinews.org/*", + "*://*.wikiversity.org/*", + "*://*.wikivoyage.org/*", + "*://*.mediawiki.org/*", + "*://*/wiki/*" + ], "runAt": "document-idle", "grant": [], "integrity": null, - "desc": "Wikipedia hover previews (maintained fork)" + "desc": "Navigation popups (maintained fork) — MediaWiki hover previews. Matches Wikimedia family by domain + any */wiki/* path (coarse; content-detection planned)." } ] diff --git a/tampermonkey/test/nav-popups-match.test.js b/tampermonkey/test/nav-popups-match.test.js new file mode 100644 index 0000000..c68f304 --- /dev/null +++ b/tampermonkey/test/nav-popups-match.test.js @@ -0,0 +1,29 @@ +const test = require('node:test'); +const assert = require('node:assert'); +const fs = require('node:fs'); +const path = require('node:path'); +const L = require('../loader.user.js'); + +function navPopups() { + const text = fs.readFileSync(path.join(__dirname, '..', 'registry.json'), 'utf8'); + return L.parseRegistry(text).find((e) => e.id === 'nav-popups'); +} + +test('nav-popups matches Wikimedia by domain — incl. non-/wiki/ paths', () => { + const m = navPopups().match; + assert.ok(L.matchUrl(m, 'https://en.wikipedia.org/wiki/Cat')); + assert.ok(L.matchUrl(m, 'https://en.wikipedia.org/w/index.php?title=Cat&action=history')); + assert.ok(L.matchUrl(m, 'https://en.wiktionary.org/wiki/cat')); + assert.ok(L.matchUrl(m, 'https://www.mediawiki.org/wiki/Manual:Contents')); +}); + +test('nav-popups matches self-hosted MediaWiki by /wiki/ path catch-all', () => { + const m = navPopups().match; + assert.ok(L.matchUrl(m, 'https://some-wiki.example.org/wiki/Page')); +}); + +test('nav-popups does not match non-wiki pages', () => { + const m = navPopups().match; + assert.strictEqual(L.matchUrl(m, 'https://example.com/'), false); + assert.strictEqual(L.matchUrl(m, 'https://github.com/mcint/userscripts'), false); +});