diff --git a/src/pages/background/background.js b/src/pages/background/background.js index 2bb6cb5..0d558b0 100644 --- a/src/pages/background/background.js +++ b/src/pages/background/background.js @@ -71,17 +71,21 @@ browser.webRequest.onBeforeRequest.addListener( const url = new URL(newUrl) const frontend = url.searchParams.get("frontend") const oldUrl = new URL(url.searchParams.get("url")) - - newUrl = browser.runtime.getURL( - `/pages/messages/index.html?message=no_instance&url=${encodeURIComponent(oldUrl)}&frontend=${encodeURIComponent(frontend)}` - ) + const params = new URLSearchParams({ + message: "no_instance", + url: oldUrl, + frontend: frontend, + }) + newUrl = browser.runtime.getURL(`/pages/messages/index.html?${params.toString()}`) } if (!newUrl) { if (url.href.match(/^https?:\/{2}(.*\.)?libredirect\.invalid.*/)) { - newUrl = browser.runtime.getURL( - `/pages/messages/index.html?message=disabled&url=${encodeURIComponent(url.href)}` - ) + const params = new URLSearchParams({ + message: "disabled", + url: url.href, + }) + newUrl = browser.runtime.getURL(`/pages/messages/index.html?${params.toString()}`) } } @@ -110,10 +114,15 @@ browser.webRequest.onHeadersReceived.addListener( const url = new URL(details.url) const { service, frontend } = servicesHelper.computeFrontend(url) if (!service) return + const params = new URLSearchParams({ + message: "server_error", + code: details.statusCode, + url: url.href, + frontend: frontend, + service: service, + }) browser.tabs.update({ - url: browser.runtime.getURL( - `/pages/messages/index.html?message=server_error&code=${details.statusCode}=&url=${encodeURIComponent(url.href)}&frontend=${encodeURIComponent(frontend)}&service=${encodeURIComponent(service)}` - ), + url: browser.runtime.getURL(`/pages/messages/index.html?${params.toString()}`), }) } }, diff --git a/src/pages/messages_src/App.svelte b/src/pages/messages_src/App.svelte index 05a7804..6d68ff5 100644 --- a/src/pages/messages_src/App.svelte +++ b/src/pages/messages_src/App.svelte @@ -112,17 +112,17 @@ {#if _options && _config}
- {#if window.location.search.includes("message=disabled")} + {#if params.get("message") == "disabled"}

You disabled redirections for this service

- {:else if window.location.search.includes("message=server_error")} + {:else if params.get("message") == "server_error"}
-

Your selected instance gave out an error

+

Your selected instance gave out an error: {params.get("code")}

{#if _options[params.get("frontend")].length > 1} {/if}
- {:else if window.location.search.includes("message=no_instance")} + {:else if params.get("message") == "no_instance"}

You have no instance selected for this frontend