fix(userscript): move boot after TEMPLATE/CSS consts to avoid TDZ crash
init() ran at line 514 (document.body exists at @run-at document-idle), but buildUI() reads the TEMPLATE/CSS consts declared lower in the IIFE. Accessing them before initialization threw ReferenceError: Cannot access 'CSS' before initialization, so the script died before mounting the FAB and no UI appeared in Cromite. Move the boot invocation to the end of the IIFE, after both consts are initialized. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -511,9 +511,6 @@
|
||||
refresh().then(() => maybeAutoUpdate()); // sync, then auto-record this page
|
||||
}
|
||||
|
||||
if (document.body) init();
|
||||
else document.addEventListener("DOMContentLoaded", init);
|
||||
|
||||
// ============================================================
|
||||
// Markup + styles (kept at bottom for readability)
|
||||
// ============================================================
|
||||
@@ -598,4 +595,13 @@
|
||||
.toast.show { opacity: 1; transform: translateY(0); }
|
||||
.toast.err { background: #7f1d1d; }
|
||||
`;
|
||||
|
||||
// ============================================================
|
||||
// Boot — MUST run last: init() -> buildUI() reads TEMPLATE/CSS,
|
||||
// which are const (TDZ) and only initialized above. At
|
||||
// @run-at document-idle document.body already exists, so init()
|
||||
// fires synchronously here, after the consts are set.
|
||||
// ============================================================
|
||||
if (document.body) init();
|
||||
else document.addEventListener("DOMContentLoaded", init);
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user