small tweak

This commit is contained in:
ManeraKai 2023-02-14 20:03:06 +03:00
parent b4e76fc4b6
commit 6df1197bd1
No known key found for this signature in database
GPG Key ID: 5ABC31FFD562E337
1 changed files with 41 additions and 43 deletions

View File

@ -189,6 +189,7 @@ function createList(frontend, networks, document, redirects, blacklist) {
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] const instances = redirects[frontend][network]
if (!instances || instances.length === 0) continue if (!instances || instances.length === 0) continue
@ -197,7 +198,9 @@ function createList(frontend, networks, document, redirects, blacklist) {
.placeholder = redirects[frontend].clearnet[0] .placeholder = redirects[frontend].clearnet[0]
const sortedInstances = instances const sortedInstances = instances
.sort((a, b) => (blacklist.cloudflare.includes(a) && !blacklist.cloudflare.includes(b))) .sort((a, b) => {
return (blacklist.cloudflare.includes(a) && !blacklist.cloudflare.includes(b))
})
const content = sortedInstances const content = sortedInstances
.map(x => { .map(x => {
@ -231,14 +234,9 @@ function createList(frontend, networks, document, redirects, blacklist) {
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)
})
} }
}) })
} }