-
Notifications
You must be signed in to change notification settings - Fork 3
/
popup.js
31 lines (28 loc) · 1.14 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
let form = document.getElementById("redirectList")
chrome.storage.local.get("hardRedirectorList", (localRedirectList) => {
localRedirectList.hardRedirectorList.forEach(rule => {
let input = document.createElement("input")
input.setAttribute("type", "checkbox")
input.setAttribute("id", rule.id)
input.setAttribute("name", rule.from)
input.setAttribute("value", rule.to)
let label = document.createElement("label")
label.setAttribute("for", rule.id)
label.appendChild(document.createTextNode(rule.label))
let br = document.createElement("br")
form.appendChild(input)
input.onclick = function () { handleChange(input, localRedirectList) }
form.appendChild(label)
form.appendChild(br)
document.getElementById(rule.id).checked = rule.enabled
})
});
function handleChange(input, localRedirectList) {
let lrl = localRedirectList.hardRedirectorList
for (let i = 0; i < lrl.length; i++) {
if (lrl[i].id == input.id) {
lrl[i].enabled = !lrl[i].enabled
}
}
chrome.storage.local.set({ hardRedirectorList: lrl })
}