aboutsummaryrefslogtreecommitdiffstats
path: root/src/pages/background
diff options
context:
space:
mode:
authorManeraKai <manerakai@protonmail.com>2024-08-31 11:47:11 +0300
committerManeraKai <manerakai@protonmail.com>2024-08-31 11:47:11 +0300
commit79e134a1873e6897107b1f2acb4437030cea2425 (patch)
tree7f82cdca70c45b5f7d122a20d481ca2f089ad6ea /src/pages/background
parentAdded message popup for Server Errors https://github.com/libredirect/browser_... (diff)
downloadlibredirect-79e134a1873e6897107b1f2acb4437030cea2425.zip
small UI improvements
Diffstat (limited to 'src/pages/background')
-rw-r--r--src/pages/background/background.js29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/pages/background/background.js b/src/pages/background/background.js
index 2bb6cb57..0d558b01 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()}`),
})
}
},