1
0
Fork 0
mirror of https://github.com/Phantop/dotfiles synced 2024-11-09 00:14:53 +00:00
dotfiles/qutebrowser/config/redirects.py

38 lines
1 KiB
Python
Raw Normal View History

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'
nitter = 'nitter.snopyta.org'
2021-01-28 21:23:04 +00:00
reddit = 'teddit.net'
o = operator.methodcaller
s = 'setHost'
2021-02-10 00:11:23 +00:00
i = interceptor
MAP = {
"reddit.com": o(s, reddit),
"www.reddit.com": o(s, reddit),
"old.reddit.com": o(s, reddit),
"twitter.com": o(s, nitter),
"mobile.twitter.com": o(s, nitter),
"youtu.be": o(s, invid),
"youtube.com": o(s, invid),
"www.youtube.com": o(s, invid),
"www.instagram.com": o(s, 'bibliogram.art'),
"www.amazon.com": o(s, 'smile.amazon.com'),
"imgur.com" : o(s, 'imgin.voidnet.tech'),
"medium.com" : o(s, 'scribe.rip')
}
2021-02-10 00:11:23 +00:00
def f(info: i.Request):
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)