forked from momosecurity/FindSomething
-
Notifications
You must be signed in to change notification settings - Fork 8
/
settings.js
82 lines (76 loc) · 3.36 KB
/
settings.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
document.getElementById("save").onclick=function () {
let webhook_setting = {};
webhook_setting['url'] = document.getElementById('url').value;
webhook_setting['method'] = document.getElementById('method').value;
webhook_setting['arg'] = document.getElementById('arg').value;
webhook_setting['headers'] = JSON.parse(document.getElementById('headers').value);
// console.log(webhook_setting);
chrome.storage.local.set({"webhook_setting": webhook_setting});
}
document.getElementById("reset").onclick=function () {
let webhook_setting = {"url":"","arg":"","headers":{}};
document.getElementById('url').value = "";
document.getElementById('arg').value = "";
document.getElementById('headers').value = "{}";
// console.log(webhook_setting);
chrome.storage.local.set({"webhook_setting": webhook_setting});
}
document.getElementById("save_allowlist").onclick=function () {
snsArr = document.getElementById('allowlist').value.split(/[(\r\n)\r\n]+/);
snsArr.forEach((item, index)=>{
if(!item){
snsArr.splice(index,1);
}
})
// console.log(snsArr)
chrome.storage.local.set({"allowlist": snsArr});
}
document.getElementById("reset_allowlist").onclick=function () {
document.getElementById('allowlist').value = "";
chrome.storage.local.set({"allowlist": []});
}
document.getElementById("clear_localStorage").onclick=function () {
chrome.storage.local.clear();
console.log("清理完成");
alert("清理完成");
}
document.getElementById("global_float").onclick=function () {
// var webhook_setting = {};
chrome.storage.local.get(["global_float"], function(settings){
// console.log(settings);
chrome.storage.local.set({"global_float": settings["global_float"]==true ? false : true});
document.getElementById('global_float').textContent = settings["global_float"]==true ? "已关闭" : "已打开";
});
// console.log(webhook_setting);
}
document.getElementById("fetch_timeout").onclick=function () {
// var webhook_setting = {};
chrome.storage.local.get(["fetch_timeout"], function(settings){
// console.log(settings);
chrome.storage.local.set({"fetch_timeout": settings["fetch_timeout"]==true ? false : true});
document.getElementById('fetch_timeout').textContent = settings["fetch_timeout"]==true ? "已关闭" : "已打开";
});
// console.log(webhook_setting);
}
chrome.storage.local.get(["webhook_setting"], function(settings){
console.log(settings);
if(!settings || settings == {} || !settings["webhook_setting"] ){
console.log('获取webhook_setting失败');
return;
}
document.getElementById('url').value = settings["webhook_setting"]['url'];
document.getElementById('method').value = settings["webhook_setting"]['method'];
document.getElementById('arg').value = settings["webhook_setting"]['arg'];
document.getElementById('headers').value = JSON.stringify(settings["webhook_setting"]['headers']);
});
chrome.storage.local.get(["global_float"], function(settings){
document.getElementById('global_float').textContent = settings["global_float"]==true ? "已打开" : "已关闭";
});
chrome.storage.local.get(["fetch_timeout"], function(settings){
document.getElementById('fetch_timeout').textContent = settings["fetch_timeout"]==true ? "已打开" : "已关闭";
});
chrome.storage.local.get(["allowlist"], function(allowlist){
if(allowlist && allowlist["allowlist"]){
document.getElementById('allowlist').textContent = allowlist["allowlist"].join('\n');
}
});