qutebrowser: Extend page redirection

Extended redirection using open source frontends for a variety of
services: youtube, reddit, lbry, twitter, google translate and more.
This commit is contained in:
Marty Oehme 2023-01-16 17:36:14 +01:00
parent bf8d6fb8a3
commit 6a0745dedb
Signed by: Marty
GPG key ID: 73BA40D5AFAF49C9
3 changed files with 212 additions and 38 deletions

View file

@ -45,7 +45,8 @@ c.downloads.location.prompt = False
config.source("alias.py") config.source("alias.py")
config.source("maps.py") config.source("maps.py")
config.source("content.py") config.source("content.py")
config.source("url.py") config.source("searchengines.py")
config.source("redirects.py")
# Tab-Bar # Tab-Bar
# have tab bar on the right, not on the top # have tab bar on the right, not on the top

View file

@ -0,0 +1,209 @@
import random
import re
from qutebrowser.api import interceptor
redirects = {
"youtube": {
"source": ["youtube.com"],
"target": [
"yt.oelrichsgarcia.de",
"vid.priv.au",
"invidious.weblibre.org",
"invidious.dhusch.de",
"iv.ggtyler.dev",
"invidious.baczek.me",
"yt.funami.tech",
"iv.melmac.space",
"invidious.silur.me",
"inv.riverside.rocks",
"invidious.lidarshield.cloud",
"invidious.flokinet.to",
"invidious.snopyta.org",
"invidious.kavin.rocks",
"vid.puffyan.us",
"yt.artemislena.eu",
"invidious.nerdvpn.de",
"invidious.tiekoetter.com",
"invidious.namazso.eu",
"inv.vern.cc",
"yewtu.be",
"inv.bp.projectsegfau.lt",
"invidious.epicsite.xyz",
"y.com.sb",
"invidious.sethforprivacy.com",
],
},
"lbry": {
"source": ["odysee.com"],
"target": [
"lbry.bcow.xyz",
"odysee.076.ne.jp",
"librarian.pussthecat.org",
"lbry.mutahar.rocks",
"librarian.esmailelbob.xyz",
"lbry.vern.cc",
],
},
"reddit": {
"source": ["reddit.com"],
"target": [
"td.vern.cc",
"teddit.adminforge.de",
"teddit.artemislena.eu",
"teddit.bus-hit.me",
"teddit.froth.zone",
"teddit.hostux.net",
"teddit.namazso.eu",
"teddit.net",
"teddit.pussthecat.org",
"teddit.sethforprivacy.com",
"teddit.totaldarkness.net",
"teddit.zaggy.nl",
],
},
"twitter": {
"source": ["twitter.com"],
"target": [
"nitter.net",
"nitter.42l.fr",
"nitter.pussthecat.org",
"nitter.fdn.fr",
"nitter.1d4.us",
"nitter.kavin.rocks",
"nitter.unixfox.eu",
"nitter.namazso.eu",
"nitter.moomoo.me",
"bird.trom.tf",
"nitter.it",
"twitter.censors.us",
"nitter.grimneko.de",
"twitter.076.ne.jp",
"n.l5.ca",
"unofficialbird.com",
"nitter.ungovernable.men",
],
},
"imdb": {
"source": ["imdb.com"],
"target": [
"libremdb.iket.me",
"libremdb.pussthecat.org",
"libremdb.esmailelbob.xyz",
"ld.vern.cc",
"binge.whatever.social",
"libremdb.lunar.icu",
],
},
"translate": {
"source": ["translate.google.com"],
"target": [
"lingva.ml",
"translate.igna.wtf",
"translate.plausibility.cloud",
"translate.projectsegfau.lt",
"translate.dr460nf1r3.org",
"lingva.garudalinux.org",
"translate.jae.fi",
],
},
"tiktok": {
"source": ["tiktok.com"],
"target": [
"proxitok.pabloferreiro.es",
"proxitok.pussthecat.org",
"tok.habedieeh.re",
"proxitok.esmailelbob.xyz",
"proxitok.privacydev.net",
"proxitok.odyssey346.dev",
"tok.artemislena.eu",
"tok.adminforge.de",
"proxitok.manasiwibi.com",
"tik.hostux.net",
"tt.vern.cc",
"proxitok.mha.fi",
"proxitok.pufe.org",
"proxitok.marcopisco.com",
"cringe.whatever.social",
"proxitok.lunar.icu",
],
},
"imgur": {
"source": ["imgur.com"],
"target": [
"rimgo.bcow.xyz",
"rimgo.pussthecat.org",
"rimgo.totaldarkness.net",
"rimgo.bus-hit.me",
"rimgo.esmailelbob.xyz",
"imgur.artemislena.eu",
"rimgo.vern.cc",
"rim.odyssey346.dev",
"rimgo.privacytools.io",
"i.habedieeh.re",
"rimgo.hostux.net",
"ri.zzls.xyz",
"rimgo.marcopisco.com",
"rimgo.lunar.icu",
],
},
"medium": {
"source": ["medium.com"],
"target": [
"scribe.rip",
"scribe.nixnet.services",
"scribe.citizen4.eu",
"scribe.bus-hit.me",
"scribe.froth.zone",
"scribe.esmailelbob.xyz",
"scribe.privacydev.net",
"sc.vern.cc",
],
},
"google": {
"source": ["google.com"],
"target": [
"whoogle.dcs0.hu",
],
},
"wikipedia": {
"source": ["wikipedia.org"],
"target": [
"wiki.adminforge.de",
"wiki.froth.zone",
"wiki.slipfox.xyz",
"wikiless.esmailelbob.xyz",
"wikiless.funami.tech",
"wikiless.northboot.xyz",
"wikiless.org",
"wikiless.tiekoetter.com",
"wl.vern.cc",
],
},
}
def rewrite(request: interceptor.Request):
if (
request.resource_type != interceptor.ResourceType.main_frame
or request.request_url.scheme() in {"data", "blob"}
):
return
url = request.request_url
for service in redirects.values():
matched=False
for source in service["source"]:
if re.search(source, url.host()):
matched=True
if matched:
target = service["target"][random.randint(0, len(service["target"]))]
if target is not None and url.setHost(target) is not False:
try:
request.redirect(url)
except:
pass
break
interceptor.register(rewrite)

View file

@ -1,5 +1,3 @@
from qutebrowser.api import interceptor
c.url.searchengines = { c.url.searchengines = {
"sci": "https://sci-hub.ru/{}", "sci": "https://sci-hub.ru/{}",
"DEFAULT": "https://search.martyoeh.me/?q={}", "DEFAULT": "https://search.martyoeh.me/?q={}",
@ -24,41 +22,7 @@ c.url.searchengines = {
"r": "https://www.reddit.com/r/{}", "r": "https://www.reddit.com/r/{}",
"t": "https://www.thesaurus.com/browse/{}", "t": "https://www.thesaurus.com/browse/{}",
"w": "https://en.wikipedia.org/w/index.php?search={}", "w": "https://en.wikipedia.org/w/index.php?search={}",
"yt": "https://www.youtube.com/results?search_query={}", "yt": "https://invidious.weblibre.org/search?q={}",
} }
c.url.default_page = "https://start.duckduckgo.com" c.url.default_page = "https://start.duckduckgo.com"
c.url.start_pages = ["https://start.duckduckgo.com"] c.url.start_pages = ["https://start.duckduckgo.com"]
redirects = {
"reddit.com": "teddit.net",
"www.reddit.com": "teddit.net",
"youtube.com": "yewtu.be",
"www.youtube.com": "www.yewtu.be",
"twitter.com": "nitter.net",
"www.twitter.com": "nitter.net",
"instagram.com": "bibliogram.art",
"www.instagram.com": "bibliogram.art",
"wikipedia.org": "wikiless.org",
"en.wikipedia.org": "wikiless.org",
"medium.com": "scribe.rip",
}
def rewrite(request: interceptor.Request):
if (
request.resource_type != interceptor.ResourceType.main_frame
or request.request_url.scheme() in {"data", "blob"}
):
return
url = request.request_url
redir = redirects.get(url.host())
if redir is not None and url.setHost(redir) is not False:
try:
request.redirect(url)
except:
pass
interceptor.register(rewrite)