diff options
author | ManeraKai <manerakai@protonmail.com> | 2024-03-31 17:10:23 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-31 17:10:23 +0000 |
commit | 227888b637d0bc91201ce66c96d3acd120876487 (patch) | |
tree | ef082797cb3c188058ba741d1a5e231283029bc5 | |
parent | Merge branch 'master' of https://github.com/libredirect/browser_extension (diff) | |
parent | git: add pnpm-lock to .gitignore (diff) | |
download | libredirect-227888b637d0bc91201ce66c96d3acd120876487.zip |
Merge pull request #914 from NoPlagiarism/anon_support_sites
anonoverflow: support other StackExchange sites
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | src/assets/javascripts/services.js | 10 | ||||
-rw-r--r-- | src/config.json | 5 |
3 files changed, 14 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore index 44170d13..b1b53216 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ package-lock.json .vscode src/pages/options/index.html src/pages/popup/popup.html +pnpm-lock.yaml 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}` diff --git a/src/config.json b/src/config.json index 4288d2db..fbb2ddc2 100644 --- a/src/config.json +++ b/src/config.json @@ -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": { |