small fix
This commit is contained in:
parent
e8a67e9172
commit
84e863c477
|
@ -376,32 +376,41 @@ function redirect(url, type, initiator) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function computeService(url, returnFrontend) {
|
function computeService(url, returnFrontend) {
|
||||||
fetch("/config/config.json")
|
return new Promise(resolve => {
|
||||||
.then(response => response.text())
|
fetch("/config/config.json")
|
||||||
.then(configData => {
|
.then(response => response.text())
|
||||||
const config = JSON.parse(configData)
|
.then(configData => {
|
||||||
browser.storage.local.get(["redirects", "options"], r => {
|
const config = JSON.parse(configData)
|
||||||
const redirects = r.redirects
|
browser.storage.local.get(["redirects", "options"], r => {
|
||||||
const options = r.options
|
const redirects = r.redirects
|
||||||
for (const service in config.services) {
|
const options = r.options
|
||||||
if (regexArray(service, url, config)) {
|
for (const service in config.services) {
|
||||||
if (returnFrontend) return [service, null]
|
if (regexArray(service, url, config)) {
|
||||||
else return service
|
if (returnFrontend) {
|
||||||
} else {
|
resolve([service, null])
|
||||||
for (const frontend in config.services[service].frontends) {
|
} else {
|
||||||
if (all(service, frontend, options, config, redirects).includes(utils.protocolHost(url))) {
|
resolve(service)
|
||||||
if (returnFrontend) {
|
}
|
||||||
return [service, frontend]
|
return
|
||||||
} else return service
|
} else {
|
||||||
|
for (const frontend in config.services[service].frontends) {
|
||||||
|
if (all(service, frontend, options, config, redirects).includes(utils.protocolHost(url))) {
|
||||||
|
if (returnFrontend) {
|
||||||
|
resolve([service, frontend])
|
||||||
|
} else {
|
||||||
|
resolve(service)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
// if (returnFrontend) return [null, null]
|
||||||
// if (returnFrontend) return [null, null]
|
// else return null
|
||||||
// else return null
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function switchInstance(url) {
|
async function switchInstance(url) {
|
||||||
|
|
|
@ -58,7 +58,7 @@ const currentSiteIsFrontend = document.getElementById("current_site_divider")
|
||||||
|
|
||||||
browser.storage.local.get("options", r => {
|
browser.storage.local.get("options", r => {
|
||||||
browser.tabs.query({ active: true, currentWindow: true }, async tabs => {
|
browser.tabs.query({ active: true, currentWindow: true }, async tabs => {
|
||||||
for (const service in config.services) {
|
for (const service in config.services) {
|
||||||
if (!r.options.popupServices.includes(service)) allSites.getElementsByClassName(service)[0].classList.add("hide")
|
if (!r.options.popupServices.includes(service)) allSites.getElementsByClassName(service)[0].classList.add("hide")
|
||||||
else allSites.getElementsByClassName(service)[0].classList.remove("hide")
|
else allSites.getElementsByClassName(service)[0].classList.remove("hide")
|
||||||
currSite.getElementsByClassName(service)[0].classList.add("hide")
|
currSite.getElementsByClassName(service)[0].classList.add("hide")
|
||||||
|
|
Loading…
Reference in New Issue