From d5465699e86b6e3cc7f9a1f7d4805ed8735565e5 Mon Sep 17 00:00:00 2001 From: jojobii-arks Date: Mon, 13 Nov 2023 10:47:49 -0800 Subject: [PATCH] feat: input prefill with location hash --- src/front/cobalt.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/front/cobalt.js b/src/front/cobalt.js index 4a3ad9e6..31761c28 100644 --- a/src/front/cobalt.js +++ b/src/front/cobalt.js @@ -607,10 +607,24 @@ window.onload = () => { detectColorScheme(); popup("migration", 1); } + + if (window.location.hash) { + const input = window.location.hash.slice(1); + eid("url-input-area").value = input; + button() + } + window.history.replaceState(null, '', window.location.pathname); notificationCheck(); } +window.onhashchange = () => { + if (window.location.hash) { + const input = window.location.hash.slice(1); + eid("url-input-area").value = input; + button() + } +} eid("url-input-area").addEventListener("keydown", (e) => { button(); })