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

@ -525,7 +525,7 @@ function rewrite(url, originUrl, frontend, randomInstance) {
if (artReg) return `${randomInstance}/post/${artReg[1]}/${artReg[2]}${url.search}`
const userReg = /^\/([^\/]+)$/.exec(url.pathname)
if (userReg)return `${randomInstance}/group_user?q=${userReg[1]}&type=about`
if (userReg) return `${randomInstance}/group_user?q=${userReg[1]}&type=about`
const galleryReg = /^\/(.*?)\/gallery(\/$|$)$/.exec(url.pathname)
if (galleryReg) return `${randomInstance}/group_user?q=${galleryReg[1]}&type=gallery`
@ -941,6 +941,7 @@ async function copyRaw(url) {
* @param {URL} url
*/
function isException(url) {
if (!options) return false
if (!options.exceptions) return false
let exceptions = options.exceptions
if (exceptions && url) {

View File

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

View File

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