2021-02-10 00:11:23 +00:00
|
|
|
from qutebrowser.api import interceptor
|
2022-03-09 19:13:21 +00:00
|
|
|
from urllib.parse import urljoin
|
2023-04-08 19:28:19 +00:00
|
|
|
from PyQt6.QtCore import QUrl
|
2022-01-12 23:02:54 +00:00
|
|
|
import operator
|
2021-02-10 00:11:23 +00:00
|
|
|
|
2021-02-03 03:20:48 +00:00
|
|
|
o = operator.methodcaller
|
|
|
|
s = 'setHost'
|
2021-02-10 00:11:23 +00:00
|
|
|
|
2022-03-09 19:13:21 +00:00
|
|
|
def farside(url: QUrl, i) -> bool:
|
|
|
|
url.setHost('farside.link')
|
|
|
|
p = url.path().strip('/')
|
|
|
|
url.setPath(urljoin(i, p))
|
|
|
|
return True
|
|
|
|
|
2024-01-31 14:57:59 +00:00
|
|
|
def twitter(url: QUrl) -> bool:
|
2022-03-09 19:13:21 +00:00
|
|
|
return farside(url, '/nitter/')
|
2024-01-31 14:57:59 +00:00
|
|
|
def imgur(url: QUrl) -> bool:
|
2022-03-09 19:13:21 +00:00
|
|
|
return farside(url, '/rimgo/')
|
2024-01-31 14:57:59 +00:00
|
|
|
def medium(url: QUrl) -> bool:
|
2022-03-09 19:13:21 +00:00
|
|
|
return farside(url, '/scribe/')
|
2024-01-31 14:57:59 +00:00
|
|
|
def youtube(url: QUrl) -> bool:
|
2022-03-09 19:13:21 +00:00
|
|
|
return farside(url, '/invidious/')
|
|
|
|
def reddit(url: QUrl) -> bool:
|
|
|
|
return farside(url, '/libreddit/')
|
2024-01-31 14:57:59 +00:00
|
|
|
def instagram(url: QUrl) -> bool:
|
|
|
|
return farside(url, '/proxigram/')
|
|
|
|
def translate(url: QUrl) -> bool:
|
2022-03-09 19:13:21 +00:00
|
|
|
return farside(url, '/simplytranslate/')
|
2024-01-31 14:57:59 +00:00
|
|
|
def tiktok(url: QUrl) -> bool:
|
2022-09-09 18:54:48 +00:00
|
|
|
return farside(url, '/proxitok/')
|
2024-01-31 14:57:59 +00:00
|
|
|
def quora (url: QUrl) -> bool:
|
2022-09-09 18:54:48 +00:00
|
|
|
return farside(url, '/querte/')
|
2024-01-31 14:57:59 +00:00
|
|
|
def fandom(url: QUrl) -> bool:
|
2023-05-25 16:14:34 +00:00
|
|
|
return farside(url, '/breezewiki/')
|
2024-01-31 14:57:59 +00:00
|
|
|
def genius(url: QUrl) -> bool:
|
2023-05-25 16:14:34 +00:00
|
|
|
return farside(url, '/dumb/')
|
2024-01-31 14:57:59 +00:00
|
|
|
def stackoverflow (url: QUrl) -> bool:
|
2023-05-25 16:14:34 +00:00
|
|
|
return farside(url, '/anonymousoverflow/')
|
2024-01-31 14:57:59 +00:00
|
|
|
def wikipedia(url: QUrl) -> bool:
|
|
|
|
return farside(url, '/wikiless/')
|
2024-02-03 04:52:31 +00:00
|
|
|
def github(url: QUrl) -> bool:
|
|
|
|
return farside(url, '/gothub/')
|
2022-03-09 19:13:21 +00:00
|
|
|
|
2024-04-07 17:19:30 +00:00
|
|
|
#twitter = o(s, 'unrollnow.com')
|
2024-02-29 18:14:11 +00:00
|
|
|
|
2024-01-31 14:57:59 +00:00
|
|
|
m = {
|
2022-03-09 19:13:21 +00:00
|
|
|
"reddit.com": reddit,
|
|
|
|
"www.reddit.com": reddit,
|
|
|
|
"old.reddit.com": reddit,
|
2021-02-03 03:20:48 +00:00
|
|
|
|
2024-01-31 14:57:59 +00:00
|
|
|
"youtu.be": youtube,
|
|
|
|
"youtube.com": youtube,
|
|
|
|
"www.youtube.com": youtube,
|
|
|
|
"music.youtube.com": youtube,
|
2021-02-03 03:20:48 +00:00
|
|
|
|
2024-01-31 14:57:59 +00:00
|
|
|
"twitter.com": twitter,
|
|
|
|
"mobile.twitter.com": twitter,
|
|
|
|
"x.com": twitter,
|
2022-03-09 19:13:21 +00:00
|
|
|
|
2024-01-31 14:57:59 +00:00
|
|
|
"imgur.com" : imgur,
|
|
|
|
"medium.com" : medium,
|
|
|
|
"www.instagram.com": instagram,
|
|
|
|
"translate.google.com" : translate,
|
|
|
|
"vm.tiktok.com" : tiktok,
|
|
|
|
"www.tiktok.com" : tiktok,
|
|
|
|
"www.quora.com": quora,
|
|
|
|
"fandom.com": fandom,
|
|
|
|
"www.fandom.com": fandom,
|
|
|
|
"genius.com" : genius,
|
|
|
|
"stackoverflow.com" : stackoverflow,
|
|
|
|
"en.wikipedia.org" : wikipedia,
|
2024-02-03 04:52:31 +00:00
|
|
|
"gothub.com" : github,
|
2021-02-03 03:20:48 +00:00
|
|
|
|
2024-01-31 14:57:59 +00:00
|
|
|
"www.twitch.tv" : o(s, 'twineo.exozy.me'),
|
2022-02-27 23:58:18 +00:00
|
|
|
"discord.com" : o(s, 'canary.discord.com'),
|
2024-01-12 00:34:37 +00:00
|
|
|
"tumblr.com" : o(s, 'tumblash.fly.dev'),
|
2024-01-31 14:57:59 +00:00
|
|
|
"www.tumblr.com" : o(s, 'priviblur.fly.dev'),
|
2022-04-25 22:18:33 +00:00
|
|
|
"www.npr.org" : o(s, 'text.npr.org'),
|
2023-03-07 16:20:28 +00:00
|
|
|
"www.goodreads.com" : o(s, 'bl.vern.cc'),
|
2023-09-07 16:53:42 +00:00
|
|
|
"zelda.fandom.com" : o(s, 'zeldawiki.wiki'),
|
2024-04-07 17:19:30 +00:00
|
|
|
"avatar.wiki" : o(s, 'avatar.antifandom.com'),
|
2024-01-31 14:57:59 +00:00
|
|
|
"news.ycombinator.com" : o(s, 'news.workers.tools'),
|
|
|
|
"www.pixiv.net" : o(s, 'pixivfe.exozy.me'),
|
2022-03-04 17:37:45 +00:00
|
|
|
}
|
2024-01-31 14:57:59 +00:00
|
|
|
def rewrite(info: interceptor.Request):
|
|
|
|
if (info.resource_type != interceptor.ResourceType.main_frame or
|
2021-11-08 21:38:08 +00:00
|
|
|
info.request_url.scheme() in {"data", "blob"}):
|
|
|
|
return
|
|
|
|
url = info.request_url
|
2024-01-31 14:57:59 +00:00
|
|
|
redir = m.get(url.host())
|
2021-11-08 21:38:08 +00:00
|
|
|
if redir is not None and redir(url) is not False:
|
|
|
|
info.redirect(url)
|
2024-01-31 14:57:59 +00:00
|
|
|
interceptor.register(rewrite)
|