-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.js
35 lines (32 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
30
31
32
33
34
35
/* global chrome: false */
/* eslint-env browser */
/** Loads options from chrome.storage. */
function loadOptions() {
chrome.storage.sync.get(
{
work: '',
always: '',
},
(items) => {
document.getElementById('work').value = items.work;
document.getElementById('always').value = items.always;
},
);
}
/** Saves options to chrome.storage. */
function saveOptions() {
// No validation--this is just for my own use.
const work = document.getElementById('work').value;
const always = document.getElementById('always').value;
chrome.storage.sync.set(
{ work, always },
() => {
// Update status to let user know options were saved.
const status = document.getElementById('status');
status.textContent = 'saved!';
setTimeout(() => { status.textContent = ''; }, 750);
},
);
}
document.addEventListener('DOMContentLoaded', loadOptions);
document.getElementById('save').addEventListener('click', saveOptions);