Fixing bugs. 2.9.1 => 3.0.0

This commit is contained in:
ManeraKai 2024-09-13 21:11:49 +03:00
parent ac5ac2eda9
commit df61cdb265
No known key found for this signature in database
GPG Key ID: 5ABC31FFD562E337
3 changed files with 17 additions and 15 deletions

View File

@ -941,6 +941,7 @@ async function copyRaw(url) {
* @param {URL} url * @param {URL} url
*/ */
function isException(url) { function isException(url) {
if (!options) return false
if (!options.exceptions) return false if (!options.exceptions) return false
let exceptions = options.exceptions let exceptions = options.exceptions
if (exceptions && url) { if (exceptions && url) {

View File

@ -1,7 +1,7 @@
{ {
"name": "__MSG_extensionName__", "name": "__MSG_extensionName__",
"description": "__MSG_extensionDescription__", "description": "__MSG_extensionDescription__",
"version": "2.9.1", "version": "3.0.0",
"manifest_version": 2, "manifest_version": 2,
"browser_specific_settings": { "browser_specific_settings": {
"gecko": { "gecko": {

View File

@ -71,6 +71,7 @@ browser.webRequest.onBeforeRequest.addListener(
(newUrl && newUrl.startsWith("https://no-instance.libredirect.invalid")) || (newUrl && newUrl.startsWith("https://no-instance.libredirect.invalid")) ||
(!newUrl && url.href.startsWith("https://no-instance.libredirect.invalid")) (!newUrl && url.href.startsWith("https://no-instance.libredirect.invalid"))
) { ) {
if (details.type != "main_frame") return null
newUrl = newUrl ? new URL(newUrl) : url newUrl = newUrl ? new URL(newUrl) : url
const frontend = newUrl.searchParams.get("frontend") const frontend = newUrl.searchParams.get("frontend")
const oldUrl = new URL(newUrl.searchParams.get("url")) const oldUrl = new URL(newUrl.searchParams.get("url"))
@ -85,8 +86,8 @@ browser.webRequest.onBeforeRequest.addListener(
return { cancel: true } return { cancel: true }
} }
if (!newUrl) { if (!newUrl && url.href.match(/^https?:\/{2}(.*\.)?libredirect\.invalid.*/)) {
if (url.href.match(/^https?:\/{2}(.*\.)?libredirect\.invalid.*/)) { if (details.type != "main_frame") return null
const params = new URLSearchParams({ const params = new URLSearchParams({
message: "disabled", message: "disabled",
url: url.href, url: url.href,
@ -96,7 +97,6 @@ browser.webRequest.onBeforeRequest.addListener(
}) })
return { cancel: true } return { cancel: true }
} }
}
if (newUrl === "CANCEL") { if (newUrl === "CANCEL") {
console.log(`Cancelling ${url}`) console.log(`Cancelling ${url}`)
@ -121,8 +121,9 @@ browser.webRequest.onHeadersReceived.addListener(
details => { details => {
if (details.statusCode >= 501 || details.statusCode == 429 || details.statusCode == 403) { if (details.statusCode >= 501 || details.statusCode == 429 || details.statusCode == 403) {
const url = new URL(details.url) const url = new URL(details.url)
const { service, frontend } = servicesHelper.computeFrontend(url) const r = servicesHelper.computeFrontend(url)
if (!service) return if (!r) return
const { service, frontend } = r
const params = new URLSearchParams({ const params = new URLSearchParams({
message: "server_error", message: "server_error",
code: details.statusCode, code: details.statusCode,