mirror of
https://codeberg.org/Nero/InviTube.git
synced 2024-11-22 07:33:41 +00:00
23 lines
No EOL
631 B
JavaScript
23 lines
No EOL
631 B
JavaScript
// Save options
|
|
document.querySelector("form").addEventListener("submit", (e) => {
|
|
e.preventDefault();
|
|
let instance = document.querySelector("#instance").value.trim();
|
|
instance = instance.replace(/^https?:?\/?\/?/, '').replace('\/$');
|
|
if (!instance) {
|
|
return alert("Please fill out the fields!");
|
|
}
|
|
|
|
browser.storage.local.set({
|
|
instance: instance,
|
|
}).then(() => alert("Saved!"));
|
|
});
|
|
|
|
|
|
// Restore options
|
|
document.addEventListener("DOMContentLoaded", () => {
|
|
browser.storage.local.get({
|
|
instance: "yewtu.be",
|
|
}).then((item) => {
|
|
document.querySelector("#instance").value = item.instance;
|
|
});
|
|
}); |