small UI improvements
This commit is contained in:
parent
1492345b0d
commit
79e134a187
|
@ -71,17 +71,21 @@ browser.webRequest.onBeforeRequest.addListener(
|
||||||
const url = new URL(newUrl)
|
const url = new URL(newUrl)
|
||||||
const frontend = url.searchParams.get("frontend")
|
const frontend = url.searchParams.get("frontend")
|
||||||
const oldUrl = new URL(url.searchParams.get("url"))
|
const oldUrl = new URL(url.searchParams.get("url"))
|
||||||
|
const params = new URLSearchParams({
|
||||||
newUrl = browser.runtime.getURL(
|
message: "no_instance",
|
||||||
`/pages/messages/index.html?message=no_instance&url=${encodeURIComponent(oldUrl)}&frontend=${encodeURIComponent(frontend)}`
|
url: oldUrl,
|
||||||
)
|
frontend: frontend,
|
||||||
|
})
|
||||||
|
newUrl = browser.runtime.getURL(`/pages/messages/index.html?${params.toString()}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!newUrl) {
|
if (!newUrl) {
|
||||||
if (url.href.match(/^https?:\/{2}(.*\.)?libredirect\.invalid.*/)) {
|
if (url.href.match(/^https?:\/{2}(.*\.)?libredirect\.invalid.*/)) {
|
||||||
newUrl = browser.runtime.getURL(
|
const params = new URLSearchParams({
|
||||||
`/pages/messages/index.html?message=disabled&url=${encodeURIComponent(url.href)}`
|
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 url = new URL(details.url)
|
||||||
const { service, frontend } = servicesHelper.computeFrontend(url)
|
const { service, frontend } = servicesHelper.computeFrontend(url)
|
||||||
if (!service) return
|
if (!service) return
|
||||||
|
const params = new URLSearchParams({
|
||||||
|
message: "server_error",
|
||||||
|
code: details.statusCode,
|
||||||
|
url: url.href,
|
||||||
|
frontend: frontend,
|
||||||
|
service: service,
|
||||||
|
})
|
||||||
browser.tabs.update({
|
browser.tabs.update({
|
||||||
url: browser.runtime.getURL(
|
url: browser.runtime.getURL(`/pages/messages/index.html?${params.toString()}`),
|
||||||
`/pages/messages/index.html?message=server_error&code=${details.statusCode}=&url=${encodeURIComponent(url.href)}&frontend=${encodeURIComponent(frontend)}&service=${encodeURIComponent(service)}`
|
|
||||||
),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -112,17 +112,17 @@
|
||||||
|
|
||||||
{#if _options && _config}
|
{#if _options && _config}
|
||||||
<div class="main" dir="auto" {style}>
|
<div class="main" dir="auto" {style}>
|
||||||
{#if window.location.search.includes("message=disabled")}
|
{#if params.get("message") == "disabled"}
|
||||||
<div>
|
<div>
|
||||||
<h1>You disabled redirections for this service</h1>
|
<h1>You disabled redirections for this service</h1>
|
||||||
<Button on:click={enableService}>
|
<Button on:click={enableService}>
|
||||||
{browser.i18n.getMessage("enable") || "Enable"}
|
{browser.i18n.getMessage("enable") || "Enable"}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{:else if window.location.search.includes("message=server_error")}
|
{:else if params.get("message") == "server_error"}
|
||||||
<!-- https://httpstat.us/403 for testing -->
|
<!-- https://httpstat.us/403 for testing -->
|
||||||
<div>
|
<div>
|
||||||
<h1>Your selected instance gave out an error</h1>
|
<h1>Your selected instance gave out an error: {params.get("code")}</h1>
|
||||||
{#if _options[params.get("frontend")].length > 1}
|
{#if _options[params.get("frontend")].length > 1}
|
||||||
<Button on:click={switchInstance}>
|
<Button on:click={switchInstance}>
|
||||||
<SwitchInstanceIcon class="margin margin_{document.body.dir}" />
|
<SwitchInstanceIcon class="margin margin_{document.body.dir}" />
|
||||||
|
@ -147,7 +147,7 @@
|
||||||
</Button>
|
</Button>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{:else if window.location.search.includes("message=no_instance")}
|
{:else if params.get("message") == "no_instance"}
|
||||||
<div>
|
<div>
|
||||||
<h1>You have no instance selected for this frontend</h1>
|
<h1>You have no instance selected for this frontend</h1>
|
||||||
<Button on:click={autoPickInstance} disabled={autoPicking}>
|
<Button on:click={autoPickInstance} disabled={autoPicking}>
|
||||||
|
|
|
@ -51,6 +51,7 @@
|
||||||
window.location.hash = `services:${e.detail.value}`
|
window.location.hash = `services:${e.detail.value}`
|
||||||
hideServiceSelection = false
|
hideServiceSelection = false
|
||||||
}}
|
}}
|
||||||
|
on:pointerup={() => (hideServiceSelection = false)}
|
||||||
on:focus={() => (hideServiceSelection = true)}
|
on:focus={() => (hideServiceSelection = true)}
|
||||||
on:blur={() => (hideServiceSelection = false)}
|
on:blur={() => (hideServiceSelection = false)}
|
||||||
items={[
|
items={[
|
||||||
|
@ -128,6 +129,7 @@
|
||||||
options.set(_options)
|
options.set(_options)
|
||||||
hideFrontendSelection = false
|
hideFrontendSelection = false
|
||||||
}}
|
}}
|
||||||
|
on:pointerup={() => (hideServiceSelection = false)}
|
||||||
on:focus={() => (hideFrontendSelection = true)}
|
on:focus={() => (hideFrontendSelection = true)}
|
||||||
on:blur={() => (hideFrontendSelection = false)}
|
on:blur={() => (hideFrontendSelection = false)}
|
||||||
items={[
|
items={[
|
||||||
|
|
Loading…
Reference in New Issue