-
Notifications
You must be signed in to change notification settings - Fork 39
/
options.js
29 lines (25 loc) · 992 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
27
28
29
// Saves options to chrome.storage.sync.
function saveOptions() {
chrome.extension.getBackgroundPage().console.log('in save options...');
const reloadPageVal = document.getElementById('reload_page_after_extension_reload').checked;
chrome.storage.sync.set({
'reloadPage': reloadPageVal
}, function () {
// Update status to let user know options were saved.
const statusEl = document.getElementById('status');
statusEl.textContent = 'Options saved.';
setTimeout(function () {
statusEl.textContent = '';
}, 1000);
});
}
// Restores select box and checkbox state using the preferences stored in chrome.storage.
function restoreOptions() {
chrome.storage.sync.get({
'reloadPage': false
}, function (items) {
document.getElementById('reload_page_after_extension_reload').checked = items.reloadPage;
});
}
document.addEventListener('DOMContentLoaded', restoreOptions);
document.getElementById('save').addEventListener('click', saveOptions);