| shore up browser settings - dotfiles - These are my dotfiles. There are many li… | |
| Log | |
| Files | |
| Refs | |
| README | |
| --- | |
| commit 5ecfc9b94f8a19c3bd7230e3d3a25c39b4f277e4 | |
| parent da516cf043b452115b244b84b4d8c33b1d6620bd | |
| Author: Jay Scott <[email protected]> | |
| Date: Sun, 15 Jan 2023 22:55:53 +0000 | |
| shore up browser settings | |
| Diffstat: | |
| M qutebrowser/config.py | 1 + | |
| D qutebrowser/scripts/redirectors.py | 26 -------------------------- | |
| A qutebrowser/scripts/redirects.py | 70 +++++++++++++++++++++++++++++… | |
| M sfeed/sfeedrc | 1 + | |
| 4 files changed, 72 insertions(+), 26 deletions(-) | |
| --- | |
| diff --git a/qutebrowser/config.py b/qutebrowser/config.py | |
| @@ -5,6 +5,7 @@ try: | |
| # gruvbox colour theme | |
| config.source('scripts/gruvbox.py') | |
| + config.source('scripts/redirects.py') | |
| except ImportError: | |
| pass | |
| diff --git a/qutebrowser/scripts/redirectors.py b/qutebrowser/scripts/redirecto… | |
| @@ -1,26 +0,0 @@ | |
| -import operator, re, typing | |
| -from urllib.parse import urljoin | |
| - | |
| -from qutebrowser.api import interceptor, message | |
| -from PyQt5.QtCore import QUrl | |
| - | |
| - | |
| -REDIRECT_MAP = { | |
| - "reddit.com": operator.methodcaller('setHost', 'old.reddit.com'), | |
| - "www.reddit.com": operator.methodcaller('setHost', 'old.reddit.com'), | |
| - "twitter.com": operator.methodcaller('setHost', 'nitter.pussthecat.org'), | |
| - "www.twitter.com": operator.methodcaller('setHost', 'nitter.pussthecat.org… | |
| -} | |
| - | |
| -def int_fn(info: interceptor.Request): | |
| - if (info.resource_type != interceptor.ResourceType.main_frame or | |
| - info.request_url.scheme() in {"data", "blob"}): | |
| - return | |
| - url = info.request_url | |
| - redir = REDIRECT_MAP.get(url.host()) | |
| - if redir is not None and redir(url) is not False: | |
| - message.info("Redirecting to " + url.toString()) | |
| - info.redirect(url) | |
| - | |
| - | |
| -interceptor.register(int_fn) | |
| diff --git a/qutebrowser/scripts/redirects.py b/qutebrowser/scripts/redirects.py | |
| @@ -0,0 +1,70 @@ | |
| +from qutebrowser.api import interceptor | |
| +from urllib.parse import urljoin | |
| +from PyQt5.QtCore import QUrl | |
| +import operator | |
| + | |
| +o = operator.methodcaller | |
| +s = 'setHost' | |
| +i = interceptor | |
| + | |
| +def farside(url: QUrl, i) -> bool: | |
| + url.setHost('farside.link') | |
| + p = url.path().strip('/') | |
| + url.setPath(urljoin(i, p)) | |
| + return True | |
| + | |
| +def nitter(url: QUrl) -> bool: | |
| + return farside(url, '/nitter/') | |
| +def rimgo(url: QUrl) -> bool: | |
| + return farside(url, '/rimgo/') | |
| +def scribe(url: QUrl) -> bool: | |
| + return farside(url, '/scribe/') | |
| +def wikiless(url: QUrl) -> bool: | |
| + return farside(url, '/wikiless/') | |
| +def invid(url: QUrl) -> bool: | |
| + return farside(url, '/invidious/') | |
| +def reddit(url: QUrl) -> bool: | |
| + return farside(url, '/libreddit/') | |
| +def bibliogram(url: QUrl) -> bool: | |
| + return farside(url, '/bibliogram/') | |
| +def simplytranslate(url: QUrl) -> bool: | |
| + return farside(url, '/simplytranslate/') | |
| +def proxitok(url: QUrl) -> bool: | |
| + return farside(url, '/proxitok/') | |
| +def querte (url: QUrl) -> bool: | |
| + return farside(url, '/querte/') | |
| + | |
| +map = { | |
| + "reddit.com": reddit, | |
| + "www.reddit.com": reddit, | |
| + "old.reddit.com": reddit, | |
| + | |
| + "youtu.be": invid, | |
| + "youtube.com": invid, | |
| + "www.youtube.com": invid, | |
| + | |
| + "twitter.com": nitter, | |
| + "mobile.twitter.com": nitter, | |
| + | |
| + "imgur.com" : rimgo, | |
| + "medium.com" : scribe, | |
| + "en.wikipedia.org" : wikiless, | |
| + "www.instagram.com": bibliogram, | |
| + "translate.google.com" : simplytranslate, | |
| + "vm.tiktok.com" : proxitok, | |
| + "www.tiktok.com" : proxitok, | |
| + "www.quora.com": querte, | |
| + | |
| + "www.twitch.tv" : o(s, 'm.twitch.tv'), | |
| + "tumblr.com" : o(s, 'splashblr.fly.dev'), | |
| + "www.npr.org" : o(s, 'text.npr.org'), | |
| + } | |
| +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) | |
| +i.register(f) | |
| diff --git a/sfeed/sfeedrc b/sfeed/sfeedrc | |
| @@ -17,6 +17,7 @@ feeds() { | |
| feed 'tvtorrents' 'https://showrss.info/other/all.rss' | |
| feed 'linuxtorrents' 'http://feed.rutracker.cc/atom/f/1992.atom' | |
| feed 'gamingonlinux' 'https://www.gamingonlinux.com/article_rss.php' | |
| + feed 'lwn' 'https://lwn.net/headlines/rss' | |
| # apps | |
| feed 'qutebrowser' 'https://blog.qutebrowser.org/feeds/all.atom.xml' | |
| feed 'rdrview' 'https://github.com/eafer/rdrview/commits/master.atom' |