-
Notifications
You must be signed in to change notification settings - Fork 3
/
options.js
41 lines (34 loc) · 1.72 KB
/
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const defaultActionInput = document.getElementById("defaultActionInput")
const ignorePinnedTabsInput = document.getElementById("ignorePinnedTabsInput")
const ignorePopupWindowsInput = document.getElementById("ignorePopupWindowsInput")
const ignoreAppWindowsInput = document.getElementById("ignoreAppWindowsInput")
const showDefaultActionPopupInput = document.getElementById("showDefaultActionPopupInput")
ALL_ACTIONS.forEach(action => {
var opt = document.createElement("option");
opt.value = action.id;
opt.innerHTML = action.title;
defaultActionInput.appendChild(opt);
})
getOptions().then(options => {
defaultActionInput.value = options.defaultAction
ignorePinnedTabsInput.checked = options.ignorePinnedTabs
ignorePopupWindowsInput.checked = options.ignorePopupWindows
ignoreAppWindowsInput.checked = options.ignoreAppWindows
showDefaultActionPopupInput.checked = options.showDefaultActionPopup
})
defaultActionInput.addEventListener('change', () => {
chrome.storage.sync.set({ defaultAction: defaultActionInput.value })
});
ignorePinnedTabsInput.addEventListener('change', () => {
chrome.storage.sync.set({ ignorePinnedTabs: ignorePinnedTabsInput.checked })
});
ignorePopupWindowsInput.addEventListener('change', () => {
chrome.storage.sync.set({ ignorePopupWindows: ignorePopupWindowsInput.checked })
});
ignoreAppWindowsInput.addEventListener('change', () => {
chrome.storage.sync.set({ ignoreAppWindows: ignoreAppWindowsInput.checked })
});
showDefaultActionPopupInput.addEventListener('change', () => {
chrome.storage.sync.set({ showDefaultActionPopup: showDefaultActionPopupInput.checked })
chrome.action.setPopup({ popup: showDefaultActionPopupInput.checked ? "popup.html" : "" })
});