mirror of
https://codeberg.org/Nero/InviTube.git
synced 2024-09-17 09:45:11 +00:00
27 lines
883 B
JavaScript
27 lines
883 B
JavaScript
|
// Save options
|
||
|
document.querySelector("form").addEventListener("submit", (e) => {
|
||
|
e.preventDefault();
|
||
|
let instance = document.querySelector("#instance").value.trim();
|
||
|
instance = instance.replace(/^https?:?\/?\/?/, '').replace('\/$');
|
||
|
proxy = proxy.replace(/^https?:?\/?\/?/, '').replace('\/$');
|
||
|
if (!instance || !proxy) {
|
||
|
return alert("Please fill out the fields!");
|
||
|
}
|
||
|
|
||
|
browser.storage.local.set({
|
||
|
instance: instance,
|
||
|
imageRedirect: document.querySelector("#imageRedirect").checked
|
||
|
}).then(() => alert("Saved!"));
|
||
|
});
|
||
|
|
||
|
|
||
|
// Restore options
|
||
|
document.addEventListener("DOMContentLoaded", () => {
|
||
|
browser.storage.local.get({
|
||
|
imageRedirect: true,
|
||
|
instance: "redirect.invidio.us",
|
||
|
}).then((item) => {
|
||
|
document.querySelector("#instance").value = item.instance;
|
||
|
document.querySelector("#imageRedirect").checked = item.imageRedirect;
|
||
|
});
|
||
|
});
|