From 617b0da8840e2ffb8c19cc339ff90048c9c7ec15 Mon Sep 17 00:00:00 2001 From: Brian <18603393+brian6932@users.noreply.github.com> Date: Mon, 6 Feb 2023 01:59:40 -0500 Subject: [PATCH 1/2] services: Fix `anonymousOverflow` redirect --- src/assets/javascripts/services.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index 6e2eca1..0aac546 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -367,7 +367,7 @@ function redirect(url, type, initiator, forceRedirection) { if (url.hostname.match(/^[a-zA-Z0-9-]+\.(?:fandom|wikia)\.com/)) { wiki = url.hostname.match(/^[a-zA-Z0-9-]+(?=\.(?:fandom|wikia)\.com)/) if (wiki == "www" || !wiki) wiki = "" - else wiki = `/${wiki}`; + else wiki = `/${wiki}` urlpath = url.pathname } else { wiki = url.pathname.match(/(?<=wiki\/w:c:)[a-zA-Z0-9-]+(?=:)/) @@ -406,9 +406,9 @@ function redirect(url, type, initiator, forceRedirection) { case "neuters": { const p = url.pathname if (p.startsWith('/article/') || p.startsWith('/pf/') || p.startsWith('/arc/') || p.startsWith('/resizer/')) { - return null; + return null } - return `${randomInstance}${p}`; + return `${randomInstance}${p}` } case "dumb": { if (url.pathname.endsWith('-lyrics')) return `${randomInstance}${url.pathname}` @@ -419,7 +419,8 @@ function redirect(url, type, initiator, forceRedirection) { } case "anonymousOverflow": { if (!url.pathname.startsWith('/questions') && url.pathname != '/') return - return `${randomInstance}${url.pathname}${url.search}` + const threadID = /\/\d+(?=[?&#/]|$)/.exec(url.pathname)?.[0] + return `${randomInstance}${threadID ? '/questions' + threadID : url.pathname}${url.search}` } case "biblioReads": { if (!url.pathname.startsWith('/book/show/') && url.pathname != '/') return From 5f45e0b09cc24ff3c3559f763e221b7557e4b48b Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Mon, 6 Feb 2023 18:05:15 +0300 Subject: [PATCH 2/2] Fixed AnonymousOverflow answers linking problem https://github.com/libredirect/libredirect/pull/619. Fixed Freetube https://github.com/libredirect/libredirect/issues/621 --- src/assets/javascripts/services.js | 20 +++++++++++--------- src/manifest.json | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index 0aac546..f3fcfa0 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -59,16 +59,16 @@ function redirect(url, type, initiator, forceRedirection) { continue } - if ( - initiator - && - options[frontend].includes(initiator.origin) - ) return "BYPASSTAB" - let instanceList = options[frontend] if (instanceList === undefined) break if (instanceList.length === 0) return + if ( + initiator + && + instanceList.includes(initiator.origin) + ) return "BYPASSTAB" + randomInstance = utils.getRandomInstance(instanceList) break @@ -414,13 +414,15 @@ function redirect(url, type, initiator, forceRedirection) { if (url.pathname.endsWith('-lyrics')) return `${randomInstance}${url.pathname}` } case "ruralDictionary": { - if (!url.pathname.endsWith('/define.php') && !url.pathname.endsWith('/random.php') && url.pathname != '/') return + if (!url.pathname.includes('/define.php') && !url.pathname.includes('/random.php') && url.pathname != '/') return return `${randomInstance}${url.pathname}${url.search}` } case "anonymousOverflow": { if (!url.pathname.startsWith('/questions') && url.pathname != '/') return - const threadID = /\/\d+(?=[?&#/]|$)/.exec(url.pathname)?.[0] - return `${randomInstance}${threadID ? '/questions' + threadID : url.pathname}${url.search}` + const threadID = /\/(\d+)\/?$/.exec(url.pathname) + if (threadID) return `${randomInstance}/questions/${threadID[1]}${url.search}` + return `${randomInstance}${url.pathname}${url.search}` + } case "biblioReads": { if (!url.pathname.startsWith('/book/show/') && url.pathname != '/') return diff --git a/src/manifest.json b/src/manifest.json index 4ca1d05..2b51953 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,7 +1,7 @@ { "name": "__MSG_extensionName__", "description": "__MSG_extensionDescription__", - "version": "2.5.1", + "version": "2.5.2", "manifest_version": 2, "browser_specific_settings": { "gecko": {