This commit is contained in:
ManeraKai 2024-09-14 18:36:33 +03:00
parent d13715e83f
commit 94cb2e45de
No known key found for this signature in database
GPG Key ID: 5ABC31FFD562E337
1 changed files with 23 additions and 23 deletions

View File

@ -117,29 +117,29 @@ browser.webRequest.onBeforeRequest.addListener(
["blocking"]
)
browser.webRequest.onHeadersReceived.addListener(
details => {
if (details.statusCode >= 501 || details.statusCode == 429 || details.statusCode == 403) {
const url = new URL(details.url)
const r = servicesHelper.computeFrontend(url)
if (!r) return
const { service, frontend } = r
const params = new URLSearchParams({
message: "server_error",
code: details.statusCode,
url: url.href,
frontend: frontend,
service: service,
})
setTimeout(() => {
browser.tabs.update({
url: browser.runtime.getURL(`/pages/messages/index.html?${params.toString()}`),
})
}, 2000)
}
},
{ urls: ["<all_urls>"] }
)
// browser.webRequest.onHeadersReceived.addListener(
// details => {
// if (details.statusCode >= 501 || details.statusCode == 429 || details.statusCode == 403) {
// const url = new URL(details.url)
// const r = servicesHelper.computeFrontend(url)
// if (!r) return
// const { service, frontend } = r
// const params = new URLSearchParams({
// message: "server_error",
// code: details.statusCode,
// url: url.href,
// frontend: frontend,
// service: service,
// })
// setTimeout(() => {
// browser.tabs.update({
// url: browser.runtime.getURL(`/pages/messages/index.html?${params.toString()}`),
// })
// }, 2000)
// }
// },
// { urls: ["<all_urls>"] }
// )
browser.tabs.onRemoved.addListener(tabId => {
if (tabIdRedirects[tabId] != undefined) {