diff options
author | ManeraKai <manerakai@protonmail.com> | 2024-08-29 13:36:21 +0300 |
---|---|---|
committer | ManeraKai <manerakai@protonmail.com> | 2024-08-29 13:36:21 +0300 |
commit | 97d390737e7e953fe1e6559e41963c547b31afa0 (patch) | |
tree | fff6e211ba49d82825eb250b4b9507929537e950 /src/pages/background/background.js | |
parent | Added Auto Pick Instance https://github.com/libredirect/browser_extension/iss... (diff) | |
download | libredirect-97d390737e7e953fe1e6559e41963c547b31afa0.zip |
Improving popup messages
Diffstat (limited to 'src/pages/background/background.js')
-rw-r--r-- | src/pages/background/background.js | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/pages/background/background.js b/src/pages/background/background.js index f41cb55e..db7ad087 100644 --- a/src/pages/background/background.js +++ b/src/pages/background/background.js @@ -67,10 +67,25 @@ browser.webRequest.onBeforeRequest.addListener( tabIdRedirects[details.tabId] ) + if (newUrl && newUrl.startsWith("https://no-instance.libredirect.invalid")) { + const url = new URL(newUrl) + const frontend = url.searchParams.get("frontend") + const oldUrl = new URL(url.searchParams.get("url")) + + browser.tabs.update({ + url: browser.runtime.getURL( + `/pages/messages/index.html?message=no_instance&url=${encodeURIComponent(oldUrl)}&frontend=${encodeURIComponent(frontend)}` + ), + }) + } + if (!newUrl) { - const match = url.href.match(/^https?:\/{2}(.*\.)?libredirect\.invalid.*/) - if (match) { - browser.tabs.update({ url: browser.runtime.getURL(`/pages/messages/no_instance.html`) }) + if (url.href.match(/^https?:\/{2}(.*\.)?libredirect\.invalid.*/)) { + browser.tabs.update({ + url: browser.runtime.getURL( + `/pages/messages/index.html?message=disabled&url=${encodeURIComponent(url.href)}` + ), + }) } } |