forked from cilame/v_jstools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
62 lines (57 loc) · 2.19 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
document.querySelectorAll("input").forEach(function(v){
chrome.storage.local.get([v.dataset.key], function (result) {
if (v.type == 'checkbox'){
v.checked = result[v.dataset.key];
}
if (v.type == 'text'){
v.value = result[v.dataset.key] || '';
}
})
v.addEventListener("change", function (e) {
if (v.type == 'checkbox'){
chrome.storage.local.set({
[e.target.dataset.key]: e.target.checked
})
}
if (v.type == 'text'){
chrome.storage.local.set({
[e.target.dataset.key]: e.target.value
})
}
})
})
document.getElementById('showoptions').addEventListener('click', function(e){
function closePopup() {
window.close();
document.body.style.opacity = 0;
setTimeout(function() { history.go(0); }, 300);
}
closePopup()
chrome.tabs.create({
url: chrome.runtime.getURL('options.html')
});
})
document.getElementById('addlistener').addEventListener('click', function(e){
chrome.storage.local.get([ "config-hook-domobj", "config-hook-domobj-get", "config-hook-domobj-set", "config-hook-domobj-func" ], function (result) {
if (!(result["config-hook-domobj"] && result["config-hook-domobj-get"] && result["config-hook-domobj-set"] && result["config-hook-domobj-func"])){
chrome.tabs.query({active: true, currentWindow: true}, function(tabs){
chrome.tabs.sendMessage(tabs[0].id, {action: {type:'alerterror', info: `请在配置页面中将DOM挂钩功能全部选中。
以下四个必选:
是否启用挂钩 DOM 对象的原型的功能调试输出
hook-domobj-显示get输出
hook-domobj-显示set输出
hook-domobj-显示func输出
后面的选项,你也需要全选。`}}, function(response) {});
});
return
}
chrome.tabs.query({active: true, currentWindow: true}, function(tabs){
chrome.tabs.sendMessage(tabs[0].id, {action: {type:'addlistener', info: 'addlistener'}}, function(response) {});
});
})
})
document.getElementById('logtoggle').addEventListener('click', function(e){
chrome.tabs.query({active: true, currentWindow: true}, function(tabs){
chrome.tabs.sendMessage(tabs[0].id, {action: {type:'logtoggle', info: 'logtoggle'}}, function(response) {});
});
})