-
Notifications
You must be signed in to change notification settings - Fork 3
/
options.js
executable file
·116 lines (80 loc) · 3.17 KB
/
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
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
async function get_settings_local()
{
return ( await browser.storage.local.get() ) ;
}
async function get_settings_sync()
{
return ( await browser.storage.sync.get() ) ;
}
document.addEventListener("DOMContentLoaded", async function() {
// kill js referer bug
(async () => {
if ( ( await get_settings_local() ) ['workaround'] === true)
document.getElementById("checkbox-workaround").checked = true;
} ) () ;
(async () => {
document.getElementById("checkbox-workaround").addEventListener("change", async function () {
//console.log("workaround checkbox changed");
await browser.storage.local.set({
"workaround": document.getElementById("checkbox-workaround").checked
});
browser.runtime.sendMessage({
action: "re-globalEnable-if-is-enabled"
});
});
} ) () ;
// ease cpu
(async () => {
if ( ( await get_settings_local() ) ['easycpu'] === true)
document.getElementById("checkbox-easycpu").checked = true;
} ) () ;
(async () => {
document.getElementById("checkbox-easycpu").addEventListener("change", async function () {
//console.log("easycpu checkbox changed");
await browser.storage.local.set({
"easycpu": document.getElementById("checkbox-easycpu").checked
});
browser.runtime.sendMessage({
action: "re-globalEnable-if-is-enabled"
});
});
} ) () ;
// user whitelist
async function load_userWhitelist()
{
const loaded_obj = ( await get_settings_sync() ) ['user_whitelist'] ;
document.getElementById("textarea_userWhitelist").value = JSON.stringify( loaded_obj, null, 2);
}
load_userWhitelist();
(async () => {
document.getElementById("btn_save_userWhitelist").onclick = async function() {
var parsed_obj ;
try{
parsed_obj = JSON.parse( document.getElementById("textarea_userWhitelist").value );
}catch(err) {
alert(err);
}
if (parsed_obj)
{
await browser.storage.sync.set("user_whitelist", parsed_obj);
load_userWhitelist();
}
};
} ) () ;
// build in whitelist
(async () => {
if ( ( await get_settings_sync() ) ['enBuildinWhitelist'] !== false)
document.getElementById("checkbox-enBuildinWhitelist").checked = true;
} ) () ;
(async () => {
document.getElementById("checkbox-enBuildinWhitelist").addEventListener("change", async function () {
await browser.storage.sync.set({
"enBuildinWhitelist": document.getElementById("checkbox-enBuildinWhitelist").checked
});
});
} ) () ;
// show build in whitelist
(async () => {
document.getElementById("textarea_buildinWhitelist").value = JSON.stringify( whitelist , null, 2);
} ) () ;
} ) ;