From 8755298ee9443b9ea1d500d64c595452220b1ca0 Mon Sep 17 00:00:00 2001 From: Shish Date: Mon, 1 Jan 2024 20:15:34 +0000 Subject: [PATCH] [static] add shm_log js function available early in page load --- ext/static_files/init.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ext/static_files/init.js b/ext/static_files/init.js index d45f34e3..5cd4e5f8 100644 --- a/ext/static_files/init.js +++ b/ext/static_files/init.js @@ -4,3 +4,13 @@ function shm_cookie_set(name, value) { function shm_cookie_get(name) { return Cookies.get(name); } + +function shm_log(...message) { + window.dispatchEvent(new CustomEvent("shm_log", {detail: {message: message}})); +} +window.addEventListener("shm_log", function (e) { + console.log(...e.detail.message); +}); +window.addEventListener("error", function (e) { + shm_log("Window error:", e.error); +});