about summary refs log tree commit diff stats
path: root/src/assets/javascripts
diff options
context:
space:
mode:
authorNoPlagiarism <37241775+NoPlagiarism@users.noreply.github.com>2024-03-31 21:00:56 +0500
committerNoPlagiarism <37241775+NoPlagiarism@users.noreply.github.com>2024-03-31 21:00:56 +0500
commit9034a2fb843ec4f341953ee7f398b97eeb2ff2c3 (patch)
treeea55b53ed7c85e7b6d9c1bb189cda6993f0e2332 /src/assets/javascripts
parentMerge branch 'master' of https://github.com/libredirect/browser_extension (diff)
downloadlibredirect-9034a2fb843ec4f341953ee7f398b97eeb2ff2c3.zip
anonoverflow: support other StackExchange sites
Diffstat (limited to 'src/assets/javascripts')
-rw-r--r--src/assets/javascripts/services.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js
index c7f12bc0..640fd8a8 100644
--- a/src/assets/javascripts/services.js
+++ b/src/assets/javascripts/services.js
@@ -309,11 +309,21 @@ function rewrite(url, frontend, randomInstance) {
 				if (threadID) return `${randomInstance}/questions/${threadID[1]}${url.search}`
 				return `${randomInstance}${url.pathname}${url.search}`
 			}
+			if (url.pathname == "/" || url.pathname == "") {
+				// https://stackexchange.com or https://superuser.com
+				return `${randomInstance}${url.pathname}${url.search}`
+			}
 			const regex = url.href.match(/https?:\/{2}(?:([a-zA-Z0-9-]+)\.)?stackexchange\.com\//)
 			if (regex && regex.length > 1) {
 				const subdomain = regex[1]
 				return `${randomInstance}/exchange/${subdomain}${url.pathname}${url.search}`
 			}
+			const notExchangeRegex = url.hostname.match(/(?:[a-zA-Z]+\.)?(?:askubuntu\.com|mathoverflow\.net|serverfault\.com|stackapps\.com|superuser\.com|stackoverflow\.com)/)
+			if (notExchangeRegex) {
+				return `${randomInstance}/exchange/${notExchangeRegex[0]}${url.pathname}${url.search}`
+			}
+			// "Default case"
+			return `${randomInstance}${url.pathname}${url.search}`
 		}
 		case "biblioReads": {
 			return `${randomInstance}${url.pathname}${url.search}`