From 8f32062babb0d968ce55602a991431b96d8a06c8 Mon Sep 17 00:00:00 2001 From: Sulthan Zaki Date: Tue, 28 Jul 2026 16:07:42 +0700 Subject: [PATCH] fix: scope the export hook to Node, refresh the stale ring comment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- userscript/manga-bookmark.user.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/userscript/manga-bookmark.user.js b/userscript/manga-bookmark.user.js index 5be6f6c..d598fcb 100644 --- a/userscript/manga-bookmark.user.js +++ b/userscript/manga-bookmark.user.js @@ -795,8 +795,8 @@ } // 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 - // ring around the FAB shows it running. The manual "Update to X" button still fires + // against a misclick on "latest chapter"). Arm a 25s timer instead; the tab fills + // 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 // the same chapter (Demonic /chapter/N/) keeps it counting rather than resetting. const DWELL_MS = 25000; @@ -1419,12 +1419,12 @@ // ============================================================ // 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. + // Fires only in Node, where window is undefined. The typeof window check keeps it + // inert on pages whose own scripts define a UMD module shim — under @grant none + // the userscript shares page globals, so we must not clobber the page's exports. + // 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 }; }