22 lines
650 B
JavaScript
22 lines
650 B
JavaScript
/* global chrome, document, URL */
|
|
|
|
const input = document.querySelector("#dockdeck-url");
|
|
const status = document.querySelector("#status");
|
|
|
|
chrome.storage.sync
|
|
.get({ dockdeckUrl: "http://127.0.0.1:1218/" })
|
|
.then(({ dockdeckUrl }) => {
|
|
input.value = dockdeckUrl;
|
|
});
|
|
|
|
document.querySelector("#save").addEventListener("click", async () => {
|
|
try {
|
|
const url = new URL(input.value.trim());
|
|
if (!["http:", "https:"].includes(url.protocol)) throw new Error();
|
|
await chrome.storage.sync.set({ dockdeckUrl: url.href });
|
|
status.textContent = "Saved.";
|
|
} catch {
|
|
status.textContent = "Enter a valid HTTP(S) URL.";
|
|
}
|
|
});
|