From: Samir Benmendil Date: Sun, 17 Jan 2021 22:36:52 +0000 (+0000) Subject: qutebrowser: add interceptor to redirect some urls X-Git-Url: https://git.rmz.io/dotfiles.git/commitdiff_plain/e00699825fc440708a2927c5f207d896914f1b72?ds=inline qutebrowser: add interceptor to redirect some urls --- diff --git a/qutebrowser/config.py b/qutebrowser/config.py index 9951404..097a061 100644 --- a/qutebrowser/config.py +++ b/qutebrowser/config.py @@ -7,6 +7,29 @@ ## Remove it to not load settings done via the GUI. config.load_autoconfig() +try: + from qutebrowser.api import interceptor, message + from PyQt5.QtCore import QUrl + + def intercept(info: interceptor.Request): + url = info.request_url + if url.host() == "twitter.com": + url.setHost("nitter.net") + message.info("Redirecting to " + url.toString()) + info.redirect(url) + if url.host() == "xkcd.com": + url.setHost("m.xkcd.com") + message.info("Redirecting to " + url.toString()) + info.redirect(url) + if url.host() == "www.bristolpost.co.uk": + url.setUrl("https://outline.com/" + url.toString()) + message.info("Redirecting to " + url.toString()) + info.redirect(url) + + interceptor.register(intercept) +except ImportError: + pass + ## Aliases for commands. The keys of the given dictionary are the ## aliases, while the values are the commands they map to. ## Type: Dict