-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.js
36 lines (28 loc) · 861 Bytes
/
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
"use strict";
chrome.storage.sync.get("opening", function(data) {
let now = data.opening;
console.log("state: ", now);
toggle(now);
});
function toggle(opening) {
console.log("toggle: ", opening);
chrome.storage.sync.set({ opening }, function() {
let mm_checkbox = document.getElementById("mm_checkbox");
if (opening) {
mm_checkbox.setAttribute("checked", "checked");
} else {
mm_checkbox.removeAttribute("checked");
}
let mm_msg = document.getElementById("mm_msg");
mm_msg.innerText = opening
? "正在使『Medium』保持安静"
: "正在使『自己』 保持安静";
});
}
let switchBtn = document.getElementById("open_switch");
switchBtn.addEventListener("click", function() {
chrome.storage.sync.get("opening", function(data) {
let now = data.opening;
toggle(!now);
});
});