aboutsummaryrefslogtreecommitdiff
path: root/options.js
diff options
context:
space:
mode:
Diffstat (limited to 'options.js')
-rw-r--r--options.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/options.js b/options.js
new file mode 100644
index 0000000..1848954
--- /dev/null
+++ b/options.js
@@ -0,0 +1,20 @@
+function saveOptions(e) {
+ e.preventDefault();
+ browser.storage.sync.set({
+ rb: document.querySelector("#rb").value,
+ tr: document.querySelector("#tr").value
+ });
+}
+function restoreOptions() {
+ function setCurrentChoice(result) {
+ document.querySelector("#rb").value = result.rb || "";
+ document.querySelector("#tr").value = result.tr || "";
+ }
+ function onError(error) {
+ console.log(`Error: ${error}`);
+ }
+ let getting = browser.storage.sync.get(["rb", "tr"]);
+ getting.then(setCurrentChoice, onError);
+}
+document.addEventListener("DOMContentLoaded", restoreOptions);
+document.querySelector("form").addEventListener("submit", saveOptions);