2021-02-10 00:11:23 +00:00
|
|
|
from qutebrowser.api import interceptor
|
2022-01-12 23:02:54 +00:00
|
|
|
import operator
|
2021-02-10 00:11:23 +00:00
|
|
|
|
2021-05-18 16:50:56 +00:00
|
|
|
invid = 'vid.puffyan.us'
|
2022-02-27 23:58:18 +00:00
|
|
|
nitter = 'nitter.net'
|
2022-02-19 04:04:40 +00:00
|
|
|
reddit = 'libreddit.pussthecat.org'
|
2021-01-28 21:23:04 +00:00
|
|
|
|
2021-02-03 03:20:48 +00:00
|
|
|
o = operator.methodcaller
|
|
|
|
s = 'setHost'
|
2021-02-10 00:11:23 +00:00
|
|
|
i = interceptor
|
|
|
|
|
2021-02-03 03:20:48 +00:00
|
|
|
MAP = {
|
2021-11-08 21:38:08 +00:00
|
|
|
"reddit.com": o(s, reddit),
|
|
|
|
"www.reddit.com": o(s, reddit),
|
|
|
|
"old.reddit.com": o(s, reddit),
|
2021-02-03 03:20:48 +00:00
|
|
|
|
2021-11-08 21:38:08 +00:00
|
|
|
"twitter.com": o(s, nitter),
|
|
|
|
"mobile.twitter.com": o(s, nitter),
|
2021-02-03 03:20:48 +00:00
|
|
|
|
2021-11-08 21:38:08 +00:00
|
|
|
"youtu.be": o(s, invid),
|
|
|
|
"youtube.com": o(s, invid),
|
|
|
|
"www.youtube.com": o(s, invid),
|
2021-02-03 03:20:48 +00:00
|
|
|
|
2022-02-27 23:58:18 +00:00
|
|
|
"www.instagram.com": o(s, 'bibliogram.pussthecat.org'),
|
2021-02-03 03:20:48 +00:00
|
|
|
"www.amazon.com": o(s, 'smile.amazon.com'),
|
2022-02-27 23:58:18 +00:00
|
|
|
"imgur.com" : o(s, 'i.bcow.xyz'),
|
2022-02-04 18:17:39 +00:00
|
|
|
"medium.com" : o(s, 'scribe.rip'),
|
|
|
|
"www.twitch.tv" : o(s, 'm.twitch.tv'),
|
2022-02-27 23:58:18 +00:00
|
|
|
"discord.com" : o(s, 'canary.discord.com'),
|
|
|
|
"vm.tiktok.com" : o(s, 'proxitok.herokuapp.com')
|
2021-11-08 21:38:08 +00:00
|
|
|
}
|
2021-02-10 00:11:23 +00:00
|
|
|
def f(info: i.Request):
|
2021-11-08 21:38:08 +00:00
|
|
|
if (info.resource_type != i.ResourceType.main_frame or
|
|
|
|
info.request_url.scheme() in {"data", "blob"}):
|
|
|
|
return
|
|
|
|
url = info.request_url
|
|
|
|
redir = MAP.get(url.host())
|
|
|
|
if redir is not None and redir(url) is not False:
|
|
|
|
info.redirect(url)
|
2021-02-10 00:11:23 +00:00
|
|
|
i.register(f)
|