-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathoptions.js
More file actions
23 lines (20 loc) · 718 Bytes
/
Copy pathoptions.js
File metadata and controls
23 lines (20 loc) · 718 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"use strict";
function saveOptions(e) {
e.preventDefault();
browser.storage.sync.set({
maps: document.querySelector("#maps").value
});
}
async function restoreOptions() {
try {
const result = await browser.storage.sync.get("maps");
let selectedMaps = result.maps || "osm";
// Pre v3 users may have selected Qwant Maps which no longer exists
if (selectedMaps === "qwant") selectedMaps = "osm";
document.querySelector("#maps").value = selectedMaps;
} catch (error) {
console.log(`Error: ${error}`);
}
}
document.addEventListener("DOMContentLoaded", restoreOptions);
document.querySelector("form").addEventListener("submit", saveOptions);