-
Notifications
You must be signed in to change notification settings - Fork 16
/
options.js
22 lines (20 loc) · 945 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
function saveOptions(e) {
e.preventDefault();
browser.storage.sync.set({
showTabContextMenuCopyUrls: document.querySelector("#showTabContextMenuCopyUrls").checked,
openUrlsAlreadyOpened: document.querySelector("#openUrlsAlreadyOpened").checked,
});
browser.runtime.sendMessage({});
}
function restoreOptions() {
browser.storage.sync.get().then(settings => {
let showContextMenu = ('showTabContextMenuCopyUrls' in settings) ? settings.showTabContextMenuCopyUrls : true;
let openTabs = ('openUrlsAlreadyOpened' in settings) ? settings.openUrlsAlreadyOpened : false;
document.querySelector("#showTabContextMenuCopyUrls").checked = showContextMenu;
document.querySelector("#openUrlsAlreadyOpened").checked = openTabs;
}, error => {
console.log(`Error: ${error}`);
});
}
document.addEventListener("DOMContentLoaded", restoreOptions);
document.querySelector("form").addEventListener("submit", saveOptions);