Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
RustomDuck committed Feb 5, 2023
1 parent 786c94b commit 48c884f
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 19 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,20 @@ A web extension that redirects YouTube, Twitter, TikTok... requests to alternati
- Youtube Music <span>&#8594;</span> [Beatbump](https://github.com/snuffyDev/Beatbump), [Hyperpipe](https://codeberg.org/Hyperpipe/Hyperpipe)
- Twitter <span>&#8594;</span> [Nitter](https://github.com/zedeus/nitter)
- TikTok <span>&#8594;</span> [ProxiTok](https://github.com/pablouser1/ProxiTok)
- Reddit <span>&#8594;</span> [Libreddit](https://github.com/spikecodes/libreddit#instances), [Teddit](https://codeberg.org/teddit/teddit#instances)
- Reddit <span>&#8594;</span> [Libreddit](https://github.com/spikecodes/libreddit), [Teddit](https://codeberg.org/teddit/teddit)
- Imgur <span>&#8594;</span> [Rimgo](https://codeberg.org/video-prize-ranch/rimgo)
- Reuters <span>&#8594;</span> [Neuters](https://github.com/HookedBehemoth/neuters)
- Medium <span>&#8594;</span> [Scribe](https://sr.ht/~edwardloveall/Scribe/)
- Medium <span>&#8594;</span> [Scribe](https://sr.ht/~edwardloveall/Scribe/), [LibMedium](https://github.com/realaravinth/libmedium)
- Quora <span>&#8594;</span> [Quetre](https://github.com/zyachel/quetre)
- IMDb <span>&#8594;</span> [libremdb](https://github.com/zyachel/libremdb)
- LBRY/Odysee <span>&#8594;</span> [Librarian](https://codeberg.org/librarian/librarian), [LBRY Desktop](https://lbry.com/get)
- Search <span>&#8594;</span> [SearXNG](https://github.com/searxng/searxng), [SearX](https://searx.github.io/searx/), [Whoogle](https://benbusby.com/projects/whoogle-search/), [LibreX](https://github.com/hnhx/librex/)
- Translate <span>&#8594;</span> [SimplyTranslate](https://git.sr.ht/~metalune/simplytranslate_web), [LingvaTranslate](https://github.com/TheDavidDelta/lingva-translate), [LibreTranslate](https://github.com/LibreTranslate/LibreTranslate)
- Google Maps <span>&#8594;</span> [OpenStreetMap](https://www.openstreetmap.org/), [FacilMap](https://github.com/FacilMap/facilmap)
- Send Files <span>&#8594;</span> [Send](https://gitlab.com/timvisee/send)
- Genius <span>&#8594;</span> [Dumb](https://github.com/rramiachraf/dumb)
- StackOverflow <span>&#8594;</span> [AnonymousOverflow](https://github.com/httpjamesm/AnonymousOverflow)
- Goodreads <span>&#8594;</span> [BiblioReads](https://github.com/nesaku/BiblioReads)

**Note**: The Extension will be using random instances by default. You can modify this and add custom instances too.

Expand Down
55 changes: 38 additions & 17 deletions src/assets/javascripts/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,31 +89,37 @@ function redirect(url, type, initiator, forceRedirection) {
}
return [zoom, lon, lat]
}

if (!frontend) return

switch (frontend) {
// This is where all instance-specific code must be ran to convert the service url to one that can be understood by the frontend.
case "beatbump":
case "beatbump": {
return `${randomInstance}${url.pathname}${url.search}`
.replace("/watch?v=", "/listen?id=")
.replace("/channel/", "/artist/")
.replace("/playlist?list=", "/playlist/VL")
.replace(/\/search\?q=.*/, searchQuery => searchQuery.replace("?q=", "/") + "?filter=all")
case "hyperpipe":
}
case "hyperpipe": {
return `${randomInstance}${url.pathname}${url.search}`.replace(/\/search\?q=.*/, searchQuery => searchQuery.replace("?q=", "/"))
case "lbryDesktop":
}
case "lbryDesktop": {
return url.href.replace(/^https?:\/{2}odysee\.com\//, "lbry://").replace(/:(?=[a-zA-Z0-9])/g, "#")
}
case "searx":
case "searxng":
return `${randomInstance}/${url.search}`
case "whoogle":
case "whoogle": {
return `${randomInstance}/search${url.search}`
case "librex":
}
case "librex": {
return `${randomInstance}/search.php${url.search}`
case "send":
}
case "send": {
return randomInstance
case "nitter":
}
case "nitter": {
let search = new URLSearchParams(url.search)

search.delete("ref_src")
Expand All @@ -135,17 +141,22 @@ function redirect(url, type, initiator, forceRedirection) {
if (url.pathname.split("/").includes("tweets")) return `${randomInstance}${url.pathname.replace("/tweets", "")}${search}`
if (url.host == "t.co") return `${randomInstance}/t.co${url.pathname}`
return `${randomInstance}${url.pathname}${search}#m`
case "yattee":
}
case "yattee": {
return url.href.replace(/^https?:\/{2}/, "yattee://")
case "freetube":
}
case "freetube": {
return `freetube://https://youtu.be${url.pathname}${url.search}`.replace(/watch\?v=/, "")
case "simplyTranslate":
}
case "simplyTranslate": {
return `${randomInstance}/${url.search}`
case "libreTranslate":
}
case "libreTranslate": {
return `${randomInstance}/${url.search}`
.replace(/(?<=\/?)sl/, "source")
.replace(/(?<=&)tl/, "target")
.replace(/(?<=&)text/, "q")
}
case "osm": {
if (initiator && initiator.host === "earth.google.com") return
const travelModes = {
Expand Down Expand Up @@ -338,7 +349,7 @@ function redirect(url, type, initiator, forceRedirection) {
if (query) return `${randomInstance}/${mapCentre}/Mpnk/${query}`
}
}
case "lingva":
case "lingva": {
let params_arr = url.search.split("&")
params_arr[0] = params_arr[0].substring(1)
let params = {}
Expand All @@ -350,7 +361,8 @@ function redirect(url, type, initiator, forceRedirection) {
return `${randomInstance}/${params.sl}/${params.tl}/${params.text}`
}
return randomInstance
case "breezeWiki":
}
case "breezeWiki": {
let wiki, urlpath = ""
if (url.hostname.match(/^[a-zA-Z0-9-]+\.(?:fandom|wikia)\.com/)) {
wiki = url.hostname.match(/^[a-zA-Z0-9-]+(?=\.(?:fandom|wikia)\.com)/)
Expand All @@ -367,10 +379,12 @@ function redirect(url, type, initiator, forceRedirection) {
}
if (url.href.search(/Special:Search\?query/) > -1) return `${randomInstance}${wiki}${urlpath}${url.search}`.replace(/Special:Search\?query/, "search?q").replace(/\/wiki/, "")
else return `${randomInstance}${wiki}${urlpath}${url.search}`
case "rimgo":
}
case "rimgo": {
if (url.href.search(/^https?:\/{2}(?:[im]\.)?stack\./) > -1) return `${randomInstance}/stack${url.pathname}${url.search}`
else return `${randomInstance}${url.pathname}${url.search}`
case "libreddit":
}
case "libreddit": {
const subdomain = url.hostname.match(/^(?:(?:external-)?preview|i)(?=\.redd\.it)/)
if (!subdomain) return `${randomInstance}${url.pathname}${url.search}`
switch (subdomain[0]) {
Expand All @@ -381,12 +395,14 @@ function redirect(url, type, initiator, forceRedirection) {
case "i":
return `${randomInstance}/img${url.pathname}`
}
case "teddit":
}
case "teddit": {
if (/^(?:(?:external-)?preview|i)\.redd\.it/.test(url.hostname)) {
if (url.search == "") return `${randomInstance}${url.pathname}?teddit_proxy=${url.hostname}`
else return `${randomInstance}${url.pathname}${url.search}&teddit_proxy=${url.hostname}`
}
return `${randomInstance}${url.pathname}${url.search}`
}
case "neuters": {
const p = url.pathname
if (p.startsWith('/article/') || p.startsWith('/pf/') || p.startsWith('/arc/') || p.startsWith('/resizer/')) {
Expand All @@ -405,6 +421,10 @@ function redirect(url, type, initiator, forceRedirection) {
if (!url.pathname.startsWith('/questions') && url.pathname != '/') return
return `${randomInstance}${url.pathname}${url.search}`
}
case "biblioReads": {
if (!url.pathname.startsWith('/book/show/') && url.pathname != '/') return
return `${randomInstance}${url.pathname}${url.search}`
}
default:
return `${randomInstance}${url.pathname}${url.search}`
}
Expand Down Expand Up @@ -547,6 +567,7 @@ function initDefaults() {
options['dumb'] = ['https://dm.vern.cc']
options['ruralDictionary'] = ['https://rd.vern.cc']
options['anonymousOverflow'] = ['https://code.whatever.social']
options['biblioReads'] = ['https://biblioreads.ml']

browser.storage.local.set({ options },
() => resolve()
Expand Down
19 changes: 19 additions & 0 deletions src/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,25 @@
"imageType": "svgMono",
"embeddable": false,
"url": "https://stackoverflow.com/"
},
"goodReads": {
"frontends": {
"biblioReads": {
"name": "goodReads",
"instanceList": true,
"url": "https://github.com/nesaku/BiblioReads"
}
},
"targets": [
"^https?:\\/{2}(www\\.)?goodreads\\.com\\/"
],
"name": "Goodreads",
"options": {
"enabled": false
},
"imageType": "svg",
"embeddable": false,
"url": "https://goodreads.com/"
}
}
}

0 comments on commit 48c884f

Please sign in to comment.