From 5adfebeba8f9d1c890574c5f185818e684455563 Mon Sep 17 00:00:00 2001 From: Phantop Date: Tue, 16 Jul 2024 12:20:10 -0400 Subject: [PATCH] qute: adjust for arista and redo redirects --- bin/setup.fish | 4 +- git/config | 1 + kitty/kitty.conf | 1 + qutebrowser/arista.py | 12 ++++ qutebrowser/bindings.py | 2 +- qutebrowser/config.py | 10 ++- qutebrowser/css/user.scss | 83 ++++++++++------------ qutebrowser/redirects.py | 146 +++++++++++++++++--------------------- qutebrowser/ui.py | 2 + 9 files changed, 129 insertions(+), 132 deletions(-) create mode 100644 qutebrowser/arista.py diff --git a/bin/setup.fish b/bin/setup.fish index debd5bf..2ebaf66 100755 --- a/bin/setup.fish +++ b/bin/setup.fish @@ -120,8 +120,8 @@ for i in (cut -d ' ' -f1 < ~/.config/qutebrowser/quickmarks) a $i "qutebrowser / \":open $i\"" end -for i in deemix encodec git-sim lightnovel-crawler mandown mangadex-downloader\ - mathicsscript pdf2docx portablemc ratarmount scdl soundscrape spleeter +for i in bandcamp-downloader deemix encodec git-sim lightnovel-crawler mandown\ + mangadex-downloader mathicsscript pdf2docx portablemc ratarmount scdl spleeter a $i "pipx run $i" end a in2csv 'pipx run --spec csvkit in2csv' diff --git a/git/config b/git/config index 894fbc1..33d0bac 100644 --- a/git/config +++ b/git/config @@ -52,6 +52,7 @@ g = clone gr = clone --recursive l = log + open = remote -v p = pull pu = push puf = push -f diff --git a/kitty/kitty.conf b/kitty/kitty.conf index 1d202f2..75dfdc9 100644 --- a/kitty/kitty.conf +++ b/kitty/kitty.conf @@ -10,6 +10,7 @@ close_on_child_death yes initial_window_width 80c initial_window_height 24c allow_remote_control yes +hide_window_decorations yes map shift+page_up scroll_page_up map shift+page_down scroll_page_down diff --git a/qutebrowser/arista.py b/qutebrowser/arista.py new file mode 100644 index 0000000..657c1cf --- /dev/null +++ b/qutebrowser/arista.py @@ -0,0 +1,12 @@ +c.url.searchengines['aid'] = 'http://aid/{}' +c.url.searchengines['go'] = 'http://go/{}' +c.url.searchengines['group'] = 'http://groups/{}' + +config.bind('A', ':cmd-set-text -s :open -t aid') +config.bind('a', ':cmd-set-text -s :open aid') +config.bind('E', ':cmd-set-text -s :open -t go') +config.bind('e', ':cmd-set-text -s :open go') + +c.content.user_stylesheets = ['css/user.css'] +c.fonts.default_size = '13pt' +c.url.default_page = 'https://docs.google.com/document/d/1LGHPp5h5lu-aCFSSZHOZkz5OZrJv5xd7jtq6Wsa3ZKU/mobilebasic' diff --git a/qutebrowser/bindings.py b/qutebrowser/bindings.py index ba16ff0..38bf937 100644 --- a/qutebrowser/bindings.py +++ b/qutebrowser/bindings.py @@ -37,7 +37,7 @@ bind = { 'E': 'config-cycle -p content.javascript.enabled ;; reload', 's1': 'download-open', 'sa': 'open -t archive.is/submit/?url={url}', - 'sb': 'spawn -u priviblur', + 'pb': 'spawn -u priviblur', 'sc': 'toggle-dark', 'sd': "spawn fish -c 'dl; open (ls -a | rofi -dmenu -b -i || exit 0)'", 'sg': 'debug-dump-page ~/Downloads/dump.html', diff --git a/qutebrowser/config.py b/qutebrowser/config.py index 23544af..535b630 100644 --- a/qutebrowser/config.py +++ b/qutebrowser/config.py @@ -1,8 +1,14 @@ +import platform + config.load_autoconfig(False) config.source('adblock.py') config.source('bindings.py') -config.source('redirects.py') config.source('search.py') -config.source('sites.py') config.source('theme.py') config.source('ui.py') + +if platform.system() != 'Darwin': + config.source('redirects.py') + config.source('sites.py') +else: + config.source('arista.py') diff --git a/qutebrowser/css/user.scss b/qutebrowser/css/user.scss index 10d4ed9..e8f7d0b 100644 --- a/qutebrowser/css/user.scss +++ b/qutebrowser/css/user.scss @@ -1,7 +1,7 @@ #hnmain { // hacker news - zoom: 120%; - .title a:link, .c00, .c00 a:link {color: #FFF } + .title a:link, .c00, .c00 a:link {color: #FFF} [action="comment"] {display:none} + zoom: 120%; } #app-mount { //discord @@ -12,43 +12,55 @@ --background-secondary-alt: var(--background-primary); --channeltextarea-background: var(--background-primary); - font-family: "Ubuntu Mono"; $aria: gift, Help, Inbox; @each $i in $aria {[aria-label$="#{$i}"] {display: none}} - [class^="private"] [class^="search"], [href="/store"], [href="/shop"] {display: none} [aria-label="Servers"] ~ div { display: none } + [class^="private"] [class^="search"], [href="/store"], [href="/shop"] {display: none} + font-family: "Ubuntu Mono"; } -div.doc-container div.doc div {max-width: 666pt !important; margin: auto} // better docs mobile .docs-gm > #sheets-viewport > div { display: unset !important; } -// .bridge-card { form, h5 {display:revert} .showmore {display:none} } // show rss-bridges -#years-table { .detail-view-container { display: flex } td { background-image: unset } } //quatalog detailed view +.doc-content {max-width: 666pt !important; margin: auto} // better docs mobile +body>nav:nth-child(1), .docs-ml-header {position: absolute} // lock sticky navbars ul.js-show-external { display: unset } // show annas external +// .bridge-card { form, h5 {display:revert} .showmore {display:none} } // show rss-bridges -/* hide ads and invidious recommends */ -$class: ad-frame-container, ad-panel, ad-slot, adsbygoogle, adbox, adunit, -adunit-wrapper, b_ad, leaderboard, "pure-u-lg-1-5:nth-child(3)", verified-icon; -@each $i in $class {.#{$i} {display:none}} - +/* hide ads */ +$class: -frame-container, -panel, -slot, sbygoogle, box, unit, unit-wrapper; +$id: ads, leaderboard, player-ads, rc-row-container; $div: 'class*=-ad-container', 'class*=ad-wrapper', 'id*=_ad_native', 'id^=div-gpt-ad', 'id^=google_ads_', 'id^=netboard_', 'id^=skyscraper'; +@each $i in $class {.ad#{$i} {display:none}} @each $i in $div {div[#{$i}] {display:none}} - -$id: ads, leaderboard, player-ads, rc-row-container; @each $i in $id {##{$i} {display:none}} /* --------------------------------- */ -div.container > div.conversation > div#r.replies { display: none } //nitter replies -body>nav:nth-child(1):not([class]) {position: absolute} // nitter/libreddit/librex + +// arista aids +body:has(> p.author) { max-width: 60em; margin: auto; zoom: 110%; } + +div#outer.wrapper { //ao3 + #admin-banner, #header ul.primary, #bookmark-form fieldset > dl {display:none} + #workskin {zoom: 125%; max-width: 40em;} + p.kudos {overflow-wrap: break-word} + select { background: none; color: #FFF; } + zoom: 110%; + ul.work { // modified work header w/ nav and epub + .download li:not(:nth-child(2)), a.collapsed, li.share {display: none} + ul.secondary { border: none; display: unset; position: static; } + } +} [data-csrf-token] { // miniflux - --body-background: #000; - --current-item-border-color: #c88aff; - --text-color: #EEE; + @media (prefers-color-scheme: dark) { + --body-background: #000; + --current-item-border-color: #c88aff; + --text-color: #EEE; - --entry-content-color: var(--text-color); - --link-color: var(--text-color); - --title-color: var(--text-color); + --entry-content-color: var(--text-color); + --link-color: var(--text-color); + --title-color: var(--text-color); + } .logo a span, .logo a:hover { color: var(--current-item-border-color) } @@ -58,32 +70,9 @@ body>nav:nth-child(1):not([class]) {position: absolute} // nitter/libreddit/libr } #grease-anchor { - margin-inline-start: 4px; color: var(--category-link-color); display: none; + margin-inline-start: 4px; } - h1, h2, h3, h4, h5, h6 { - &:hover { - #grease-anchor { display: unset } - } - } -} - -div#outer.wrapper { //ao3 - #admin-banner, #header > nav > ul.primary {display:none} - #bookmark-form fieldset > dl {display:none} - #workskin {zoom: 125%; max-width: 40em;} - p.kudos {overflow-wrap: break-word} - select {background: none } - zoom: 110%; - ul.work { - .download li:not(:nth-child(2)) {display: none} - a.collapsed {display: none} - li.share {display: none} - ul.secondary { - border: none; - display: unset; - position: static; - } - } + h1, h2, h3, h4, h5, h6 { &:hover #grease-anchor {display: unset}} } diff --git a/qutebrowser/redirects.py b/qutebrowser/redirects.py index 898af9f..7cbf989 100644 --- a/qutebrowser/redirects.py +++ b/qutebrowser/redirects.py @@ -1,96 +1,82 @@ from qutebrowser.api import interceptor -from urllib.parse import urljoin from PyQt6.QtCore import QUrl -import operator -o = operator.methodcaller -s = 'setHost' +basic = { + 'tumblr.com' : 'priviblur.fly.dev', + 'www.tumblr.com' : 'priviblur.fly.dev', -def farside(url: QUrl, i) -> bool: - url.setHost('farside.link') - p = url.path().strip('/') - url.setPath(urljoin(i, p)) - return True + 'avatar.wiki' : 'avatar.antifandom.com', + 'portal.wiki' : 'theportalwiki.com', + 'tardis.fandom.com' : 'tardis.wiki', + 'zelda.fandom.com' : 'zeldawiki.wiki', -def twitter(url: QUrl) -> bool: - return farside(url, '/nitter/') -def imgur(url: QUrl) -> bool: - return farside(url, '/rimgo/') -def medium(url: QUrl) -> bool: - return farside(url, '/scribe/') -def youtube(url: QUrl) -> bool: - return farside(url, '/invidious/') -def reddit(url: QUrl) -> bool: - return farside(url, '/libreddit/') -def instagram(url: QUrl) -> bool: - return farside(url, '/proxigram/') -def translate(url: QUrl) -> bool: - return farside(url, '/simplytranslate/') -def tiktok(url: QUrl) -> bool: - return farside(url, '/proxitok/') -def quora (url: QUrl) -> bool: - return farside(url, '/querte/') -def fandom(url: QUrl) -> bool: - return farside(url, '/breezewiki/') -def genius(url: QUrl) -> bool: - return farside(url, '/dumb/') -def stackoverflow (url: QUrl) -> bool: - return farside(url, '/anonymousoverflow/') -def wikipedia(url: QUrl) -> bool: - return farside(url, '/wikiless/') -def github(url: QUrl) -> bool: - return farside(url, '/gothub/') + 'discord.com' : 'canary.discord.com', + 'news.ycombinator.com' : 'news.workers.tools', + 'www.goodreads.com' : 'bl.vern.cc', + 'www.npr.org' : 'text.npr.org', + 'www.pixiv.net' : 'pixivfe.exozy.me', + 'www.twitch.tv' : 'twineo.exozy.me', +} +farside = { + 'music.youtube.com': 'invidious', + 'www.youtube.com': 'invidious', + 'youtu.be': 'invidious', + 'youtube.com': 'invidious', -#twitter = o(s, 'unrollnow.com') + 'old.reddit.com': 'redlib', + 'reddit.com': 'redlib', + 'www.reddit.com': 'redlib', -m = { - "reddit.com": reddit, - "www.reddit.com": reddit, - "old.reddit.com": reddit, + 'mobile.twitter.com': 'nitter', + 'twitter.com': 'nitter', + 'x.com': 'nitter', - "youtu.be": youtube, - "youtube.com": youtube, - "www.youtube.com": youtube, - "music.youtube.com": youtube, + 'vm.tiktok.com' : 'proxitok', + 'www.tiktok.com' : 'proxitok', - "twitter.com": twitter, - "mobile.twitter.com": twitter, - "x.com": twitter, + 'en.wikipedia.org' : 'wikiless', + 'genius.com' : 'dumb', + 'gothub.com' : 'gothub', + 'imgur.com' : 'rimgo', + 'medium.com' : 'scribe', + 'stackoverflow.com' : 'anonymousoverflow', + 'translate.google.com' : 'simplytranslate', + 'www.instagram.com': 'proxigram', + 'www.quora.com': 'querte', +} - "imgur.com" : imgur, - "medium.com" : medium, - "www.instagram.com": instagram, - "translate.google.com" : translate, - "vm.tiktok.com" : tiktok, - "www.tiktok.com" : tiktok, - "www.quora.com": quora, - "fandom.com": fandom, - "www.fandom.com": fandom, - "genius.com" : genius, - "stackoverflow.com" : stackoverflow, - "en.wikipedia.org" : wikipedia, - "gothub.com" : github, +def dosub(url: QUrl, host, sub): + url.setHost(host) + url.setPath('/' + sub + url.path()) +def fandom(url: QUrl, sub): + dosub(url, 'farside.link', 'breezewiki/' + sub) +def tumblr(url: QUrl, sub): + dosub(url, 'priviblur.fly.dev', sub) - "tumblr.com" : o(s, 'priviblur.fly.dev'), - "www.tumblr.com" : o(s, 'priviblur.fly.dev'), +subs = { + 'fandom.com' : fandom, + 'tumblr.com' : tumblr, +} - "avatar.wiki" : o(s, 'avatar.antifandom.com'), - "tardis.fandom.com" : o(s, 'tardis.wiki'), - "zelda.fandom.com" : o(s, 'zeldawiki.wiki'), - - "discord.com" : o(s, 'canary.discord.com'), - "news.ycombinator.com" : o(s, 'news.workers.tools'), - "www.goodreads.com" : o(s, 'bl.vern.cc'), - "www.npr.org" : o(s, 'text.npr.org'), - "www.pixiv.net" : o(s, 'pixivfe.exozy.me'), - "www.twitch.tv" : o(s, 'twineo.exozy.me'), - } def rewrite(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 = m.get(url.host()) - if redir is not None and redir(url) is not False: + host = url.host() + base = '.'.join(host.split('.')[-2:]) + + bredir = basic.get(host) + fredir = farside.get(host) + sredir = subs.get(base) + + if bredir is not None: + url.setHost(bredir) info.redirect(url) + elif fredir is not None: + url.setHost('farside.link') + url.setPath('/' + fredir + url.path()) + info.redirect(url) + elif sredir is not None: + sub = host.split('.')[0] + sredir(url, sub) + info.redirect(url) + interceptor.register(rewrite) diff --git a/qutebrowser/ui.py b/qutebrowser/ui.py index 11b45d8..b0ed058 100644 --- a/qutebrowser/ui.py +++ b/qutebrowser/ui.py @@ -3,4 +3,6 @@ c.confirm_quit = ['downloads'] c.content.fullscreen.window = True c.content.prefers_reduced_motion = True c.content.user_stylesheets = ['css/adblock.css', 'css/ao3.css', 'css/laserwave.css', 'css/twitter_dark.css', 'css/user.css'] +c.qt.highdpi = True c.tabs.show = 'multiple' +c.window.hide_decoration = True