diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index a1935bf..3aba28d 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -617,7 +617,11 @@ function switchInstance(url, customService) { if (customService) { const instancesList = options[options[customService].frontend] 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 { for (const service in config.services) { @@ -630,8 +634,11 @@ function switchInstance(url, customService) { resolve() return } - resolve(`${utils.getNextInstance(url.origin, instancesList)}${url.pathname}${url.search}`) - return + const newInstance = utils.getNextInstance(url.origin, instancesList) + if (newInstance) { + resolve(`${newInstance}${url.pathname}${url.search}`) + return + } } } resolve() diff --git a/src/pages/background/background.js b/src/pages/background/background.js index 9057f64..3df43b5 100644 --- a/src/pages/background/background.js +++ b/src/pages/background/background.js @@ -160,9 +160,7 @@ browser.contextMenus.onClicked.addListener(async (info) => { case 'switchInstanceTab': { const url = new URL(info.pageUrl) const newUrl = await servicesHelper.switchInstance(url) - if (newUrl) { - browser.tabs.update({ url: newUrl }) - } + if (newUrl) browser.tabs.update({ url: newUrl }) return } case 'settingsTab': {