-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconfig.js
47 lines (42 loc) · 1.78 KB
/
config.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
42
43
44
45
46
47
document.addEventListener('DOMContentLoaded', () => {
var container = document.getElementById('container'),
announcement = document.getElementById('announcement'),
acceptanceRate = document.getElementById('acceptanceRate'),
difficulty = document.getElementById('difficulty'),
lockedQuestions = document.getElementById('lockedQuestions');
chrome.storage.sync.get('lc_options', (options) => {
var opts = options['lc_options'];
if (opts === undefined) {
opts = {
announcement: false,
acceptanceRate: false,
difficulty: false,
lockedQuestions: false,
resultCountNode: true,
resultCount: 0,
solvedDifficultyCounts: false
};
chrome.storage.sync.set({lc_options: opts});
}
announcement.checked = opts.announcement;
acceptanceRate.checked = opts.acceptanceRate;
difficulty.checked = opts.difficulty;
lockedQuestions.checked = opts.lockedQuestions;
resultCountNode.checked = opts.resultCountNode;
solvedDifficultyCounts.checked = opts.solvedDifficultyCounts;
});
container.addEventListener('change', () => {
var options = {
announcement: announcement.checked,
acceptanceRate: acceptanceRate.checked,
difficulty: difficulty.checked,
lockedQuestions: lockedQuestions.checked,
resultCountNode: resultCountNode.checked,
solvedDifficultyCounts: solvedDifficultyCounts.checked
};
chrome.tabs.getSelected(null, function(tab) {
chrome.tabs.sendMessage(tab.id, options, null, null);
});
chrome.storage.sync.set({lc_options: options});
});
});