aboutsummaryrefslogtreecommitdiffstats
path: root/src/assets
diff options
context:
space:
mode:
authorManeraKai <manerakai@protonmail.com>2023-02-06 18:05:28 +0300
committerManeraKai <manerakai@protonmail.com>2023-02-06 18:05:28 +0300
commit6c94617ff26c7f9b4da150b53d5800acd9815a83 (patch)
treeb4ba94947dc8bbb29df5f6fddc0d4e67f10d1c1e /src/assets
parentMerge pull request #618 from kirizdev/master (diff)
parentFixed AnonymousOverflow answers linking problem https://github.com/libredirec... (diff)
downloadlibredirect-6c94617ff26c7f9b4da150b53d5800acd9815a83.zip
Merge branch 'brian6932-anonymousoverflow-redirect-fix'
Diffstat (limited to 'src/assets')
-rw-r--r--src/assets/javascripts/services.js21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js
index 6e2eca13..f3fcfa0d 100644
--- a/src/assets/javascripts/services.js
+++ b/src/assets/javascripts/services.js
@@ -59,16 +59,16 @@ function redirect(url, type, initiator, forceRedirection) {
continue
}
+ let instanceList = options[frontend]
+ if (instanceList === undefined) break
+ if (instanceList.length === 0) return
+
if (
initiator
&&
- options[frontend].includes(initiator.origin)
+ instanceList.includes(initiator.origin)
) return "BYPASSTAB"
- let instanceList = options[frontend]
- if (instanceList === undefined) break
- if (instanceList.length === 0) return
-
randomInstance = utils.getRandomInstance(instanceList)
break
@@ -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,20 +406,23 @@ 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}`
}
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)
+ 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