test: zero-dependency harness for userscript adapter logic

Loads the IIFE in bare Node behind a minimal localStorage/document stub, with
document.body left undefined so the boot block defers and the UI never builds.
Adds a module.exports hook that is inert in every real userscript engine.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-28 15:26:50 +07:00
parent 206c447f36
commit 383dbaa7eb
2 changed files with 198 additions and 0 deletions
+12
View File
@@ -1357,6 +1357,18 @@
.toast.err { background: #7f1d1d; }
`;
// ============================================================
// Test hook
//
// Node's require() defines `module`; Bromite's native engine, Tampermonkey,
// and Violentmonkey do not, so this is inert everywhere the script actually
// ships. Exposes pure logic only — see userscript/test/logic.test.js, which
// loads this file with document.body undefined so the UI never boots.
// ============================================================
if (typeof module === "object" && module.exports) {
module.exports = { stripBuildHash, asura, demonic, anchorsFromHTML, statusOf };
}
// ============================================================
// Boot — MUST run last: init() -> buildUI() reads TEMPLATE/CSS,
// which are const (TDZ) and only initialized above. At