-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.js
37 lines (34 loc) · 1.2 KB
/
settings.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
const checkboxes = document.querySelectorAll('input[type="checkbox"]');
document.addEventListener('DOMContentLoaded', () => {
chrome.storage.sync.get({
showRottenTomatoesRating: false,
showReleased: false,
showRuntime: false,
showDirector: false,
showWriters: false,
showActors: false,
showCountry: false,
showAwards: false,
showMetascore: false
}, function(items) {
checkboxes.forEach(checkbox => {
checkbox.checked = items[checkbox.id];
});
});
checkboxes.forEach(checkbox => {
checkbox.addEventListener('change', function() {
document.getElementById('statusMessage').classList.add('hidden');
});
});
// Save settings
document.getElementById('saveSettings').addEventListener('click', function() {
document.getElementById('statusMessage').classList.add('hidden');
const settings = {};
checkboxes.forEach(checkbox => {
settings[checkbox.id] = checkbox.checked;
});
chrome.storage.sync.set(settings, function() {
document.getElementById('statusMessage').classList.remove('hidden');
});
});
});