-
Notifications
You must be signed in to change notification settings - Fork 1
/
options.js
124 lines (118 loc) · 8.85 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
const getObjectFromLocalStorage = async function (key) {
return new Promise((resolve, reject) => {
try {
chrome.storage.sync.get(key, function (value) {
resolve(value[key]);
});
} catch (ex) {
reject(ex);
}
});
};
const saveObjectInStorage = async function (obj) {
return new Promise((resolve, reject) => {
try {
chrome.storage.sync.set(obj, function () {
resolve();
});
} catch (ex) {
reject(ex);
}
});
};
document.getElementById("saveConfigs").addEventListener(
"click",
async function (e) {
if (document.getElementById("textareaConfigs").value) {
try {
let jsonConfigs = JSON.parse(
document.getElementById("textareaConfigs").value
);
await saveObjectInStorage({ configs: jsonConfigs });
alert("Configs are saved.");
} catch (error) {
alert(error.message);
}
}
},
false
);
(async function () {
// set sample on #textareaSample
document.getElementById("textareaSample").innerHTML = JSON.stringify(
getDefaultConfigs(),
null,
2
);
// get configs from storage
let configs = await getObjectFromLocalStorage("configs");
if (configs) {
// set user's configs on #textareaConfigs
return (document.getElementById("textareaConfigs").innerHTML =
JSON.stringify(configs, null, 2));
}
// save & set default configs on #textareaConfigs
configs = getDefaultConfigs();
await saveObjectInStorage({ configs: configs });
return (document.getElementById("textareaConfigs").innerHTML = JSON.stringify(
configs,
null,
2
));
})();
function getDefaultConfigs() {
return [
{
name: "localhost",
alert: false,
favicon: false,
style: {
backgroundColor: "rgba(48,209,88,0.5)",
},
url: "^https?://(127.0.0.1|localhost):(.+83|8080)",
},
{
name: "development",
alert: false,
favicon: false,
style: {
backgroundColor: "rgba(10,132,255,0.5)",
},
url: "^https?://dev-.+-admin.+",
},
{
name: "staging",
alert: false,
favicon: {
rel: "shortcut icon",
type: "image/x-icon",
href: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAJZlWElmTU0AKgAAAAgABQESAAMAAAABAAEAAAEaAAUAAAABAAAASgEbAAUAAAABAAAAUgExAAIAAAARAAAAWodpAAQAAAABAAAAbAAAAAAAAABgAAAAAQAAAGAAAAABd3d3Lmlua3NjYXBlLm9yZwAAAAOgAQADAAAAAQABAACgAgAEAAAAAQAAACCgAwAEAAAAAQAAACAAAAAAs9pmNgAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAi1pVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDYuMC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIgogICAgICAgICAgICB4bWxuczp0aWZmPSJodHRwOi8vbnMuYWRvYmUuY29tL3RpZmYvMS4wLyI+CiAgICAgICAgIDx4bXA6Q3JlYXRvclRvb2w+d3d3Lmlua3NjYXBlLm9yZzwveG1wOkNyZWF0b3JUb29sPgogICAgICAgICA8dGlmZjpZUmVzb2x1dGlvbj45NjwvdGlmZjpZUmVzb2x1dGlvbj4KICAgICAgICAgPHRpZmY6T3JpZW50YXRpb24+MTwvdGlmZjpPcmllbnRhdGlvbj4KICAgICAgICAgPHRpZmY6WFJlc29sdXRpb24+OTY8L3RpZmY6WFJlc29sdXRpb24+CiAgIC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awu/W2OACvk8eE3nwhPdGmRFCGu41Ij6JOqgBZwBFgrTBgSxgARTlmD1Vebyt4+ogEP916g5rOw0E7pKZTdAAAKEbXkTx7xJ9xKGDYI4RFmLzY9VB1HODoqXH8Q/90pJFnRdOHfiH1WES0bkmJ1abhCblnBqAMDMICJmNzc9q8Ux0HROrZvth9W1fd8SCMe0aPyMPIiJEhLT5bPMATMtaSFpWw5j4VsPSoOw5sXs9lgbPHDw79lzPLb44HRl2n0qpEMV3h7SAJBRE7lSRBfhPnnKMsiMZYdFGi2DRtGR+Wkx//nXEmGUgfHCJ/h86eyA0/OAWc3AL6/9XldZ78FuT2iqIEOZ7rCjh4P+Wk2uDbGbcunz6itPUrdTQ4hTvdMybkpeQocfmX2+LJF/9irB+/OCiOPTYs2j5VfU8rVksxjYmj+BH32CfXwK2yB0cqtWgP4zYJdL0dYAiHdtsBOjMwTSLDYoebyJiETRUhlaUW6bcANxP5V+af0o66FOIm9TlNNkw/LjXWWTp+dCS/3Ec2RtPjEfrxceeJ899zZzLKTEs8tzc37pK1QxFS/90+C5xLcv1kbZTJAsoGgudotqPfxPSJqyxX775AqokD0pIXzXr7nL2/XEb/7jvABLVU1S6TnK31M1ZSE5cwlvgKqp1L6DfeqlG7nhb0fNzvQUV50Tn6UR2XkLk6wv1mzuFnnJ1jM5/PWPVD+1StdmCAM8gh7VKs11dk7bfVGP8RYPo/MitQTKGXdb0AAAAASUVORK5CYII=",
},
style: {
backgroundColor: "rgba(255,214,10,0.5)",
},
url: "^https?://[^/]*stage-admin.+|^https?://admin-.+stage.+|^https?://stg-admin.+",
},
{
name: "production",
alert: false,
favicon: {
rel: "shortcut icon",
type: "image/x-icon",
href: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAJZlWElmTU0AKgAAAAgABQESAAMAAAABAAEAAAEaAAUAAAABAAAASgEbAAUAAAABAAAAUgExAAIAAAARAAAAWodpAAQAAAABAAAAb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aJFoBQ74XtTGZZ791A7yHvLLUrmyAvGiWJa7EtG4NHPy1RJ2zmgmGoSIvJYHDLrt9hvX/WP2gM7emLx1+SkYhbnC1pLDh83ljSAEYacVKv/0HJn34g/fJ3JH6/QpTMdPVGHYREWrpC14dByN0+FwJCKgDa0nt4dFLDKSfU+2ib3rdAsDcYFUiW2f8CJV58DrpQDSR5mRcwabU6obSINzx8Ip8J9H7mlt63DLd3gpCYH39BtU+/hBWuByuN+1P4NTKlVScMYyu88Dp/4zrhp4R56NDapln5LTewLlUq16RZXBCphN459lx8oP/u1sdp5sQpiifSlJ4YJ/HTZaI+HJBBvBUNVjzXIyOVkvFsn5CuWxa2vREKOecLg7VgTuTX5FKou6z3eoLTrtuO2EAiSerVK5T59htSVJ3ElV+IWA07Gfe3GhASdSIaN2w1mUx7UnKdGBNzIyNPxoTyfWJtvzc7M6/Y0Pl4V+YHe2O/gTBi5iaMQpbvG4SF24SBpyEM2DnpcYNS+TznroJd7tDI8SYSa3NUt2zofVVh13vdcpsX4haEW97/IB6AxkH5XXUOAIO8fJhpGjUvkslAqRoTGoDtdFDKq+Wqahi61HCiWnS/Tw/fXtcfGYgQ82LV5rMRjhDUrDfUiGF4eHhGw+ufNaFsW7MuhwTnUnf3GzYoIUwK/jMzjVMsHZyfK3yezGY36dEIU1hwvO5Ow3bxD15g478ibIdalgp79gzmNmxgP92TJi5c+Ms3xEXonljsYIRt/wPhVd3UKpqdLwAAAABJRU5ErkJggg==",
},
style: {
backgroundColor: "rgba(255,69,58,0.5)",
},
url: "^https?://[^/]*admin.+",
},
{
name: "repositories",
alert: false,
style: {
background: "linear-gradient(to right, rgba(255,214,10,0.5), rgba(255,69,58,0.5))",
},
url: "^https://github.com/pj8/(peacekeeper|Pj8.SentryModule|sssh|dbdb|ms-teams-notify-orb|github-backlog-sync|vscode-twig-goto|vscode-bear-goto|image)",
},
];
}