-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.js
38 lines (32 loc) · 859 Bytes
/
popup.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
var sem;
var down;
window.onload = function () {
chrome.runtime.sendMessage({ action: "getState" }, function (response) {
sem = response.sem;
down = response.down;
document.getElementById("sem").checked = response.sem;
document.getElementById("al" + response.down).checked = true;
});
document.getElementById("sem").addEventListener("click", function () {
sem = document.getElementById("sem").checked;
sendMsg();
});
document.getElementsByName("al").forEach((radio) => {
radio.addEventListener("change", function () {
if (radio.checked) {
down = radio.value;
sendMsg();
}
});
});
document.getElementById("link").addEventListener("click",function(e){
e.preventDefault;
});
};
function sendMsg() {
chrome.runtime.sendMessage({
action:"setState",
sem,
down,
});
}