fix: scope the export hook to Node, refresh the stale ring comment

The module.exports guard fired on any page whose own scripts define a UMD
module shim — under @grant none the userscript shares page globals, so that
clobbered the page's exports. A typeof window check keeps it to Node.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-28 16:07:42 +07:00
parent b3903440df
commit 8f32062bab
+7 -7
View File
@@ -795,8 +795,8 @@
} }
// Dwell timer: don't advance progress the instant a newer chapter opens (guards // Dwell timer: don't advance progress the instant a newer chapter opens (guards
// against a misclick on "latest chapter"). Arm a 25s timer instead; the countdown // against a misclick on "latest chapter"). Arm a 25s timer instead; the tab fills
// ring around the FAB shows it running. The manual "Update to X" button still fires // bottom-up to show it counting down. The manual "Update to X" button still fires
// immediately. Timer is keyed to the chapter, not the URL, so turning pages within // immediately. Timer is keyed to the chapter, not the URL, so turning pages within
// the same chapter (Demonic /chapter/N/<page>) keeps it counting rather than resetting. // the same chapter (Demonic /chapter/N/<page>) keeps it counting rather than resetting.
const DWELL_MS = 25000; const DWELL_MS = 25000;
@@ -1419,12 +1419,12 @@
// ============================================================ // ============================================================
// Test hook // Test hook
// //
// Node's require() defines `module`; Bromite's native engine, Tampermonkey, // Fires only in Node, where window is undefined. The typeof window check keeps it
// and Violentmonkey do not, so this is inert everywhere the script actually // inert on pages whose own scripts define a UMD module shim — under @grant none
// ships. Exposes pure logic only — see userscript/test/logic.test.js, which // the userscript shares page globals, so we must not clobber the page's exports.
// loads this file with document.body undefined so the UI never boots. // Exposes pure logic only — see userscript/test/logic.test.js.
// ============================================================ // ============================================================
if (typeof module === "object" && module.exports) { if (typeof window === "undefined" && typeof module === "object" && module.exports) {
module.exports = { stripBuildHash, asura, demonic, anchorsFromHTML, statusOf }; module.exports = { stripBuildHash, asura, demonic, anchorsFromHTML, statusOf };
} }