mirror of
https://codeberg.org/Nero/InviTube.git
synced 2024-10-02 01:02:41 +00:00
29 lines
761 B
JavaScript
29 lines
761 B
JavaScript
// Restore options
|
|
document.addEventListener("DOMContentLoaded", () => {
|
|
browser.storage.local.get({
|
|
instance: "yewtu.be",
|
|
}).then((storage) => {
|
|
document.querySelector("#instance").value = storage.instance;
|
|
});
|
|
});
|
|
|
|
// Save options
|
|
const saveBtn = document.getElementById("saveBtn");
|
|
|
|
saveBtn.addEventListener("click", (e) => {
|
|
e.preventDefault();
|
|
const instance = document.querySelector("#instance").value.trim().replace(/^https?:\/\/*|\/$/g, '');
|
|
if (!instance) return alert("Please fill out the fields!");
|
|
|
|
browser.storage.local.set({
|
|
instance,
|
|
}).then(() => {
|
|
saveBtn.disabled = true;
|
|
saveBtn.value = "Saved!";
|
|
setTimeout(() => {
|
|
saveBtn.disabled = false;
|
|
saveBtn.value = "Save";
|
|
}, 3000)
|
|
});
|
|
});
|
|
|