-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.js
30 lines (27 loc) · 928 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
30
// Saves options to chrome.storage
const saveOptions = () => {
const sl = document.getElementById('stringList').value;
chrome.storage.sync.set(
{ stringList: sl},
() => {
// Update status to let user know options were saved.
const status = document.getElementById('status');
status.textContent = 'Options saved.';
setTimeout(() => {
status.textContent = '';
}, 750);
}
);
};
// Restores select box and checkbox state using the preferences
// stored in chrome.storage.
const restoreOptions = () => {
chrome.storage.sync.get(
{ stringList: ''},
(items) => {
document.getElementById('stringList').value = items.stringList;
}
);
};
document.addEventListener('DOMContentLoaded', restoreOptions);
document.getElementById('save').addEventListener('click', saveOptions);