From 4534193cf59f8667b61eb5c881c9f77acbbcca26 Mon Sep 17 00:00:00 2001 From: liooil Date: Sun, 8 Dec 2024 12:24:27 +0800 Subject: [PATCH] feat: match localhost and fix bool --- evolve-helper.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/evolve-helper.js b/evolve-helper.js index 386647a..ece6e01 100644 --- a/evolve-helper.js +++ b/evolve-helper.js @@ -7,6 +7,7 @@ // @author liooil // @homepage https://xiteng.site/git/liooil/evolve-helper // @match https://pmotschmann.github.io/Evolve/ +// @match http://localhost/Evolve/dist/ // @icon https://www.google.com/s2/favicons?sz=64&domain=github.io // @updateURL https://xiteng.site/git/liooil/evolve-helper/raw/branch/main/evolve-helper.js // @downloadURL https://xiteng.site/git/liooil/evolve-helper/raw/branch/main/evolve-helper.js @@ -61,7 +62,7 @@ function auto() { if (getBool("autoAll")) { for (const node of document.querySelectorAll("div.action.vb")) { if (node.classList.contains("cna")) continue; - const a = el.querySelector("a.button"); + const a = node.querySelector("a.button"); if (a) a.click(); } } @@ -152,18 +153,22 @@ function setBool(key, val) { */ function menuBtn(nextElementSibling, id, type, defaultVal, cb) { if (document.getElementById(id)) return; + const getVal = () => { + if (type === "bool") return getBool(id) ?? defaultVal; + else return getInt(id) ?? defaultVal; + }; const el = document.createElement("span"); el.id = id; el.classList.add("version"); el.style.cursor = "pointer"; - el.textContent = `${id}=${getInt(id) ?? defaultVal}`; + el.textContent = `${id}=${getVal()}`; el.onclick = () => { let val; if (type === "bool") { - val = !(getBool(id) ?? defaultVal); + val = !(getVal()); setBool(id, val); } else { - let input = prompt(`${id}=`, `${getInt(id) ?? defaultVal}`); + let input = prompt(`${id}=`, `${getVal()}`); if (input === null) return; val = parseInt(input) setInt(id, input);