-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathpopup.js
More file actions
21 lines (18 loc) · 821 Bytes
/
popup.js
File metadata and controls
21 lines (18 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// 初始化popup展示
chrome.tabs.query({active: true, currentWindow: true}, function (tabs) {
chrome.tabs.sendMessage(tabs[0].id, {action: "init_switch"}, function(data) {
console.log('init switch', data);
if (data == undefined) {
document.getElementById('desc-extra').innerHTML = '抱歉,在该页面无法获得操作权限';
return;
}
document.getElementById('radio').checked = (data.switch == 1) ? false : true;
});
});
// 点击时设置开关
document.getElementById("radio").onclick = function () {
var switch_opt = document.getElementById('radio').checked;
chrome.tabs.query({active: true, currentWindow: true}, function (tabs){
chrome.tabs.sendMessage(tabs[0].id, {action: "toggle_switch", "switch": switch_opt});
});
}