-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.js
executable file
·45 lines (43 loc) · 1.28 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
document.addEventListener("DOMContentLoaded", function() {
chrome.storage.sync.get(
{
audioUrl: "",
autoPlay: false,
clickMode: "pause",
volume: 1
},
function(items) {
const audioUrl = document.getElementById("audio-url");
audioUrl.value = items.audioUrl;
const autoPlay = document.getElementById("auto-play");
autoPlay.checked = items.autoPlay;
document.getElementById(items.clickMode + "-mode").checked = true;
const volume = document.getElementById("volume");
volume.value = items.volume;
}
);
});
document.getElementById("save").addEventListener("click", function() {
const audioUrl = document.getElementById("audio-url").value;
const autoPlay = document.getElementById("auto-play").checked;
const clickMode = document.getElementById("pause-mode").checked
? "pause"
: "stop";
const volume = document.getElementById("volume").value;
chrome.storage.sync.set(
{
audioUrl: audioUrl,
autoPlay: autoPlay,
clickMode: clickMode,
volume: volume
},
function() {
chrome.runtime.reload();
}
);
});
document
.getElementById("keyboard-shortcuts")
.addEventListener("click", function() {
chrome.tabs.create({ url: "chrome://extensions/configureCommands" });
});