This commit is contained in:
ManeraKai 2024-01-08 23:58:18 +03:00
parent b79a485f61
commit cfa6c887f1
No known key found for this signature in database
GPG Key ID: 5ABC31FFD562E337
2 changed files with 11 additions and 6 deletions

View File

@ -617,7 +617,11 @@ function switchInstance(url, customService) {
if (customService) { if (customService) {
const instancesList = options[options[customService].frontend] const instancesList = options[options[customService].frontend]
if (instancesList !== undefined) { if (instancesList !== undefined) {
resolve(`${utils.getNextInstance(url.origin, instancesList)}${url.pathname}${url.search}`) const newInstance = utils.getNextInstance(url.origin, instancesList)
if (newInstance) {
resolve(`${newInstance}${url.pathname}${url.search}`)
return
}
} }
} else { } else {
for (const service in config.services) { for (const service in config.services) {
@ -630,8 +634,11 @@ function switchInstance(url, customService) {
resolve() resolve()
return return
} }
resolve(`${utils.getNextInstance(url.origin, instancesList)}${url.pathname}${url.search}`) const newInstance = utils.getNextInstance(url.origin, instancesList)
return if (newInstance) {
resolve(`${newInstance}${url.pathname}${url.search}`)
return
}
} }
} }
resolve() resolve()

View File

@ -160,9 +160,7 @@ browser.contextMenus.onClicked.addListener(async (info) => {
case 'switchInstanceTab': { case 'switchInstanceTab': {
const url = new URL(info.pageUrl) const url = new URL(info.pageUrl)
const newUrl = await servicesHelper.switchInstance(url) const newUrl = await servicesHelper.switchInstance(url)
if (newUrl) { if (newUrl) browser.tabs.update({ url: newUrl })
browser.tabs.update({ url: newUrl })
}
return return
} }
case 'settingsTab': { case 'settingsTab': {