anonoverflow: support other StackExchange sites

This commit is contained in:
NoPlagiarism 2024-03-31 21:00:56 +05:00
parent 8d73647ab9
commit 9034a2fb84
2 changed files with 13 additions and 2 deletions

View File

@ -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}`

View File

@ -663,8 +663,9 @@
}
},
"targets": [
"^https?:\\/{2}(www\\.)?stackoverflow\\.com\\/",
"^https?:\\/{2}([a-zA-Z0-9-]+\\.)?stackexchange\\.com\\/"
"^https?:\\/{2}(www\\.)?([a-zA-Z]+\\.)?stackoverflow\\.com\\/",
"^https?:\\/{2}([a-zA-Z0-9-]+\\.)?stackexchange\\.com\\/",
"^https?:\\/{2}(www\\.)?([a-zA-Z]+\\.)?(askubuntu\\.com|mathoverflow\\.net|serverfault\\.com|stackapps\\.com|superuser\\.com)\\/"
],
"name": "Stack Overflow",
"options": {