forked from truedread/netflix-1080p
-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathoptions.js
executable file
·50 lines (44 loc) · 2.01 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const use6ChannelsCheckbox = document.getElementById("use-51");
const setMaxBitrateCheckbox = document.getElementById("set-max-bitrate");
const disableVP9Checkbox = document.getElementById("disable-vp9");
const disableAVChighCheckbox = document.getElementById("disable-avchigh");
const showAllSubsCheckbox = document.getElementById("show-all-subs");
const optionsSavedLabel = document.getElementById("options-saved");
function saveOptions() {
const use6Channels = use6ChannelsCheckbox.checked;
const setMaxBitrate = setMaxBitrateCheckbox.checked;
const disableVP9 = disableVP9Checkbox.checked;
const disableAVChigh = disableAVChighCheckbox.checked;
const showAllSubs = showAllSubsCheckbox.checked;
chrome.storage.sync.set({
use6Channels,
setMaxBitrate,
disableVP9,
disableAVChigh,
showAllSubs,
}, function() {
optionsSavedLabel.style.display = "inline-block";
});
}
function restoreOptions() {
chrome.storage.sync.get({
use6Channels: true,
setMaxBitrate: true,
disableVP9: false,
disableAVChigh: false,
showAllSubs: false,
}, function(items) {
use6ChannelsCheckbox.checked = items.use6Channels;
setMaxBitrateCheckbox.checked = items.setMaxBitrate;
disableVP9Checkbox.checked = items.disableVP9;
disableAVChighCheckbox.checked = items.disableAVChigh;
showAllSubsCheckbox.checked = items.showAllSubs;
});
}
document.getElementById("save").addEventListener("click", saveOptions);
use6ChannelsCheckbox.addEventListener("change", () => optionsSavedLabel.style.display = "none");
setMaxBitrateCheckbox.addEventListener("change", () => optionsSavedLabel.style.display = "none");
disableVP9Checkbox.addEventListener("change", () => optionsSavedLabel.style.display = "none");
disableAVChighCheckbox.addEventListener("change", () => optionsSavedLabel.style.display = "none");
showAllSubsCheckbox.addEventListener("change", () => optionsSavedLabel.style.display = "none");
restoreOptions();