fix: add redirects on qutebrowser
Signed-off-by: Lucas Sta Maria <lucas@priime.dev>
This commit is contained in:
parent
911621d8bb
commit
ef6fa246af
1 changed files with 46 additions and 9 deletions
|
@ -1,15 +1,52 @@
|
|||
from qutebrowser.api import interceptor
|
||||
from typing import Dict
|
||||
|
||||
config.load_autoconfig()
|
||||
|
||||
config.bind('<Shift-j>', 'tab-prev')
|
||||
config.bind('<Shift-k>', 'tab-next')
|
||||
config.bind('<Control-j>', 'tab-prev')
|
||||
config.bind('<Control-k>', 'tab-next')
|
||||
config.bind("<Shift-j>", "tab-prev")
|
||||
config.bind("<Shift-k>", "tab-next")
|
||||
config.bind("<Control-j>", "tab-prev")
|
||||
config.bind("<Control-k>", "tab-next")
|
||||
|
||||
c.content.blocking.method = 'both'
|
||||
c.content.blocking.method = "both"
|
||||
c.content.blocking.adblock.lists = [
|
||||
'https://easylist.to/easylist/easylist.txt',
|
||||
'https://easylist.to/easylist/easyprivacy.txt',
|
||||
'https://easylist-downloads.adblockplus.org/antiadblockfilters.txt'
|
||||
"https://easylist.to/easylist/easylist.txt",
|
||||
"https://easylist.to/easylist/easyprivacy.txt",
|
||||
"https://easylist-downloads.adblockplus.org/antiadblockfilters.txt",
|
||||
]
|
||||
|
||||
c.hints.chars = 'aoeuidhtns'
|
||||
c.hints.chars = "aoeuidhtns"
|
||||
|
||||
|
||||
def redirect(request: interceptor.Request):
|
||||
redirect_dict: Dict[str, str] = {
|
||||
"www.reddit.com": "r.nf",
|
||||
"old.reddit.com": "r.nf",
|
||||
"reddit.com": "r.nf",
|
||||
}
|
||||
|
||||
if request.request_url.host() in redirect_dict.keys():
|
||||
try:
|
||||
new_host = redirect_dict[request.request_url.host()]
|
||||
request.request_url.setHost(new_host)
|
||||
request.redirect(request.request_url)
|
||||
except:
|
||||
pass
|
||||
|
||||
if request.request_url.host() == "news.ycombinator.com":
|
||||
try:
|
||||
request.request_url.setHost("hn.svelte.dev")
|
||||
query = request.request_url.query()
|
||||
if len(query) != 0:
|
||||
queries = query.split("&")
|
||||
for q in queries:
|
||||
if q.startswith("id"):
|
||||
id = q.split("=")[1]
|
||||
request.request_url.setPath(f"/item/{id}")
|
||||
request.request_url.setQuery("")
|
||||
request.redirect(request.request_url)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
interceptor.register(redirect)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue