from qutebrowser.api import interceptor from typing import Dict config.load_autoconfig() c.bindings.default["normal"].clear() c.bindings.commands["normal"] = { # Navigation "": "scroll-page 0 0.5", "": "scroll-page 0 -0.5", "<": "scroll-to-perc 0", ">": "scroll-to-perc", # Commands "": "cmd-set-text :", "b": "cmd-set-text :tab-focus", "r": "reload", "": "tab-close", "": "quit", # Searching "": "cmd-set-text /", "": "cmd-set-text ?", # Hinting "": "hint all", "": "hint all tab", # History "f": "forward", "p": "back", # Zoom "+": "zoom-in", "-": "zoom-out", # Tabs "": "tab-next", "": "tab-prev", # Open "": "cmd-set-text -s :open", "": "cmd-set-text -s :open {url:pretty}", "": "cmd-set-text -s :open -t", # Editing "": "fake-key ", "": "fake-key ", "": "fake-key ", "": "fake-key ", # Numbers "0": "fake-key 0", "1": "fake-key 1", "2": "fake-key 2", "3": "fake-key 3", "4": "fake-key 4", "5": "fake-key 5", "6": "fake-key 6", "7": "fake-key 7", "8": "fake-key 8", "9": "fake-key 9", # Links "": "yank", } c.bindings.commands["command"] = { # Searching "": "search-next", "": "search-prev", # Completion "": "completion-item-focus prev", "": "completion-item-focus next", "": "mode-leave", } c.bindings.commands["hint"] = { "": "mode-leave", } c.bindings.commands["caret"] = { "": "mode-leave", } 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", ] c.hints.chars = "aoeuidhtns" def redirect(request: interceptor.Request): redirect_dict: Dict[str, str] = { } 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)