-
Notifications
You must be signed in to change notification settings - Fork 2
/
options.js
26 lines (24 loc) · 959 Bytes
/
options.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
function saveOptions(e) {
browser.storage.sync.set({
jsproxy_sandbox_url: document.querySelector("#jsproxy_sandbox_url").value
});
var label = document.createElement("label");
label.innerHTML = "You have set your jsproxy sandbox url!";
document.body.appendChild(label);
e.preventDefault();
}
function restoreOptions() {
var gettingItem = browser.storage.sync.get('jsproxy_sandbox_url');
gettingItem.then((res) => {
if (res.jsproxy_sandbox_url !== "") {
document.querySelector("#jsproxy_sandbox_url").value = res.jsproxy_sandbox_url;
} else {
document.querySelector("#jsproxy_sandbox_url").value = "https://jsproxy1.jimmytinsley.workers.dev/";
browser.storage.sync.set({
jsproxy_sandbox_url: document.querySelector("#jsproxy_sandbox_url").value
});
}
});
}
document.addEventListener('DOMContentLoaded', restoreOptions);
document.querySelector("form").addEventListener("submit", saveOptions);