small tweak
This commit is contained in:
parent
b4e76fc4b6
commit
6df1197bd1
|
@ -180,34 +180,37 @@ async function processCustomInstances(frontend, document) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function createList(frontend, networks, document, redirects, blacklist) {
|
function createList(frontend, networks, document, redirects, blacklist) {
|
||||||
for (const network in networks) {
|
for (const network in networks) {
|
||||||
const checklist = document.getElementById(frontend)
|
const checklist = document.getElementById(frontend)
|
||||||
.getElementsByClassName(network)[0]
|
.getElementsByClassName(network)[0]
|
||||||
.getElementsByClassName("checklist")[0]
|
.getElementsByClassName("checklist")[0]
|
||||||
|
|
||||||
if (!redirects[frontend]) {
|
if (!redirects[frontend]) {
|
||||||
checklist.innerHTML = '<div class="some-block option-block">No instances found.</div>'
|
checklist.innerHTML = '<div class="some-block option-block">No instances found.</div>'
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
const instances = redirects[frontend][network]
|
|
||||||
if (!instances || instances.length === 0) continue
|
|
||||||
|
|
||||||
document.getElementById(frontend)
|
const instances = redirects[frontend][network]
|
||||||
.getElementsByClassName("custom-instance")[0]
|
if (!instances || instances.length === 0) continue
|
||||||
.placeholder = redirects[frontend].clearnet[0]
|
|
||||||
|
|
||||||
const sortedInstances = instances
|
document.getElementById(frontend)
|
||||||
.sort((a, b) => (blacklist.cloudflare.includes(a) && !blacklist.cloudflare.includes(b)))
|
.getElementsByClassName("custom-instance")[0]
|
||||||
|
.placeholder = redirects[frontend].clearnet[0]
|
||||||
|
|
||||||
const content = sortedInstances
|
const sortedInstances = instances
|
||||||
.map(x => {
|
.sort((a, b) => {
|
||||||
const cloudflare = blacklist.cloudflare.includes(x) ?
|
return (blacklist.cloudflare.includes(a) && !blacklist.cloudflare.includes(b))
|
||||||
`<a target="_blank" href="https://libredirect.github.io/docs.html#instances">
|
})
|
||||||
|
|
||||||
|
const content = sortedInstances
|
||||||
|
.map(x => {
|
||||||
|
const cloudflare = blacklist.cloudflare.includes(x) ?
|
||||||
|
`<a target="_blank" href="https://libredirect.github.io/docs.html#instances">
|
||||||
<span style="color:red;">cloudflare</span>
|
<span style="color:red;">cloudflare</span>
|
||||||
</a>` : ""
|
</a>` : ""
|
||||||
|
|
||||||
const warnings = [cloudflare].join(" ")
|
const warnings = [cloudflare].join(" ")
|
||||||
return `<div class="frontend">
|
return `<div class="frontend">
|
||||||
<x>
|
<x>
|
||||||
<a href="${x}" target="_blank">${x}</a>${warnings}
|
<a href="${x}" target="_blank">${x}</a>${warnings}
|
||||||
</x>
|
</x>
|
||||||
|
@ -217,32 +220,27 @@ function createList(frontend, networks, document, redirects, blacklist) {
|
||||||
</svg>
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
</div>`
|
</div>`
|
||||||
})
|
})
|
||||||
|
|
||||||
checklist.innerHTML = [
|
checklist.innerHTML = [
|
||||||
`<div class="some-block option-block">
|
`<div class="some-block option-block">
|
||||||
<h4>${utils.camelCase(network)}</h4>
|
<h4>${utils.camelCase(network)}</h4>
|
||||||
</div>`,
|
</div>`,
|
||||||
...content,
|
...content,
|
||||||
"<br>"
|
"<br>"
|
||||||
].join("\n<hr>\n")
|
].join("\n<hr>\n")
|
||||||
|
|
||||||
for (const instance of instances) {
|
for (const instance of instances) {
|
||||||
checklist.getElementsByClassName(`add-${instance}`)[0]
|
checklist.getElementsByClassName(`add-${instance}`)[0]
|
||||||
.addEventListener("click", async () => {
|
.addEventListener("click", async () => {
|
||||||
let options = await utils.getOptions()
|
let options = await utils.getOptions()
|
||||||
let customInstances = options[frontend]
|
if (!options[frontend].includes(instance)) {
|
||||||
if (!customInstances.includes(instance)) {
|
options[frontend].push(instance)
|
||||||
customInstances.push(instance)
|
browser.storage.local.set({ options }, () => calcCustomInstances(frontend))
|
||||||
options = await utils.getOptions()
|
}
|
||||||
options[frontend] = customInstances
|
})
|
||||||
browser.storage.local.set({options}, () => {
|
}
|
||||||
calcCustomInstances(frontend)
|
}
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const r = window.location.href.match(/#(.*)/)
|
const r = window.location.href.match(/#(.*)/)
|
||||||
|
|
Loading…
Reference in New Issue