-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathoptions.js
More file actions
122 lines (111 loc) · 2.9 KB
/
options.js
File metadata and controls
122 lines (111 loc) · 2.9 KB
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
var options
function store(optionName, optionValue) {
chrome.runtime.sendMessage({
_setOption: true,
optionName: optionName,
optionValue: optionValue,
})
}
async function restoreDefaults() {
await chrome.runtime.sendMessage({
_restoreDefaults: true,
url: window.location.href,
})
options = await chrome.runtime.sendMessage({
_getOptions: true,
})
filloutOptions()
}
function filloutOptions() {
var optionsIds = [
'iconSize',
'ignore404css',
'ignore404js',
'ignore404others',
'ignoreBlockedByClient',
'ignoreConnectionRefused',
'ignoreConsoleError',
'ignoreExternal',
'includeDomains',
'linkStackOverflow',
// 'linkViewSource',
'notificationIconOpacity',
'popupMaxHeight',
'popupMaxWidth',
'relativeErrorUrl',
'showColumn',
'showIcon',
'hideInPage',
'showPopup',
'showPopupOnMouseOver',
'showTrace',
]
if (options['notificationIconOpacity'] == undefined) {
options['notificationIconOpacity'] = 100
}
for (var i in optionsIds) {
var option = optionsIds[i]
var value = options[option]
var input = document.getElementById(option)
if (option == 'notificationIconOpacity') {
const opacitySlider = document.getElementById('opacityRange')
opacitySlider.value = options[option]
continue
}
if (input.type == 'textarea' || input.type == 'text') {
if (value == undefined) {
value = ''
}
}
if (input.type == 'checkbox') {
if (value) {
input.checked = true
} else {
input.checked = false
}
input.onchange = (function (option) {
return function () {
store(option, this.checked ? 1 : '')
}
})(option)
} else {
input.value = value
input.onkeyup = (function (option) {
return function () {
store(option, this.value)
}
})(option)
}
}
if (options['jscrNotified'] || options['isRecommended']) {
document.getElementById('recommendation').remove()
} else {
var linksIds = ['openRecommendation', 'hideRecommendation']
for (var i in linksIds) {
document.getElementById(linksIds[i]).onclick = function () {
store('isRecommended', 3)
closePopup()
return this.id == 'openRecommendation'
}
}
}
document.getElementById('restore-defaults').onclick = function () {
let result = window.confirm('Reset all options to default?')
if (result) restoreDefaults()
}
}
document.addEventListener('DOMContentLoaded', function () {
;(async () => {
options = await chrome.runtime.sendMessage({
_getOptions: true,
})
filloutOptions()
})()
document.getElementById('close').onclick = function () {
closePopup()
}
var opacitySlider = document.getElementById('opacityRange')
opacitySlider.oninput = function () {
store('notificationIconOpacity', this.value)
}
})