Skip to content

Commit

Permalink
Merge pull request #914 from NoPlagiarism/anon_support_sites
Browse files Browse the repository at this point in the history
anonoverflow: support other StackExchange sites
  • Loading branch information
ManeraKai authored Mar 31, 2024
2 parents 8d73647 + 7ae3c03 commit 227888b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ package-lock.json
.vscode
src/pages/options/index.html
src/pages/popup/popup.html
pnpm-lock.yaml
10 changes: 10 additions & 0 deletions src/assets/javascripts/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
Expand Down
5 changes: 3 additions & 2 deletions src/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down

0 comments on commit 227888b

Please sign in to comment.