From 0423b9850f06a32ef102547c2dabc3015d379ecc Mon Sep 17 00:00:00 2001 From: TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> Date: Mon, 17 Feb 2025 04:57:37 +0900 Subject: updates --- ar/.config/zsh/scripts.zsh | 1 + .../share/qutebrowser/greasemonkey/0x0.css.js | 29 -- .../qutebrowser/greasemonkey/arstechnica.css.js | 21 -- .../share/qutebrowser/greasemonkey/cnn-lite.css.js | 31 -- .../qutebrowser/greasemonkey/csmonitor-text.css.js | 43 --- .../share/qutebrowser/greasemonkey/dienet.css.js | 67 ---- .../share/qutebrowser/greasemonkey/dir.css.js | 72 ---- .../share/qutebrowser/greasemonkey/fandom.css.js | 27 -- .../share/qutebrowser/greasemonkey/git-scm.css.js | 38 -- .../share/qutebrowser/greasemonkey/google.css.js | 12 - .../share/qutebrowser/greasemonkey/imdb.css.js | 12 - .../qutebrowser/greasemonkey/leadertelegram.css.js | 18 - .../share/qutebrowser/greasemonkey/manpages.css.js | 75 ---- .../share/qutebrowser/greasemonkey/npr-text.css.js | 33 -- .../qutebrowser/greasemonkey/opengroup.css.js | 50 --- .../share/qutebrowser/greasemonkey/rarbg.css.js | 12 - .../share/qutebrowser/greasemonkey/reddit.css.js | 41 -- .../qutebrowser/greasemonkey/smbc-comics.css.js | 31 -- .../qutebrowser/greasemonkey/stackexchange.css.js | 44 --- .../share/qutebrowser/greasemonkey/termbin.css.js | 32 -- .../share/qutebrowser/greasemonkey/wiki.css.js | 33 -- .../share/qutebrowser/greasemonkey/xkcd.css.js | 44 --- .../qutebrowser/greasemonkey/ycombinator.css.js | 74 ---- .../share/qutebrowser/greasemonkey/youtube-ads.js | 23 -- .../share/qutebrowser/greasemonkey/youtube.css.js | 18 - .../userscripts/add-nextcloud-bookmarks | 173 --------- .../qutebrowser/userscripts/add-nextcloud-cookbook | 131 ------- ar/.local/share/qutebrowser/userscripts/qr | 8 - ar/.local/share/qutebrowser/userscripts/qute-pass | 411 --------------------- ar/.local/share/qutebrowser/userscripts/translate | 116 ------ .../share/qutebrowser/greasemonkey/0x0.css.js | 29 ++ .../qutebrowser/greasemonkey/arstechnica.css.js | 21 ++ .../share/qutebrowser/greasemonkey/cnn-lite.css.js | 31 ++ .../qutebrowser/greasemonkey/csmonitor-text.css.js | 43 +++ .../share/qutebrowser/greasemonkey/dienet.css.js | 67 ++++ .../share/qutebrowser/greasemonkey/dir.css.js | 72 ++++ .../share/qutebrowser/greasemonkey/fandom.css.js | 27 ++ .../share/qutebrowser/greasemonkey/git-scm.css.js | 38 ++ .../share/qutebrowser/greasemonkey/google.css.js | 12 + .../share/qutebrowser/greasemonkey/imdb.css.js | 12 + .../qutebrowser/greasemonkey/leadertelegram.css.js | 18 + .../share/qutebrowser/greasemonkey/manpages.css.js | 75 ++++ .../share/qutebrowser/greasemonkey/npr-text.css.js | 33 ++ .../qutebrowser/greasemonkey/opengroup.css.js | 50 +++ .../share/qutebrowser/greasemonkey/rarbg.css.js | 12 + .../share/qutebrowser/greasemonkey/reddit.css.js | 41 ++ .../qutebrowser/greasemonkey/smbc-comics.css.js | 31 ++ .../qutebrowser/greasemonkey/stackexchange.css.js | 44 +++ .../share/qutebrowser/greasemonkey/termbin.css.js | 32 ++ .../share/qutebrowser/greasemonkey/wiki.css.js | 33 ++ .../share/qutebrowser/greasemonkey/xkcd.css.js | 44 +++ .../qutebrowser/greasemonkey/ycombinator.css.js | 74 ++++ .../share/qutebrowser/greasemonkey/youtube-ads.js | 23 ++ .../share/qutebrowser/greasemonkey/youtube.css.js | 18 + .../userscripts/add-nextcloud-bookmarks | 173 +++++++++ .../qutebrowser/userscripts/add-nextcloud-cookbook | 131 +++++++ global/.local/share/qutebrowser/userscripts/qr | 8 + .../.local/share/qutebrowser/userscripts/qute-pass | 411 +++++++++++++++++++++ .../.local/share/qutebrowser/userscripts/translate | 116 ++++++ global/.local/share/venvs/default-requirements.txt | 1 + 60 files changed, 1721 insertions(+), 1719 deletions(-) delete mode 100644 ar/.local/share/qutebrowser/greasemonkey/0x0.css.js delete mode 100644 ar/.local/share/qutebrowser/greasemonkey/arstechnica.css.js delete mode 100644 ar/.local/share/qutebrowser/greasemonkey/cnn-lite.css.js delete mode 100644 ar/.local/share/qutebrowser/greasemonkey/csmonitor-text.css.js delete mode 100644 ar/.local/share/qutebrowser/greasemonkey/dienet.css.js delete mode 100644 ar/.local/share/qutebrowser/greasemonkey/dir.css.js delete mode 100644 ar/.local/share/qutebrowser/greasemonkey/fandom.css.js delete mode 100644 ar/.local/share/qutebrowser/greasemonkey/git-scm.css.js delete mode 100644 ar/.local/share/qutebrowser/greasemonkey/google.css.js delete mode 100644 ar/.local/share/qutebrowser/greasemonkey/imdb.css.js delete mode 100644 ar/.local/share/qutebrowser/greasemonkey/leadertelegram.css.js delete mode 100644 ar/.local/share/qutebrowser/greasemonkey/manpages.css.js delete mode 100644 ar/.local/share/qutebrowser/greasemonkey/npr-text.css.js delete mode 100644 ar/.local/share/qutebrowser/greasemonkey/opengroup.css.js delete mode 100644 ar/.local/share/qutebrowser/greasemonkey/rarbg.css.js delete mode 100644 ar/.local/share/qutebrowser/greasemonkey/reddit.css.js delete mode 100644 ar/.local/share/qutebrowser/greasemonkey/smbc-comics.css.js delete mode 100644 ar/.local/share/qutebrowser/greasemonkey/stackexchange.css.js delete mode 100644 ar/.local/share/qutebrowser/greasemonkey/termbin.css.js delete mode 100644 ar/.local/share/qutebrowser/greasemonkey/wiki.css.js delete mode 100644 ar/.local/share/qutebrowser/greasemonkey/xkcd.css.js delete mode 100644 ar/.local/share/qutebrowser/greasemonkey/ycombinator.css.js delete mode 100644 ar/.local/share/qutebrowser/greasemonkey/youtube-ads.js delete mode 100644 ar/.local/share/qutebrowser/greasemonkey/youtube.css.js delete mode 100755 ar/.local/share/qutebrowser/userscripts/add-nextcloud-bookmarks delete mode 100755 ar/.local/share/qutebrowser/userscripts/add-nextcloud-cookbook delete mode 100755 ar/.local/share/qutebrowser/userscripts/qr delete mode 100755 ar/.local/share/qutebrowser/userscripts/qute-pass delete mode 100755 ar/.local/share/qutebrowser/userscripts/translate create mode 100644 global/.local/share/qutebrowser/greasemonkey/0x0.css.js create mode 100644 global/.local/share/qutebrowser/greasemonkey/arstechnica.css.js create mode 100644 global/.local/share/qutebrowser/greasemonkey/cnn-lite.css.js create mode 100644 global/.local/share/qutebrowser/greasemonkey/csmonitor-text.css.js create mode 100644 global/.local/share/qutebrowser/greasemonkey/dienet.css.js create mode 100644 global/.local/share/qutebrowser/greasemonkey/dir.css.js create mode 100644 global/.local/share/qutebrowser/greasemonkey/fandom.css.js create mode 100644 global/.local/share/qutebrowser/greasemonkey/git-scm.css.js create mode 100644 global/.local/share/qutebrowser/greasemonkey/google.css.js create mode 100644 global/.local/share/qutebrowser/greasemonkey/imdb.css.js create mode 100644 global/.local/share/qutebrowser/greasemonkey/leadertelegram.css.js create mode 100644 global/.local/share/qutebrowser/greasemonkey/manpages.css.js create mode 100644 global/.local/share/qutebrowser/greasemonkey/npr-text.css.js create mode 100644 global/.local/share/qutebrowser/greasemonkey/opengroup.css.js create mode 100644 global/.local/share/qutebrowser/greasemonkey/rarbg.css.js create mode 100644 global/.local/share/qutebrowser/greasemonkey/reddit.css.js create mode 100644 global/.local/share/qutebrowser/greasemonkey/smbc-comics.css.js create mode 100644 global/.local/share/qutebrowser/greasemonkey/stackexchange.css.js create mode 100644 global/.local/share/qutebrowser/greasemonkey/termbin.css.js create mode 100644 global/.local/share/qutebrowser/greasemonkey/wiki.css.js create mode 100644 global/.local/share/qutebrowser/greasemonkey/xkcd.css.js create mode 100644 global/.local/share/qutebrowser/greasemonkey/ycombinator.css.js create mode 100644 global/.local/share/qutebrowser/greasemonkey/youtube-ads.js create mode 100644 global/.local/share/qutebrowser/greasemonkey/youtube.css.js create mode 100755 global/.local/share/qutebrowser/userscripts/add-nextcloud-bookmarks create mode 100755 global/.local/share/qutebrowser/userscripts/add-nextcloud-cookbook create mode 100755 global/.local/share/qutebrowser/userscripts/qr create mode 100755 global/.local/share/qutebrowser/userscripts/qute-pass create mode 100755 global/.local/share/qutebrowser/userscripts/translate diff --git a/ar/.config/zsh/scripts.zsh b/ar/.config/zsh/scripts.zsh index 5d45c0b..8a45ae5 100644 --- a/ar/.config/zsh/scripts.zsh +++ b/ar/.config/zsh/scripts.zsh @@ -791,6 +791,7 @@ function active_venv() { source "$XDG_DATA_HOME/venvs/$venv/bin/activate" python -m ensurepip --upgrade >/dev/null 2>&1 python -m pip install --upgrade pip >/dev/null 2>&1 + jupyter kernel --kernel=$venv } # list venvs diff --git a/ar/.local/share/qutebrowser/greasemonkey/0x0.css.js b/ar/.local/share/qutebrowser/greasemonkey/0x0.css.js deleted file mode 100644 index ec10275..0000000 --- a/ar/.local/share/qutebrowser/greasemonkey/0x0.css.js +++ /dev/null @@ -1,29 +0,0 @@ -// ==UserScript== -// @name 0x0.st -// @include *://0x0.st* -// ==/UserScript== - -/* ~/.config/qutebrowser/greasemonkey/0x0.css.js :: */ - -GM_addStyle(` - body { - background: var(--color-bg) !important; - color: var(--color-fg) !important; - font-size: var(--font-size) !important; - } - - u { - text-decoration: none !important - } - - a { - color: var(--color-heading) !important; - text-decoration: none !important; - } - a:visited { - color: var(--color-link) !important; - } - a:hover { - color: var(--color-active) !important; - } -`); diff --git a/ar/.local/share/qutebrowser/greasemonkey/arstechnica.css.js b/ar/.local/share/qutebrowser/greasemonkey/arstechnica.css.js deleted file mode 100644 index 723a7e4..0000000 --- a/ar/.local/share/qutebrowser/greasemonkey/arstechnica.css.js +++ /dev/null @@ -1,21 +0,0 @@ -// ==UserScript== -// @name Ars Technica -// @include *://arstechnica.com/* -// ==/UserScript== - -/* ~/.config/qutebrowser/greasemonkey/arstechnica.css.js :: */ - -GM_addStyle(` - .ad.ad.ad, .ad_wrapper, .ad-wrapper { - display: none !important; - } - .listing-top.with-feature .article.top-feature figure .listing, - .listing-top.with-feature .article.top-latest figure .listing, - .listing-top.with-feature .article figure .listing, - .listing-earlier .article figure .listing, - .listing-latest .article figure .listing, - .listing-rest .article figure .listing, - .with-xrail .xrail .featured-video .video-thumbnail { - background: none; - } -`); diff --git a/ar/.local/share/qutebrowser/greasemonkey/cnn-lite.css.js b/ar/.local/share/qutebrowser/greasemonkey/cnn-lite.css.js deleted file mode 100644 index 8c2c507..0000000 --- a/ar/.local/share/qutebrowser/greasemonkey/cnn-lite.css.js +++ /dev/null @@ -1,31 +0,0 @@ -// ==UserScript== -// @name CNN Lite -// @include *://lite.cnn.com* -// ==/UserScript== - -/* ~/.config/qutebrowser/greasemonkey/cnn-lite.css.js :: */ - -GM_addStyle(` - body { - color: var(--color-fg) !important; - background: var(--color-bg) !important; - } - - a, footer a:visited, header a:visited { - color: var(--color-heading) !important; - text-decoration: none !important; - } - - a:visited { - color: var(--color-link) !important; - } - - a:hover, footer a:hover, header a:hover { - color: var(--color-active) !important; - } - - ul { - list-style-type: none !important; - padding-inline-start: unset !important; - } -`); diff --git a/ar/.local/share/qutebrowser/greasemonkey/csmonitor-text.css.js b/ar/.local/share/qutebrowser/greasemonkey/csmonitor-text.css.js deleted file mode 100644 index 92a491d..0000000 --- a/ar/.local/share/qutebrowser/greasemonkey/csmonitor-text.css.js +++ /dev/null @@ -1,43 +0,0 @@ -// ==UserScript== -// @name Christian Science Monitor Text Edition -// @include *://www.csmonitor.com/text_edition* -// ==/UserScript== - -/* ~/.config/qutebrowser/greasemonkey/csmonitor-text.css.js :: */ - -GM_addStyle(` - body, footer { - background: var(--color-bg) !important; - color: var(--color-fg) !important; - } - - div[data-field='summary'] { - color: var(--color-fg) !important; - } - - u { - text-decoration: none !important - } - - a, .content-title>* { - border: none !important; - transition: none !important; - -webkit-transition: none !important; - } - - a, footer a:visited, .top-navigation a:visited, a:visited.navbar-brand { - color: var(--color-heading) !important; - text-decoration: none !important; - } - a:visited { - color: var(--color-link) !important; - } - a:hover, footer a:hover, .top-navigation a:hover, a:hover.navbar-brand { - color: var(--color-active) !important; - } - - span[data-view='kicker'], h2 + small, .underlined, - .footer-logo, #issn, .footer-social-links { - display: none !important; - } -`); diff --git a/ar/.local/share/qutebrowser/greasemonkey/dienet.css.js b/ar/.local/share/qutebrowser/greasemonkey/dienet.css.js deleted file mode 100644 index 7031d05..0000000 --- a/ar/.local/share/qutebrowser/greasemonkey/dienet.css.js +++ /dev/null @@ -1,67 +0,0 @@ -// ==UserScript== -// @name die.net -// @include *://linux.die.net* -// @include *://die.net* -// @include *://www.die.net* -// ==/UserScript== - -/* ~/.config/qutebrowser/greasemonkey/dienet.css.js :: */ - -GM_addStyle(` - body { - background: var(--color-bg) !important; - color: var(--color-fg) !important; - } - #logo, #menu { - background: var(--color-bg1) !important; - color: var(--color-fg) !important; - border: none !important; - } - - #bg { - max-width: unset !important; - } - - #content { - font-family: var(--font-family) !important; - font-size: var(--font-size) !important; - } - - h1 { - border: none !important; - } - - h1, h2, h3, h4, h5, h6 { - font-size: var(--font-size) !important; - color: var(--color-heading) !important; - padding: 0 !important; - margin-top: 2ch !important; - margin-bottom: 0 !important; - } - - b { - color: var(--color-heading) !important; - } - - input { - background: var(--color-bg) !important; - color: var(--color-code) !important; - border-color: 2px solid var(--color-bar) !important; - } - - a { - color: var(--color-link) !important ; - text-decoration: none !important; - } - a:hover { - color: var(--color-active) !important; - text-decoration: none !important; - } - #logo a, #menu a { - background: none !important; - } - - img[alt='Back'], #adright, #cse-search-box { - display: none !important; - } -`); diff --git a/ar/.local/share/qutebrowser/greasemonkey/dir.css.js b/ar/.local/share/qutebrowser/greasemonkey/dir.css.js deleted file mode 100644 index 59ed68e..0000000 --- a/ar/.local/share/qutebrowser/greasemonkey/dir.css.js +++ /dev/null @@ -1,72 +0,0 @@ -// ==UserScript== -// @name local directory -// @include file://*/ -// ==/UserScript== - -/* ~/.config/qutebrowser/greasemonkey/dir.css.js :: */ - -var header = document.getElementById('header'); -var text = header.textContent.slice(9); -header.textContent = text; -document.title = text; - -if (text != '/') { - var table = document.getElementsByTagName('table')[0]; - var row = table.insertRow(1); - var cell = row.insertCell(); - var a = document.createElement('a'); - var updir = document.createTextNode('../'); - a.href = '../'; - a.appendChild(updir); - cell.appendChild(a); -}; - -GM_addStyle(` - * { - border: none !important; - margin: 0px !important; - padding: 0px !important; - color: var(--color-fg) !important; - background: var(--color-bg) !important; - font-family: var(--font-family) !important; - font-size: var(--font-size) !important; - text-decoration: none !important; - } - - body { - display: block !important; - color: var(--color-fg) !important; - background-color: var(--color-bg) !important; - font-style: none !important; - font-weight: normal !important; - padding-left: 1ch !important; - padding-right: 1ch !important; - } - - h1 { - border-color: var(--color-heading) !important; - color: var(--color-heading) !important; - display: table !important; - font-weight: bold !important; - border-bottom: solid !important; - border-width: 2ch !important; - border-image: var(--box1-heading) !important; - } - - a { - color: var(--color-link) !important ; - } - - a:hover { - color: var(--color-active) !important; - } - - td { - padding-right: 2ch !important; - } - - #parentDirLinkBox, #parentDirLink, #parentDirText, - thead, #theader, td:nth-child(2), td:nth-child(3) { - display: none !important; - } -`); diff --git a/ar/.local/share/qutebrowser/greasemonkey/fandom.css.js b/ar/.local/share/qutebrowser/greasemonkey/fandom.css.js deleted file mode 100644 index e52987a..0000000 --- a/ar/.local/share/qutebrowser/greasemonkey/fandom.css.js +++ /dev/null @@ -1,27 +0,0 @@ -// ==UserScript== -// @name Fandom -// @include *://*.fandom.com/* -// ==/UserScript== - -/* ~/.config/qutebrowser/greasemonkey/fandom.css.js :: */ - -GM_addStyle(` - div[itemprop=video], - #WikiaBar, - #mixed-content-footer, - .bottom-ads-container, - .fandom-sticky-header.is-visible, - .page__right-rail, - .top-ads-container { - display: none !important; - } - - .main-container { - background: #ffffff !important; - } - - body.theme-fandomdesktop-dark .main-page .mcwiki-header { - background: none !important; - border: none !important; - } -`); diff --git a/ar/.local/share/qutebrowser/greasemonkey/git-scm.css.js b/ar/.local/share/qutebrowser/greasemonkey/git-scm.css.js deleted file mode 100644 index 4451840..0000000 --- a/ar/.local/share/qutebrowser/greasemonkey/git-scm.css.js +++ /dev/null @@ -1,38 +0,0 @@ -// ==UserScript== -// @name git-scm -// @include *://git-scm.com* -// ==/UserScript== - -/* ~/.config/qutebrowser/greasemonkey/git-scm.css.js :: */ - -GM_addStyle(` - * { - font-family: var(--font-family) !important; - } - - body { - background: var(--color-bg) !important; - } - - #masthead, #main { - background: var(--color-bg1) !important; - } - - code, pre { - background: var(--color-bg) !important; - color: var(--color-code) !important; - } - - h1, h2, h3, h4, h5, h6 { - color: var(--color-heading) !important; - } - - a { - color: var(--color-link) !important; - transition: none !important; - } - a:hover { - color: var(--color-active) !important; - } - -`); diff --git a/ar/.local/share/qutebrowser/greasemonkey/google.css.js b/ar/.local/share/qutebrowser/greasemonkey/google.css.js deleted file mode 100644 index eea39c2..0000000 --- a/ar/.local/share/qutebrowser/greasemonkey/google.css.js +++ /dev/null @@ -1,12 +0,0 @@ -// ==UserScript== -// @name Google -// @include *://*.google.com/* -// ==/UserScript== - -/* ~/.config/qutebrowser/greasemonkey/google.css.js :: */ - -GM_addStyle(` - #tadsb, #taw, .cu-container { - display: none !important; - } -`); diff --git a/ar/.local/share/qutebrowser/greasemonkey/imdb.css.js b/ar/.local/share/qutebrowser/greasemonkey/imdb.css.js deleted file mode 100644 index a21bc01..0000000 --- a/ar/.local/share/qutebrowser/greasemonkey/imdb.css.js +++ /dev/null @@ -1,12 +0,0 @@ -// ==UserScript== -// @name IMDB -// @include *://*.imdb.com/* -// ==/UserScript== - -/* ~/.config/qutebrowser/greasemonkey/imdb.css.js :: */ - -GM_addStyle(` - .ipc-overflowText-overlay { - background: none !important; - } -`); diff --git a/ar/.local/share/qutebrowser/greasemonkey/leadertelegram.css.js b/ar/.local/share/qutebrowser/greasemonkey/leadertelegram.css.js deleted file mode 100644 index 3fabb6e..0000000 --- a/ar/.local/share/qutebrowser/greasemonkey/leadertelegram.css.js +++ /dev/null @@ -1,18 +0,0 @@ -// ==UserScript== -// @name Leader Telegram -// @include *://*.leadertelegram.com/* -// ==/UserScript== - -/* ~/.config/qutebrowser/greasemonkey/leadertelegram.css.js :: */ - -GM_addStyle(` - #app, #asset-below, #main-bottom-container, #main-top-container, - #site-footer-container, #site-header, #site-header-container, - #sticky-anchor, #tncms-region-article_bottom, #tncms-region-front-full-top, - .ad-col, .dfp-ad, .fixed-col-right, .grecaptcha-badge, .header-promo, - .hidden-print, .main-sidebar, .modal-body, .navbar-header, .nav-home, - .not-logged-in, .paging-link, .row-senary, .site-logo-container, - .subscription-required, .tnt-ads, .tnt-photo-purchase, .tnt-stack { - display: none !important; - } -`); diff --git a/ar/.local/share/qutebrowser/greasemonkey/manpages.css.js b/ar/.local/share/qutebrowser/greasemonkey/manpages.css.js deleted file mode 100644 index a013076..0000000 --- a/ar/.local/share/qutebrowser/greasemonkey/manpages.css.js +++ /dev/null @@ -1,75 +0,0 @@ -// ==UserScript== -// @name Man Pages -// @include *://man7.org/* -// @include *://man.freebsd.org/cgi/man.cgi* -// ==/UserScript== - -/* ~/.config/qutebrowser/greasemonkey/man7.css.js :: */ - -GM_addStyle(` - * { - background: var(--color-bg) !important; - color: var(--color-fg) !important; - font-family: Hack, Hack-Regular, monospace !important; - font-size: var(--font-size) !important; - } - - h1, h2, h3, h4, h5, h6 { - color: var(--color-heading) !important; - padding: 0 !important; - margin-top: 2ch !important; - margin-bottom: 0 !important; - } - - a { - color: var(--color-link) !important ; - background: var(--color-bg) !important; - text-decoration: none !important; - } - a:hover { - color: var(--color-active) !important; - text-decoration: none !important; - } - - b { - color: var(--color-heading) !important; - font-weight: normal !important; - } - - i { - color: var(--color-active) !important; - font-style: normal !important; - } - - hr, hr.nav-end { - border: none !important; - clear: both !important; - border-bottom: solid !important; - border-image: var(--box2-comment) !important; - border-width: 2ch !important; - color: var(--color-comment) !important; - border-color: var(--color-comment) !important; - margin-bottom: 0 !important; - } - - input, button, select { - border-color: var(--color-comment) !important; - border-style: solid !important; - } - - #container { - width: 100% !important; - margin-left: 1ch !important; - margin-right: 1ch !important; - } - - .footer, .top-link, td.search-box, hr.start-footer, hr.end-footer, - .nav-bar, hr.nav-end, #header, #headercontainer, #footer { - display: none !important; - } - - pre { - margin-top: 0 !important; - } - -`); diff --git a/ar/.local/share/qutebrowser/greasemonkey/npr-text.css.js b/ar/.local/share/qutebrowser/greasemonkey/npr-text.css.js deleted file mode 100644 index 6f5020f..0000000 --- a/ar/.local/share/qutebrowser/greasemonkey/npr-text.css.js +++ /dev/null @@ -1,33 +0,0 @@ -// ==UserScript== -// @name NPR Text-Only -// @include *://text.npr.org* -// ==/UserScript== - -/* ~/.config/qutebrowser/greasemonkey/npr-text.css.js :: */ - -GM_addStyle(` - body { - background: var(--color-bg) !important; - color: var(--color-fg) !important; - max-width: 750px !important; - } - - u { - text-decoration: none !important - } - - a { - color: var(--color-heading) !important; - text-decoration: none !important; - } - a:visited { - color: var(--color-link) !important; - } - a:hover { - color: var(--color-active) !important; - } - - .hr-line { - display: none !important; - } -`); diff --git a/ar/.local/share/qutebrowser/greasemonkey/opengroup.css.js b/ar/.local/share/qutebrowser/greasemonkey/opengroup.css.js deleted file mode 100644 index fdce0d3..0000000 --- a/ar/.local/share/qutebrowser/greasemonkey/opengroup.css.js +++ /dev/null @@ -1,50 +0,0 @@ -// ==UserScript== -// @name Open Group Publications -// @include https://pubs.opengroup.org/onlinepubs* -// ==/UserScript== - -/* ~/.config/qutebrowser/greasemonkey/opengroup.css.js :: */ - -var hrs = document.getElementsByTagName('hr'); -for (let i = 0; i < hrs.length; i++) { - while(hrs[i].attributes.length > 0) { - hrs[i].removeAttributeNode(hrs[i].attributes[0]); - }; -}; - -GM_addStyle(` - body { - background: var(--color-bg) !important; - color: var(--color-fg) !important; - } - - ul, li, table { - color: unset !important; - background: unset !important; - } - - hr { - border-top: 2px solid var(--color-bar) !important; - color: var(--color-bar) !important; - } - - a { - color: var(--color-heading) !important; - text-decoration: none !important; - } - a:visited { - color: var(--color-link) !important; - } - a:hover { - color: var(--color-active) !important; - } - - h1, h2, h3, h4, h5, h6 { - color: var(--color-code) !important; - background: unset !important; - } - - .topOfPage { - display: none !important; - } -`); diff --git a/ar/.local/share/qutebrowser/greasemonkey/rarbg.css.js b/ar/.local/share/qutebrowser/greasemonkey/rarbg.css.js deleted file mode 100644 index 16e4666..0000000 --- a/ar/.local/share/qutebrowser/greasemonkey/rarbg.css.js +++ /dev/null @@ -1,12 +0,0 @@ -// ==UserScript== -// @name RARBG -// @include *://rarbg.to/* -// ==/UserScript== - -/* ~/.config/qutebrowser/greasemonkey/rarbg.css.js :: */ - -GM_addStyle(` - body { - background: none !important; - } -`); diff --git a/ar/.local/share/qutebrowser/greasemonkey/reddit.css.js b/ar/.local/share/qutebrowser/greasemonkey/reddit.css.js deleted file mode 100644 index 9677090..0000000 --- a/ar/.local/share/qutebrowser/greasemonkey/reddit.css.js +++ /dev/null @@ -1,41 +0,0 @@ -// ==UserScript== -// @name Reddit -// @include *://*.reddit.com/* -// ==/UserScript== - -/* ~/.config/qutebrowser/greasemonkey/reddit.css.js :: */ - -GM_addStyle(` - body, body:before, textarea, #header, #siteTable, .comment, .commentarea, - .option, .side, .sitetable, .titlebox, .usertext-body { - background: var(--color-bg) !important; - background-image: none !important; - color: var(--color-fg) !important; - } - - #sr-header-area { - background: var(--color-bg1) !important; - } - #sr-header-area a { - color: var(--color-heading) !important ; - } - #sr-header-area a:hover { - color: var(--color-active) !important; - } - - a { - color: var(--color-heading) !important ; - text-decoration: none !important; - } - a:visited { - color: var(--color-link) !important ; - } - a:hover { - color: var(--color-active) !important; - } - - .account-activity-box, .premium-banner, .premium-banner-outer, .promoted, - .promotedlink, .redesign-beta-optin, .sidebox.create { - display: none !important; - } -`); diff --git a/ar/.local/share/qutebrowser/greasemonkey/smbc-comics.css.js b/ar/.local/share/qutebrowser/greasemonkey/smbc-comics.css.js deleted file mode 100644 index 926559c..0000000 --- a/ar/.local/share/qutebrowser/greasemonkey/smbc-comics.css.js +++ /dev/null @@ -1,31 +0,0 @@ -// ==UserScript== -// @name SMBC -// @include *://*.smbc-comics.com/* -// ==/UserScript== - -/* ~/.config/qutebrowser/greasemonkey/smbc-comics.css.js :: */ - -GM_addStyle(` - body { - background: var(--color-bg) !important; - } - - #mainwrap { - border: none !important; - background: none !important; - padding: 0px !important; - } - - #comicleft { - float: none !important; - margin: auto !important; - } - - #blogarea, #blogheader, #blogmsgmobile, #boardleader, #buythis, - #comicright, #commentarea, #comment-space, #footer, #header, #hw-jumpbar, - #midleader, #mobad1, #mobaftercomic, #mobfacebook, #mobilefooter, - #mobilemenu, #mobilepermalink, #mobtumblr, #mobtwitter, - #navtop + script + a, #permalink, #sharebar, #sharemob, .cc-tagline { - display: none !important; - } -`); diff --git a/ar/.local/share/qutebrowser/greasemonkey/stackexchange.css.js b/ar/.local/share/qutebrowser/greasemonkey/stackexchange.css.js deleted file mode 100644 index 845b0a6..0000000 --- a/ar/.local/share/qutebrowser/greasemonkey/stackexchange.css.js +++ /dev/null @@ -1,44 +0,0 @@ -// ==UserScript== -// @name Stack Exchange -// @include *://stackexchange.com* -// @include *://*.stackexchange.com* -// @include *://stackoverflow.com* -// @include *://mathoverflow.net* -// @include *://superuser.com* -// @include *://askubuntu.com* -// @include *://serverfault.com* -// ==/UserScript== - -/* ~/.config/qutebrowser/greasemonkey/stackexchange.css.js :: */ - -GM_addStyle(` - html, body, .s-sidebarwidget { - background: var(--color-bg) !important; - } - #content, header { - background: var(--color-bg1) !important; - border: 2px solid var(--color-bar) !important; - } - .s-sidebarwidget--header { - background: var(--color-bg1) !important; - } - .s-btn { - background: none !important; - } - - a { - color: var(--color-heading) !important; - text-decoration: none !important; - transition: none !important; - } - a:visited { - color: var(--color-link) !important; - } - a:hover { - color: var(--color-active) !important; - } - - .js-overflowai-cta { - display: none !important; - } -`); diff --git a/ar/.local/share/qutebrowser/greasemonkey/termbin.css.js b/ar/.local/share/qutebrowser/greasemonkey/termbin.css.js deleted file mode 100644 index 0c559aa..0000000 --- a/ar/.local/share/qutebrowser/greasemonkey/termbin.css.js +++ /dev/null @@ -1,32 +0,0 @@ -// ==UserScript== -// @name termbin -// @include *://termbin.com* -// ==/UserScript== - -/* ~/.config/qutebrowser/greasemonkey/termbin.css.js :: */ - -GM_addStyle(` - body { - background: var(--color-bg) !important; - color: var(--color-fg) !important; - } - - pre { - font-size: var(--font-size) !important; - } - - u { - text-decoration: none !important - } - - a { - color: var(--color-heading) !important; - text-decoration: none !important; - } - a:visited { - color: var(--color-link) !important; - } - a:hover { - color: var(--color-active) !important; - } -`); diff --git a/ar/.local/share/qutebrowser/greasemonkey/wiki.css.js b/ar/.local/share/qutebrowser/greasemonkey/wiki.css.js deleted file mode 100644 index 301f85e..0000000 --- a/ar/.local/share/qutebrowser/greasemonkey/wiki.css.js +++ /dev/null @@ -1,33 +0,0 @@ -// ==UserScript== -// @name ArchWiki/Wikimedia -// @include *://*.wikibooks.org/* -// @include *://*.wikidata.org/* -// @include *://*.wikimedia.org/* -// @include *://*.wikinews.org/* -// @include *://*.wikipedia.org/* -// @include *://*.wikiquote.org/* -// @include *://*.wikisource.org/* -// @include *://*.wikiversity.org/* -// @include *://*.wikivoyage.org/* -// @include *://*.wiktionary.org/* -// @include *://wiki.archlinux.org/* -// ==/UserScript== - -/* ~/.config/qutebrowser/greasemonkey/wiki.css.js :: */ - -GM_addStyle(` - body, #mw-head, #mw-panel, .mw-list-item { - background: #ffffff !important; - } - .vector-menu-heading, .vector-menu-tabs a, .vector-menu-tabs, - .vector-toc::after { - background: none !important; - } - - .vector-menu-heading { - border-bottom: 1px solid #606060 !important; - } - .cn-fundraising { - display: none !important; - } -`); diff --git a/ar/.local/share/qutebrowser/greasemonkey/xkcd.css.js b/ar/.local/share/qutebrowser/greasemonkey/xkcd.css.js deleted file mode 100644 index 2dfaa1d..0000000 --- a/ar/.local/share/qutebrowser/greasemonkey/xkcd.css.js +++ /dev/null @@ -1,44 +0,0 @@ -// ==UserScript== -// @name xkcd -// @include *://xkcd.com/* -// ==/UserScript== - -/* ~/.config/qutebrowser/greasemonkey/xkcd.css.js :: */ - -var content = document.getElementById('middleContainer'); -content.innerHTML = content.innerHTML.split('
')[0] + '
\n'; - -GM_addStyle(` - body, #middleContainer { - background: var(--color-bg) !important; - color: var(--color-fg) !important; - } - - #bottom, - #topContainer { - display: none !important; - } - - ul.comicNav li a { - background: var(--color-bar) !important; - border: none !important; - box-shadow: none !important; - -mox-box-shadow: none !important; - -webkit-box-shadow: none !important; - } - - .box { - border: none !important; - } - - a { - text-decoration: none !important; - transition: none !important; - } - a, a:visited { - color: var(--color-link) !important; - } - a:hover { - color: var(--color-active) !important; - } -`); diff --git a/ar/.local/share/qutebrowser/greasemonkey/ycombinator.css.js b/ar/.local/share/qutebrowser/greasemonkey/ycombinator.css.js deleted file mode 100644 index cdc02a2..0000000 --- a/ar/.local/share/qutebrowser/greasemonkey/ycombinator.css.js +++ /dev/null @@ -1,74 +0,0 @@ -// ==UserScript== -// @name Hacker News -// @include *://news.ycombinator.com* -// ==/UserScript== - -/* ~/.config/qutebrowser/greasemonkey/ycominator.css.js :: */ - -var style = getComputedStyle(document.body) -var colorBg = style.getPropertyValue('--color-bg') -var colorBg1 = style.getPropertyValue('--color-bg1') -var colorBar = style.getPropertyValue('--color-bar') - -var hnmain = document.getElementById('hnmain'); -hnmain.style.background = colorBg1; - -var tds = document.getElementsByTagName('td'); -for (let i = 0; i < tds.length; i++) { - if (tds[i].bgColor.toLowerCase() == '#ff6600') { - tds[i].bgColor = colorBar; - }; -}; - -var imgs = document.getElementsByTagName('img'); -for (let i = 0; i < imgs.length; i++) { - imgs[i].src = 'data:,'; -}; - -GM_addStyle(` - body, td, input, textarea, .default, .title, .pagetop, .comment { - font-size: 14px !important; - } - .admin, .admin td { - font-size: 12px !important; - } - .subtext, .subtext td { - font-size: 10px !important; - } - - body, input, textarea { - background: var(--color-bg) !important; - } - body { - color: var(--color-fg) !important; - } - input, textarea { - color: var(--color-bar) !important; - border-color: var(--color-bar) !important; - border-style: solid !important; - } - - input[type='submit'] { - background: var(--color-bar) !important; - border-color: var(--color-bg) !important; - color: var(--color-heading) !important; - } - input[type='submit']:hover { - background: var(--color-bg1) !important; - border-color: var(--color-bar) !important; - border-style: solid !important; - color: var(--color-active) !important; - } - - a, .pagetop a:visited, .yclinks a:visited, - a[href='https://www.ycombinator.com/apply/']:visited { - color: var(--color-heading) !important; - } - a:visited { - color: var(--color-link) !important; - } - a:hover, .pagetop a:hover, .yclinks a:hover, - a[href='https://www.ycombinator.com/apply/']:hover { - color: var(--color-active) !important; - } -`); diff --git a/ar/.local/share/qutebrowser/greasemonkey/youtube-ads.js b/ar/.local/share/qutebrowser/greasemonkey/youtube-ads.js deleted file mode 100644 index 21d4214..0000000 --- a/ar/.local/share/qutebrowser/greasemonkey/youtube-ads.js +++ /dev/null @@ -1,23 +0,0 @@ -// ==UserScript== -// @name Skip YouTube ads -// @description Skips the ads in YouTube videos -// @run-at document-start -// @include *.youtube.com/* -// ==/UserScript== - -document.addEventListener( - "load", - () => { - const btn = document.querySelector( - ".videoAdUiSkipButton,.ytp-ad-skip-button-modern", - ); - if (btn) { - btn.click(); - } - const ad = [...document.querySelectorAll(".ad-showing")][0]; - if (ad) { - document.querySelector("video").currentTime = 9999999999; - } - }, - true, -); diff --git a/ar/.local/share/qutebrowser/greasemonkey/youtube.css.js b/ar/.local/share/qutebrowser/greasemonkey/youtube.css.js deleted file mode 100644 index e86edf9..0000000 --- a/ar/.local/share/qutebrowser/greasemonkey/youtube.css.js +++ /dev/null @@ -1,18 +0,0 @@ -// ==UserScript== -// @name YouTube -// @include *://*.youtube.com/* -// ==/UserScript== - -/* ~/.config/qutebrowser/greasemonkey/youtube.css.js :: */ - -document.addEventListener('load', () => { - try { document.querySelector('.ad-showing video').currentTime = 99999 } catch {} - try { document.querySelector('.ytp-ad-skip-button').click() } catch {} -}, true); - -GM_addStyle(` - ytd-compact-promoted-video-renderer, .ytd-action-companion-ad-renderer, - .ytd-ad-slot-renderer, .ytd-promoted-sparkles-web-renderer { - display: none !important; - } -`); diff --git a/ar/.local/share/qutebrowser/userscripts/add-nextcloud-bookmarks b/ar/.local/share/qutebrowser/userscripts/add-nextcloud-bookmarks deleted file mode 100755 index 2a480cc..0000000 --- a/ar/.local/share/qutebrowser/userscripts/add-nextcloud-bookmarks +++ /dev/null @@ -1,173 +0,0 @@ -#!/usr/bin/env python3 - -""" -Behavior: - A qutebrowser userscript that creates bookmarks in Nextcloud's Bookmarks app. - -Requirements: - requests - -userscript setup: - Optionally create ~/.config/qutebrowser/add-nextcloud-bookmarks.ini like: - -[nextcloud] -HOST=https://nextcloud.example.com -USER=username -;PASSWORD=lamepassword -DESCRIPTION=None -;TAGS=just-one -TAGS=read-me-later,added-by-qutebrowser, Another-One - - If settings aren't in the configuration file, the user will be prompted during - bookmark creation. If DESCRIPTION and TAGS are set to None, they will be left - blank. If the user does not want to be prompted for a password, it is recommended - to set up an 'app password'. See the following for instructions: - https://docs.nextcloud.com/server/latest/user_manual/en/session_management.html#managing-devices # noqa: E501 - -qutebrowser setup: - add bookmark via hints - config.bind('X', 'hint links userscript add-nextcloud-bookmarks') - - add bookmark of current URL - config.bind('X', 'spawn --userscript add-nextcloud-bookmarks') - -troubleshooting: - Errors detected within this userscript will have an exit of 231. All other - exit codes will come from requests. -""" - -import configparser -from json import dumps -from os import environ, path -from sys import argv, exit - -from PyQt6.QtWidgets import QApplication, QInputDialog, QLineEdit -from requests import get, post -from requests.auth import HTTPBasicAuth - - -def get_text(name, info): - """Get input from the user.""" - _app = QApplication(argv) # noqa: F841 - if name == "password": - text, ok = QInputDialog.getText( - None, - "add-nextcloud-bookmarks userscript", - "Please enter {}".format(info), - QLineEdit.EchoMode.Password, - ) - else: - text, ok = QInputDialog.getText( - None, "add-nextcloud-bookmarks userscript", "Please enter {}".format(info) - ) - if not ok: - message("info", "Dialog box canceled.") - exit(0) - return text - - -def message(level, text): - """display message""" - with open(environ["QUTE_FIFO"], "w") as fifo: - fifo.write( - 'message-{} "add-nextcloud-bookmarks userscript: {}"\n'.format(level, text) - ) - fifo.flush() - - -if "QUTE_FIFO" not in environ: - print( - "This script is designed to run as a qutebrowser userscript, " - "not as a standalone script." - ) - exit(231) - -if "QUTE_CONFIG_DIR" not in environ: - if "XDG_CONFIG_HOME" in environ: - QUTE_CONFIG_DIR = environ["XDG_CONFIG_HOME"] + "/qutebrowser" - else: - QUTE_CONFIG_DIR = environ["HOME"] + "/.config/qutebrowser" -else: - QUTE_CONFIG_DIR = environ["QUTE_CONFIG_DIR"] - -config_file = QUTE_CONFIG_DIR + "/add-nextcloud-bookmarks.ini" -if path.isfile(config_file): - config = configparser.ConfigParser() - config.read(config_file) - settings = dict(config.items("nextcloud")) -else: - settings = {} - -settings_info = [ - ("host", "host information.", "required"), - ("user", "username.", "required"), - ("password", "password.", "required"), - ("description", "description or leave blank", "optional"), - ("tags", "tags (comma separated) or leave blank", "optional"), -] - -# check for settings that need user interaction and clear optional setting if need be -for setting in settings_info: - if setting[0] not in settings: - userInput = get_text(setting[0], setting[1]) - settings[setting[0]] = userInput - if setting[2] == "optional": - if settings[setting[0]] == "None": - settings[setting[0]] = "" - -tags = settings["tags"].split(",") - -QUTE_URL = environ["QUTE_URL"] -api_url = settings["host"] + "/index.php/apps/bookmarks/public/rest/v2/bookmark" - -auth = HTTPBasicAuth(settings["user"], settings["password"]) -headers = {"Content-Type": "application/json"} -params = {"url": QUTE_URL} - -# check if there is already a bookmark for the URL -r = get( - api_url, - auth=auth, - headers=headers, - params=params, - timeout=(3.05, 27), -) -if r.status_code != 200: - message( - "error", - "Could not connect to {} with status code {}".format( - settings["host"], r.status_code - ), - ) - exit(r.status_code) - -try: - r.json()["data"][0]["id"] -except IndexError: - pass -else: - message("info", "bookmark already exists for {}".format(QUTE_URL)) - exit(0) - -if environ["QUTE_MODE"] == "hints": - QUTE_TITLE = QUTE_URL -else: - QUTE_TITLE = environ["QUTE_TITLE"] - -# JSON format -# https://nextcloud-bookmarks.readthedocs.io/en/latest/bookmark.html#create-a-bookmark -dict = { - "url": QUTE_URL, - "title": QUTE_TITLE, - "description": settings["description"], - "tags": tags, -} -data = dumps(dict) - -r = post(api_url, data=data, headers=headers, auth=auth, timeout=(3.05, 27)) - -if r.status_code == 200: - message("info", "bookmark {} added".format(QUTE_URL)) -else: - message("error", "something went wrong {} bookmark not added".format(QUTE_URL)) - exit(r.status_code) diff --git a/ar/.local/share/qutebrowser/userscripts/add-nextcloud-cookbook b/ar/.local/share/qutebrowser/userscripts/add-nextcloud-cookbook deleted file mode 100755 index 1510907..0000000 --- a/ar/.local/share/qutebrowser/userscripts/add-nextcloud-cookbook +++ /dev/null @@ -1,131 +0,0 @@ -#!/usr/bin/env python3 - -""" -Behavior: - A qutebrowser userscript that adds recipes to Nextcloud's Cookbook app. - -Requirements: - requests - -userscript setup: - Optionally create ~/.config/qutebrowser/add-nextcloud-cookbook.ini like: - -[nextcloud] -HOST=https://nextcloud.example.com -USER=username -;PASSWORD=lamepassword - - If settings aren't in the configuration file, the user will be prompted. - If the user does not want to be prompted for a password, it is recommended - to set up an 'app password' with 'Allow filesystem access' enabled. - See the following for instructions: - https://docs.nextcloud.com/server/latest/user_manual/en/session_management.html#managing-devices # noqa: E501 - -qutebrowser setup: - add recipe via hints - config.bind('X', 'hint links userscript add-nextcloud-cookbook') - - add recipe of current URL - config.bind('X', 'spawn --userscript add-nextcloud-cookbook') - -troubleshooting: - Errors detected within this userscript will have an exit of 231. All other - exit codes will come from requests. -""" - -import configparser -from os import environ, path -from sys import argv, exit - -from PyQt6.QtWidgets import QApplication, QInputDialog, QLineEdit -from requests import post -from requests.auth import HTTPBasicAuth - - -def get_text(name, info): - """Get input from the user.""" - _app = QApplication(argv) # noqa: F841 - if name == "password": - text, ok = QInputDialog.getText( - None, - "add-nextcloud-cookbook userscript", - "Please enter {}".format(info), - QLineEdit.EchoMode.Password, - ) - else: - text, ok = QInputDialog.getText( - None, "add-nextcloud-cookbook userscript", "Please enter {}".format(info) - ) - if not ok: - message("info", "Dialog box canceled.") - exit(0) - return text - - -def message(level, text): - """display message""" - with open(environ["QUTE_FIFO"], "w") as fifo: - fifo.write( - "message-{} 'add-nextcloud-cookbook userscript: {}'\n".format(level, text) - ) - fifo.flush() - - -if "QUTE_FIFO" not in environ: - print( - "This script is designed to run as a qutebrowser userscript, " - "not as a standalone script." - ) - exit(231) - -if "QUTE_CONFIG_DIR" not in environ: - if "XDG_CONFIG_HOME" in environ: - QUTE_CONFIG_DIR = environ["XDG_CONFIG_HOME"] + "/qutebrowser" - else: - QUTE_CONFIG_DIR = environ["HOME"] + "/.config/qutebrowser" -else: - QUTE_CONFIG_DIR = environ["QUTE_CONFIG_DIR"] - -config_file = QUTE_CONFIG_DIR + "/add-nextcloud-cookbook.ini" -if path.isfile(config_file): - config = configparser.ConfigParser() - config.read(config_file) - settings = dict(config.items("nextcloud")) -else: - settings = {} - -settings_info = [ - ("host", "host information.", "required"), - ("user", "username.", "required"), - ("password", "password.", "required"), -] - -# check for settings that need user interaction -for setting in settings_info: - if setting[0] not in settings: - userInput = get_text(setting[0], setting[1]) - settings[setting[0]] = userInput - -api_url = settings["host"] + "/index.php/apps/cookbook/import" -headers = {"Content-Type": "application/x-www-form-urlencoded"} -auth = HTTPBasicAuth(settings["user"], settings["password"]) -data = "url=" + environ["QUTE_URL"] - -message("info", "starting to process {}".format(environ["QUTE_URL"])) - -r = post(api_url, data=data, headers=headers, auth=auth, timeout=(3.05, 27)) - -if r.status_code == 200: - message("info", "recipe from {} added.".format(environ["QUTE_URL"])) - exit(0) -elif r.status_code == 500: - message("warning", "Cookbook app reports {}".format(r.text)) - exit(0) -else: - message( - "error", - "Could not connect to {} with status code {}".format( - settings["host"], r.status_code - ), - ) - exit(r.status_code) diff --git a/ar/.local/share/qutebrowser/userscripts/qr b/ar/.local/share/qutebrowser/userscripts/qr deleted file mode 100755 index 8421524..0000000 --- a/ar/.local/share/qutebrowser/userscripts/qr +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -pngfile=$(mktemp --suffix=.png) -trap 'rm -f "$pngfile"' EXIT - -qrencode -t PNG -o "$pngfile" -s 10 "$QUTE_URL" -echo ":open -t file:///$pngfile" >> "$QUTE_FIFO" -sleep 1 # give qutebrowser time to open the file before it gets removed diff --git a/ar/.local/share/qutebrowser/userscripts/qute-pass b/ar/.local/share/qutebrowser/userscripts/qute-pass deleted file mode 100755 index 6b071b8..0000000 --- a/ar/.local/share/qutebrowser/userscripts/qute-pass +++ /dev/null @@ -1,411 +0,0 @@ -#!/usr/bin/env python3 - -# SPDX-FileCopyrightText: Chris Braun (cryzed) -# -# SPDX-License-Identifier: GPL-3.0-or-later - -""" -Insert login information using pass and a dmenu-compatible application (e.g. dmenu, rofi -dmenu, ...). A short -demonstration can be seen here: https://i.imgur.com/KN3XuZP.gif. -""" - -USAGE = """The domain of the site has to appear as a segment in the pass path, -for example: "github.com/cryzed" or "websites/github.com". Alternatively the -parameter `--unfiltered` may be used to get a list of all passwords. How the -username and password are determined is freely configurable using the CLI -arguments. As an example, if you instead store the username as part of the -secret (and use a site's name as filename), instead of the default configuration, -use `--username-target secret` and `--username-pattern "username: (.+)"`. - -The login information is inserted by emulating key events using qutebrowser's -fake-key command in this manner: [USERNAME][PASSWORD], which is compatible -with almost all login forms. - -If you use gopass with multiple mounts, use the CLI switch --mode gopass to switch to gopass mode. - -Suggested bindings similar to Uzbl's `formfiller` script: - - config.bind('', 'spawn --userscript qute-pass') - config.bind('', 'spawn --userscript qute-pass --username-only') - config.bind('

', 'spawn --userscript qute-pass --password-only') - config.bind('', 'spawn --userscript qute-pass --otp-only') -""" - -EPILOG = """Dependencies: tldextract (Python 3 module), pass, pass-otp (optional). - -WARNING: The login details are viewable as plaintext in qutebrowser's debug log (qute://log) and might be shared if -you decide to submit a crash report!""" - -import argparse -import enum -import fnmatch -import functools -import os -import re -import shlex -import subprocess -import sys -import unicodedata -from urllib.parse import urlparse - -import idna -import tldextract - - -def expanded_path(path): - # Expand potential ~ in paths, since this script won't be called from a shell that does it for us - expanded = os.path.expanduser(path) - # Add trailing slash if not present - return os.path.join(expanded, "") - - -argument_parser = argparse.ArgumentParser( - description=__doc__, usage=USAGE, epilog=EPILOG -) -argument_parser.add_argument("url", nargs="?", default=os.getenv("QUTE_URL")) -argument_parser.add_argument( - "--password-store", - "-p", - default=expanded_path(os.getenv("PASSWORD_STORE_DIR", default="~/.password-store")), - help="Path to your pass password-store (only used in pass-mode)", - type=expanded_path, -) -argument_parser.add_argument( - "--mode", - "-M", - choices=["pass", "gopass"], - default="pass", - help="Select mode [gopass] to use gopass instead of the standard pass.", -) -argument_parser.add_argument( - "--prefix", - type=str, - help="Search only the given subfolder of the store (only used in gopass-mode)", -) -argument_parser.add_argument( - "--username-pattern", - "-u", - default=r".*/(.+)", - help="Regular expression that matches the username", -) -argument_parser.add_argument( - "--username-target", - "-U", - choices=["path", "secret"], - default="path", - help="The target for the username regular expression", -) -argument_parser.add_argument( - "--password-pattern", - "-P", - default=r"(.*)", - help="Regular expression that matches the password", -) -argument_parser.add_argument( - "--dmenu-invocation", - "-d", - default="dmenu", - help="Invocation used to execute a dmenu-provider", -) -argument_parser.add_argument( - "--no-insert-mode", - "-n", - dest="insert_mode", - action="store_false", - help="Don't automatically enter insert mode", -) -argument_parser.add_argument( - "--io-encoding", - "-i", - default="UTF-8", - help="Encoding used to communicate with subprocesses", -) -argument_parser.add_argument( - "--merge-candidates", - "-m", - action="store_true", - help="Merge pass candidates for fully-qualified and registered domain name", -) -argument_parser.add_argument( - "--extra-url-suffixes", - "-s", - default="", - help="Comma-separated string containing extra suffixes (e.g local)", -) -argument_parser.add_argument( - "--unfiltered", - dest="unfiltered", - action="store_true", - help="Show an unfiltered selection of all passwords in the store", -) -argument_parser.add_argument( - "--always-show-selection", - dest="always_show_selection", - action="store_true", - help="Always show selection, even if there is only a single match", -) -group = argument_parser.add_mutually_exclusive_group() -group.add_argument( - "--username-only", "-e", action="store_true", help="Only insert username" -) -group.add_argument( - "--password-only", "-w", action="store_true", help="Only insert password" -) -group.add_argument("--otp-only", "-o", action="store_true", help="Only insert OTP code") - -stderr = functools.partial(print, file=sys.stderr) - - -class ExitCodes(enum.IntEnum): - SUCCESS = 0 - FAILURE = 1 - # 1 is automatically used if Python throws an exception - NO_PASS_CANDIDATES = 2 - COULD_NOT_MATCH_USERNAME = 3 - COULD_NOT_MATCH_PASSWORD = 4 - - -class CouldNotMatchUsername(Exception): - pass - - -class CouldNotMatchPassword(Exception): - pass - - -def qute_command(command): - with open(os.environ["QUTE_FIFO"], "w") as fifo: - fifo.write(command + "\n") - fifo.flush() - - -# Encode candidate string parts as Internationalized Domain Name, doing -# Unicode normalization before. This allows to properly match (non-ASCII) -# pass entries with the corresponding domain names. -def idna_encode(name): - # Do Unicode normalization first, we use form NFKC because: - # 1. Use the compatibility normalization because these sequences have "the same meaning in some contexts" - # 2. idna.encode() below requires the Unicode strings to be in normalization form C - # See https://en.wikipedia.org/wiki/Unicode_equivalence#Normal_forms - unicode_normalized = unicodedata.normalize("NFKC", name) - # Empty strings can not be encoded, they appear for example as empty - # parts in split_path. If something like this happens, we just fall back - # to the unicode representation (which may already be ASCII then). - try: - idna_encoded = idna.encode(unicode_normalized) - except idna.IDNAError: - idna_encoded = unicode_normalized - return idna_encoded - - -def find_pass_candidates(domain, unfiltered=False): - candidates = [] - - if arguments.mode == "gopass": - gopass_args = ["gopass", "list", "--flat"] - if arguments.prefix: - gopass_args.append(arguments.prefix) - all_passwords = ( - subprocess.run(gopass_args, stdout=subprocess.PIPE) - .stdout.decode("UTF-8") - .splitlines() - ) - - for password in all_passwords: - if unfiltered or domain in password: - candidates.append(password) - else: - idna_domain = idna_encode(domain) - for path, directories, file_names in os.walk( - arguments.password_store, followlinks=True - ): - secrets = fnmatch.filter(file_names, "*.gpg") - if not secrets: - continue - - # Strip password store path prefix to get the relative pass path - pass_path = path[len(arguments.password_store) :] - split_path = pass_path.split(os.path.sep) - idna_split_path = [idna_encode(part) for part in split_path] - for secret in secrets: - secret_base = os.path.splitext(secret)[0] - idna_secret_base = idna_encode(secret_base) - if not unfiltered and idna_domain not in ( - idna_split_path + [idna_secret_base] - ): - continue - - # Append the unencoded Unicode path/name since this is how pass uses them - candidates.append(os.path.join(pass_path, secret_base)) - return candidates - - -def _run_pass(pass_arguments): - # The executable is conveniently named after it's mode [pass|gopass]. - pass_command = [arguments.mode] - env = os.environ.copy() - env["PASSWORD_STORE_DIR"] = arguments.password_store - process = subprocess.run( - pass_command + pass_arguments, env=env, stdout=subprocess.PIPE - ) - return process.stdout.decode(arguments.io_encoding).strip() - - -def pass_(path): - return _run_pass(["show", path]) - - -def pass_otp(path): - if arguments.mode == "gopass": - return _run_pass(["otp", "-o", path]) - return _run_pass(["otp", path]) - - -def dmenu(items, invocation): - command = shlex.split(invocation) - process = subprocess.run( - command, - input="\n".join(items).encode(arguments.io_encoding), - stdout=subprocess.PIPE, - ) - return process.stdout.decode(arguments.io_encoding).strip() - - -def fake_key_raw(text): - for character in text: - # Escape all characters by default, space requires special handling - sequence = '" "' if character == " " else r"\{}".format(character) - qute_command("fake-key {}".format(sequence)) - - -def extract_password(secret, pattern): - match = re.match(pattern, secret) - if not match: - raise CouldNotMatchPassword("Pattern did not match target") - try: - return match.group(1) - except IndexError: - raise CouldNotMatchPassword( - "Pattern did not contain capture group, please use capture group. Example: (.*)" - ) - - -def extract_username(target, pattern): - match = re.search(pattern, target, re.MULTILINE) - if not match: - raise CouldNotMatchUsername("Pattern did not match target") - try: - return match.group(1) - except IndexError: - raise CouldNotMatchUsername( - "Pattern did not contain capture group, please use capture group. Example: (.*)" - ) - - -def main(arguments): - if not arguments.url: - argument_parser.print_help() - return ExitCodes.FAILURE - - extractor = tldextract.TLDExtract( - extra_suffixes=arguments.extra_url_suffixes.split(",") - ) - extract_result = extractor(arguments.url) - - # Try to find candidates using targets in the following order: fully-qualified domain name (includes subdomains), - # the registered domain name, the IPv4 address if that's what the URL represents and finally the private domain - # (if a non-public suffix was used), and the URL netloc. - candidates = set() - attempted_targets = [] - - private_domain = "" - if not extract_result.suffix: - private_domain = ( - ".".join((extract_result.subdomain, extract_result.domain)) - if extract_result.subdomain - else extract_result.domain - ) - - netloc = urlparse(arguments.url).netloc - - for target in filter( - None, - [ - extract_result.fqdn, - extract_result.registered_domain, - extract_result.ipv4, - private_domain, - netloc, - ], - ): - attempted_targets.append(target) - target_candidates = find_pass_candidates( - target, unfiltered=arguments.unfiltered - ) - if not target_candidates: - continue - - candidates.update(target_candidates) - if not arguments.merge_candidates: - break - else: - if not candidates: - stderr( - "No pass candidates for URL {!r} found! (I tried {!r})".format( - arguments.url, attempted_targets - ) - ) - return ExitCodes.NO_PASS_CANDIDATES - - if len(candidates) == 1 and not arguments.always_show_selection: - selection = candidates.pop() - else: - selection = dmenu(sorted(candidates), arguments.dmenu_invocation) - - # Nothing was selected, simply return - if not selection: - return ExitCodes.SUCCESS - - # If username-target is path and user asked for username-only, we don't need to run pass. - # Or if using otp-only, it will run pass on its own. - secret = None - if ( - not (arguments.username_target == "path" and arguments.username_only) - and not arguments.otp_only - ): - secret = pass_(selection) - username_target = selection if arguments.username_target == "path" else secret - try: - if arguments.username_only: - fake_key_raw(extract_username(username_target, arguments.username_pattern)) - elif arguments.password_only: - fake_key_raw(extract_password(secret, arguments.password_pattern)) - elif arguments.otp_only: - otp = pass_otp(selection) - fake_key_raw(otp) - else: - # Enter username and password using fake-key and (which seems to work almost universally), then switch - # back into insert-mode, so the form can be directly submitted by hitting enter afterwards - fake_key_raw(extract_username(username_target, arguments.username_pattern)) - qute_command("fake-key ") - fake_key_raw(extract_password(secret, arguments.password_pattern)) - except CouldNotMatchPassword as e: - stderr("Failed to match password, target: secret, error: {}".format(e)) - return ExitCodes.COULD_NOT_MATCH_PASSWORD - except CouldNotMatchUsername as e: - stderr( - "Failed to match username, target: {}, error: {}".format( - arguments.username_target, e - ) - ) - return ExitCodes.COULD_NOT_MATCH_USERNAME - - if arguments.insert_mode: - qute_command("mode-enter insert") - - return ExitCodes.SUCCESS - - -if __name__ == "__main__": - arguments = argument_parser.parse_args() - sys.exit(main(arguments)) diff --git a/ar/.local/share/qutebrowser/userscripts/translate b/ar/.local/share/qutebrowser/userscripts/translate deleted file mode 100755 index 25c66dd..0000000 --- a/ar/.local/share/qutebrowser/userscripts/translate +++ /dev/null @@ -1,116 +0,0 @@ -#! /usr/bin/env python3 - -import argparse -import json -import os -import sys -import urllib.parse - -import requests - - -def js(message): - return f""" - (function() {{ - var box = document.createElement('div'); - box.style.position = 'fixed'; - box.style.bottom = '10px'; - box.style.right = '10px'; - box.style.backgroundColor = 'white'; - box.style.color = 'black'; - box.style.borderRadius = '8px'; - box.style.padding = '10px'; - box.style.boxShadow = '0 2px 10px rgba(0,0,0,0.2)'; - box.style.zIndex = '10000'; - box.innerText = decodeURIComponent("{message}"); - document.body.appendChild(box); - - function removeBox(event) {{ - if (!box.contains(event.target)) {{ - box.remove(); - document.removeEventListener('click', removeBox); - }} - }} - document.addEventListener('click', removeBox); - }})(); - """ - - -def translate_google(text, target_lang): - encoded_text = urllib.parse.quote(text) - response = requests.get( - f"https://translate.googleapis.com/translate_a/single?client=gtx&sl=auto&tl={target_lang}&dt=t&q={encoded_text}" - ) - response_json = json.loads(response.text) - translated_text = "" - for i in response_json[0]: - translated_text += i[0] - return translated_text - - -def translate_libretranslate(text, url, key, target_lang): - response = requests.post( - f"{url}/translate", - data={"q": text, "source": "auto", "target": target_lang, "api_key": key}, - ) - return response.json()["translatedText"] - - -def main(): - parser = argparse.ArgumentParser( - description="Translate text using different providers." - ) - parser.add_argument( - "--provider", - choices=["google", "libretranslate"], - required=False, - default="google", - help="Translation provider to use", - ) - parser.add_argument( - "--libretranslate_url", - required=False, - default="https://libretranslate.com", - help="URL for LibreTranslate API", - ) - parser.add_argument( - "--libretranslate_key", - required=False, - default="", - help="API key for LibreTranslate", - ) - parser.add_argument( - "--target_lang", - required=False, - default="en", - help="Target language for translation", - ) - args = parser.parse_args() - - qute_fifo = os.getenv("QUTE_FIFO") - if not qute_fifo: - sys.stderr.write( - f"Error: {sys.argv[0]} can not be run as a standalone script.\n" - ) - sys.stderr.write( - "It is a qutebrowser userscript. In order to use it, call it using 'spawn --userscript' as described in qute://help/userscripts.html\n" - ) - sys.exit(1) - - text = os.getenv("QUTE_SELECTED_TEXT", "") - - if args.provider == "google": - translated_text = translate_google(text, args.target_lang) - elif args.provider == "libretranslate": - translated_text = translate_libretranslate( - text, args.libretranslate_url, args.libretranslate_key, args.target_lang - ) - - js_code = js(urllib.parse.quote(translated_text)).replace("\n", " ") - - with open(qute_fifo, "a") as fifo: - fifo.write(f"jseval -q {js_code}\n") - - -if __name__ == "__main__": - main() diff --git a/global/.local/share/qutebrowser/greasemonkey/0x0.css.js b/global/.local/share/qutebrowser/greasemonkey/0x0.css.js new file mode 100644 index 0000000..ec10275 --- /dev/null +++ b/global/.local/share/qutebrowser/greasemonkey/0x0.css.js @@ -0,0 +1,29 @@ +// ==UserScript== +// @name 0x0.st +// @include *://0x0.st* +// ==/UserScript== + +/* ~/.config/qutebrowser/greasemonkey/0x0.css.js :: */ + +GM_addStyle(` + body { + background: var(--color-bg) !important; + color: var(--color-fg) !important; + font-size: var(--font-size) !important; + } + + u { + text-decoration: none !important + } + + a { + color: var(--color-heading) !important; + text-decoration: none !important; + } + a:visited { + color: var(--color-link) !important; + } + a:hover { + color: var(--color-active) !important; + } +`); diff --git a/global/.local/share/qutebrowser/greasemonkey/arstechnica.css.js b/global/.local/share/qutebrowser/greasemonkey/arstechnica.css.js new file mode 100644 index 0000000..723a7e4 --- /dev/null +++ b/global/.local/share/qutebrowser/greasemonkey/arstechnica.css.js @@ -0,0 +1,21 @@ +// ==UserScript== +// @name Ars Technica +// @include *://arstechnica.com/* +// ==/UserScript== + +/* ~/.config/qutebrowser/greasemonkey/arstechnica.css.js :: */ + +GM_addStyle(` + .ad.ad.ad, .ad_wrapper, .ad-wrapper { + display: none !important; + } + .listing-top.with-feature .article.top-feature figure .listing, + .listing-top.with-feature .article.top-latest figure .listing, + .listing-top.with-feature .article figure .listing, + .listing-earlier .article figure .listing, + .listing-latest .article figure .listing, + .listing-rest .article figure .listing, + .with-xrail .xrail .featured-video .video-thumbnail { + background: none; + } +`); diff --git a/global/.local/share/qutebrowser/greasemonkey/cnn-lite.css.js b/global/.local/share/qutebrowser/greasemonkey/cnn-lite.css.js new file mode 100644 index 0000000..8c2c507 --- /dev/null +++ b/global/.local/share/qutebrowser/greasemonkey/cnn-lite.css.js @@ -0,0 +1,31 @@ +// ==UserScript== +// @name CNN Lite +// @include *://lite.cnn.com* +// ==/UserScript== + +/* ~/.config/qutebrowser/greasemonkey/cnn-lite.css.js :: */ + +GM_addStyle(` + body { + color: var(--color-fg) !important; + background: var(--color-bg) !important; + } + + a, footer a:visited, header a:visited { + color: var(--color-heading) !important; + text-decoration: none !important; + } + + a:visited { + color: var(--color-link) !important; + } + + a:hover, footer a:hover, header a:hover { + color: var(--color-active) !important; + } + + ul { + list-style-type: none !important; + padding-inline-start: unset !important; + } +`); diff --git a/global/.local/share/qutebrowser/greasemonkey/csmonitor-text.css.js b/global/.local/share/qutebrowser/greasemonkey/csmonitor-text.css.js new file mode 100644 index 0000000..92a491d --- /dev/null +++ b/global/.local/share/qutebrowser/greasemonkey/csmonitor-text.css.js @@ -0,0 +1,43 @@ +// ==UserScript== +// @name Christian Science Monitor Text Edition +// @include *://www.csmonitor.com/text_edition* +// ==/UserScript== + +/* ~/.config/qutebrowser/greasemonkey/csmonitor-text.css.js :: */ + +GM_addStyle(` + body, footer { + background: var(--color-bg) !important; + color: var(--color-fg) !important; + } + + div[data-field='summary'] { + color: var(--color-fg) !important; + } + + u { + text-decoration: none !important + } + + a, .content-title>* { + border: none !important; + transition: none !important; + -webkit-transition: none !important; + } + + a, footer a:visited, .top-navigation a:visited, a:visited.navbar-brand { + color: var(--color-heading) !important; + text-decoration: none !important; + } + a:visited { + color: var(--color-link) !important; + } + a:hover, footer a:hover, .top-navigation a:hover, a:hover.navbar-brand { + color: var(--color-active) !important; + } + + span[data-view='kicker'], h2 + small, .underlined, + .footer-logo, #issn, .footer-social-links { + display: none !important; + } +`); diff --git a/global/.local/share/qutebrowser/greasemonkey/dienet.css.js b/global/.local/share/qutebrowser/greasemonkey/dienet.css.js new file mode 100644 index 0000000..7031d05 --- /dev/null +++ b/global/.local/share/qutebrowser/greasemonkey/dienet.css.js @@ -0,0 +1,67 @@ +// ==UserScript== +// @name die.net +// @include *://linux.die.net* +// @include *://die.net* +// @include *://www.die.net* +// ==/UserScript== + +/* ~/.config/qutebrowser/greasemonkey/dienet.css.js :: */ + +GM_addStyle(` + body { + background: var(--color-bg) !important; + color: var(--color-fg) !important; + } + #logo, #menu { + background: var(--color-bg1) !important; + color: var(--color-fg) !important; + border: none !important; + } + + #bg { + max-width: unset !important; + } + + #content { + font-family: var(--font-family) !important; + font-size: var(--font-size) !important; + } + + h1 { + border: none !important; + } + + h1, h2, h3, h4, h5, h6 { + font-size: var(--font-size) !important; + color: var(--color-heading) !important; + padding: 0 !important; + margin-top: 2ch !important; + margin-bottom: 0 !important; + } + + b { + color: var(--color-heading) !important; + } + + input { + background: var(--color-bg) !important; + color: var(--color-code) !important; + border-color: 2px solid var(--color-bar) !important; + } + + a { + color: var(--color-link) !important ; + text-decoration: none !important; + } + a:hover { + color: var(--color-active) !important; + text-decoration: none !important; + } + #logo a, #menu a { + background: none !important; + } + + img[alt='Back'], #adright, #cse-search-box { + display: none !important; + } +`); diff --git a/global/.local/share/qutebrowser/greasemonkey/dir.css.js b/global/.local/share/qutebrowser/greasemonkey/dir.css.js new file mode 100644 index 0000000..59ed68e --- /dev/null +++ b/global/.local/share/qutebrowser/greasemonkey/dir.css.js @@ -0,0 +1,72 @@ +// ==UserScript== +// @name local directory +// @include file://*/ +// ==/UserScript== + +/* ~/.config/qutebrowser/greasemonkey/dir.css.js :: */ + +var header = document.getElementById('header'); +var text = header.textContent.slice(9); +header.textContent = text; +document.title = text; + +if (text != '/') { + var table = document.getElementsByTagName('table')[0]; + var row = table.insertRow(1); + var cell = row.insertCell(); + var a = document.createElement('a'); + var updir = document.createTextNode('../'); + a.href = '../'; + a.appendChild(updir); + cell.appendChild(a); +}; + +GM_addStyle(` + * { + border: none !important; + margin: 0px !important; + padding: 0px !important; + color: var(--color-fg) !important; + background: var(--color-bg) !important; + font-family: var(--font-family) !important; + font-size: var(--font-size) !important; + text-decoration: none !important; + } + + body { + display: block !important; + color: var(--color-fg) !important; + background-color: var(--color-bg) !important; + font-style: none !important; + font-weight: normal !important; + padding-left: 1ch !important; + padding-right: 1ch !important; + } + + h1 { + border-color: var(--color-heading) !important; + color: var(--color-heading) !important; + display: table !important; + font-weight: bold !important; + border-bottom: solid !important; + border-width: 2ch !important; + border-image: var(--box1-heading) !important; + } + + a { + color: var(--color-link) !important ; + } + + a:hover { + color: var(--color-active) !important; + } + + td { + padding-right: 2ch !important; + } + + #parentDirLinkBox, #parentDirLink, #parentDirText, + thead, #theader, td:nth-child(2), td:nth-child(3) { + display: none !important; + } +`); diff --git a/global/.local/share/qutebrowser/greasemonkey/fandom.css.js b/global/.local/share/qutebrowser/greasemonkey/fandom.css.js new file mode 100644 index 0000000..e52987a --- /dev/null +++ b/global/.local/share/qutebrowser/greasemonkey/fandom.css.js @@ -0,0 +1,27 @@ +// ==UserScript== +// @name Fandom +// @include *://*.fandom.com/* +// ==/UserScript== + +/* ~/.config/qutebrowser/greasemonkey/fandom.css.js :: */ + +GM_addStyle(` + div[itemprop=video], + #WikiaBar, + #mixed-content-footer, + .bottom-ads-container, + .fandom-sticky-header.is-visible, + .page__right-rail, + .top-ads-container { + display: none !important; + } + + .main-container { + background: #ffffff !important; + } + + body.theme-fandomdesktop-dark .main-page .mcwiki-header { + background: none !important; + border: none !important; + } +`); diff --git a/global/.local/share/qutebrowser/greasemonkey/git-scm.css.js b/global/.local/share/qutebrowser/greasemonkey/git-scm.css.js new file mode 100644 index 0000000..4451840 --- /dev/null +++ b/global/.local/share/qutebrowser/greasemonkey/git-scm.css.js @@ -0,0 +1,38 @@ +// ==UserScript== +// @name git-scm +// @include *://git-scm.com* +// ==/UserScript== + +/* ~/.config/qutebrowser/greasemonkey/git-scm.css.js :: */ + +GM_addStyle(` + * { + font-family: var(--font-family) !important; + } + + body { + background: var(--color-bg) !important; + } + + #masthead, #main { + background: var(--color-bg1) !important; + } + + code, pre { + background: var(--color-bg) !important; + color: var(--color-code) !important; + } + + h1, h2, h3, h4, h5, h6 { + color: var(--color-heading) !important; + } + + a { + color: var(--color-link) !important; + transition: none !important; + } + a:hover { + color: var(--color-active) !important; + } + +`); diff --git a/global/.local/share/qutebrowser/greasemonkey/google.css.js b/global/.local/share/qutebrowser/greasemonkey/google.css.js new file mode 100644 index 0000000..eea39c2 --- /dev/null +++ b/global/.local/share/qutebrowser/greasemonkey/google.css.js @@ -0,0 +1,12 @@ +// ==UserScript== +// @name Google +// @include *://*.google.com/* +// ==/UserScript== + +/* ~/.config/qutebrowser/greasemonkey/google.css.js :: */ + +GM_addStyle(` + #tadsb, #taw, .cu-container { + display: none !important; + } +`); diff --git a/global/.local/share/qutebrowser/greasemonkey/imdb.css.js b/global/.local/share/qutebrowser/greasemonkey/imdb.css.js new file mode 100644 index 0000000..a21bc01 --- /dev/null +++ b/global/.local/share/qutebrowser/greasemonkey/imdb.css.js @@ -0,0 +1,12 @@ +// ==UserScript== +// @name IMDB +// @include *://*.imdb.com/* +// ==/UserScript== + +/* ~/.config/qutebrowser/greasemonkey/imdb.css.js :: */ + +GM_addStyle(` + .ipc-overflowText-overlay { + background: none !important; + } +`); diff --git a/global/.local/share/qutebrowser/greasemonkey/leadertelegram.css.js b/global/.local/share/qutebrowser/greasemonkey/leadertelegram.css.js new file mode 100644 index 0000000..3fabb6e --- /dev/null +++ b/global/.local/share/qutebrowser/greasemonkey/leadertelegram.css.js @@ -0,0 +1,18 @@ +// ==UserScript== +// @name Leader Telegram +// @include *://*.leadertelegram.com/* +// ==/UserScript== + +/* ~/.config/qutebrowser/greasemonkey/leadertelegram.css.js :: */ + +GM_addStyle(` + #app, #asset-below, #main-bottom-container, #main-top-container, + #site-footer-container, #site-header, #site-header-container, + #sticky-anchor, #tncms-region-article_bottom, #tncms-region-front-full-top, + .ad-col, .dfp-ad, .fixed-col-right, .grecaptcha-badge, .header-promo, + .hidden-print, .main-sidebar, .modal-body, .navbar-header, .nav-home, + .not-logged-in, .paging-link, .row-senary, .site-logo-container, + .subscription-required, .tnt-ads, .tnt-photo-purchase, .tnt-stack { + display: none !important; + } +`); diff --git a/global/.local/share/qutebrowser/greasemonkey/manpages.css.js b/global/.local/share/qutebrowser/greasemonkey/manpages.css.js new file mode 100644 index 0000000..a013076 --- /dev/null +++ b/global/.local/share/qutebrowser/greasemonkey/manpages.css.js @@ -0,0 +1,75 @@ +// ==UserScript== +// @name Man Pages +// @include *://man7.org/* +// @include *://man.freebsd.org/cgi/man.cgi* +// ==/UserScript== + +/* ~/.config/qutebrowser/greasemonkey/man7.css.js :: */ + +GM_addStyle(` + * { + background: var(--color-bg) !important; + color: var(--color-fg) !important; + font-family: Hack, Hack-Regular, monospace !important; + font-size: var(--font-size) !important; + } + + h1, h2, h3, h4, h5, h6 { + color: var(--color-heading) !important; + padding: 0 !important; + margin-top: 2ch !important; + margin-bottom: 0 !important; + } + + a { + color: var(--color-link) !important ; + background: var(--color-bg) !important; + text-decoration: none !important; + } + a:hover { + color: var(--color-active) !important; + text-decoration: none !important; + } + + b { + color: var(--color-heading) !important; + font-weight: normal !important; + } + + i { + color: var(--color-active) !important; + font-style: normal !important; + } + + hr, hr.nav-end { + border: none !important; + clear: both !important; + border-bottom: solid !important; + border-image: var(--box2-comment) !important; + border-width: 2ch !important; + color: var(--color-comment) !important; + border-color: var(--color-comment) !important; + margin-bottom: 0 !important; + } + + input, button, select { + border-color: var(--color-comment) !important; + border-style: solid !important; + } + + #container { + width: 100% !important; + margin-left: 1ch !important; + margin-right: 1ch !important; + } + + .footer, .top-link, td.search-box, hr.start-footer, hr.end-footer, + .nav-bar, hr.nav-end, #header, #headercontainer, #footer { + display: none !important; + } + + pre { + margin-top: 0 !important; + } + +`); diff --git a/global/.local/share/qutebrowser/greasemonkey/npr-text.css.js b/global/.local/share/qutebrowser/greasemonkey/npr-text.css.js new file mode 100644 index 0000000..6f5020f --- /dev/null +++ b/global/.local/share/qutebrowser/greasemonkey/npr-text.css.js @@ -0,0 +1,33 @@ +// ==UserScript== +// @name NPR Text-Only +// @include *://text.npr.org* +// ==/UserScript== + +/* ~/.config/qutebrowser/greasemonkey/npr-text.css.js :: */ + +GM_addStyle(` + body { + background: var(--color-bg) !important; + color: var(--color-fg) !important; + max-width: 750px !important; + } + + u { + text-decoration: none !important + } + + a { + color: var(--color-heading) !important; + text-decoration: none !important; + } + a:visited { + color: var(--color-link) !important; + } + a:hover { + color: var(--color-active) !important; + } + + .hr-line { + display: none !important; + } +`); diff --git a/global/.local/share/qutebrowser/greasemonkey/opengroup.css.js b/global/.local/share/qutebrowser/greasemonkey/opengroup.css.js new file mode 100644 index 0000000..fdce0d3 --- /dev/null +++ b/global/.local/share/qutebrowser/greasemonkey/opengroup.css.js @@ -0,0 +1,50 @@ +// ==UserScript== +// @name Open Group Publications +// @include https://pubs.opengroup.org/onlinepubs* +// ==/UserScript== + +/* ~/.config/qutebrowser/greasemonkey/opengroup.css.js :: */ + +var hrs = document.getElementsByTagName('hr'); +for (let i = 0; i < hrs.length; i++) { + while(hrs[i].attributes.length > 0) { + hrs[i].removeAttributeNode(hrs[i].attributes[0]); + }; +}; + +GM_addStyle(` + body { + background: var(--color-bg) !important; + color: var(--color-fg) !important; + } + + ul, li, table { + color: unset !important; + background: unset !important; + } + + hr { + border-top: 2px solid var(--color-bar) !important; + color: var(--color-bar) !important; + } + + a { + color: var(--color-heading) !important; + text-decoration: none !important; + } + a:visited { + color: var(--color-link) !important; + } + a:hover { + color: var(--color-active) !important; + } + + h1, h2, h3, h4, h5, h6 { + color: var(--color-code) !important; + background: unset !important; + } + + .topOfPage { + display: none !important; + } +`); diff --git a/global/.local/share/qutebrowser/greasemonkey/rarbg.css.js b/global/.local/share/qutebrowser/greasemonkey/rarbg.css.js new file mode 100644 index 0000000..16e4666 --- /dev/null +++ b/global/.local/share/qutebrowser/greasemonkey/rarbg.css.js @@ -0,0 +1,12 @@ +// ==UserScript== +// @name RARBG +// @include *://rarbg.to/* +// ==/UserScript== + +/* ~/.config/qutebrowser/greasemonkey/rarbg.css.js :: */ + +GM_addStyle(` + body { + background: none !important; + } +`); diff --git a/global/.local/share/qutebrowser/greasemonkey/reddit.css.js b/global/.local/share/qutebrowser/greasemonkey/reddit.css.js new file mode 100644 index 0000000..9677090 --- /dev/null +++ b/global/.local/share/qutebrowser/greasemonkey/reddit.css.js @@ -0,0 +1,41 @@ +// ==UserScript== +// @name Reddit +// @include *://*.reddit.com/* +// ==/UserScript== + +/* ~/.config/qutebrowser/greasemonkey/reddit.css.js :: */ + +GM_addStyle(` + body, body:before, textarea, #header, #siteTable, .comment, .commentarea, + .option, .side, .sitetable, .titlebox, .usertext-body { + background: var(--color-bg) !important; + background-image: none !important; + color: var(--color-fg) !important; + } + + #sr-header-area { + background: var(--color-bg1) !important; + } + #sr-header-area a { + color: var(--color-heading) !important ; + } + #sr-header-area a:hover { + color: var(--color-active) !important; + } + + a { + color: var(--color-heading) !important ; + text-decoration: none !important; + } + a:visited { + color: var(--color-link) !important ; + } + a:hover { + color: var(--color-active) !important; + } + + .account-activity-box, .premium-banner, .premium-banner-outer, .promoted, + .promotedlink, .redesign-beta-optin, .sidebox.create { + display: none !important; + } +`); diff --git a/global/.local/share/qutebrowser/greasemonkey/smbc-comics.css.js b/global/.local/share/qutebrowser/greasemonkey/smbc-comics.css.js new file mode 100644 index 0000000..926559c --- /dev/null +++ b/global/.local/share/qutebrowser/greasemonkey/smbc-comics.css.js @@ -0,0 +1,31 @@ +// ==UserScript== +// @name SMBC +// @include *://*.smbc-comics.com/* +// ==/UserScript== + +/* ~/.config/qutebrowser/greasemonkey/smbc-comics.css.js :: */ + +GM_addStyle(` + body { + background: var(--color-bg) !important; + } + + #mainwrap { + border: none !important; + background: none !important; + padding: 0px !important; + } + + #comicleft { + float: none !important; + margin: auto !important; + } + + #blogarea, #blogheader, #blogmsgmobile, #boardleader, #buythis, + #comicright, #commentarea, #comment-space, #footer, #header, #hw-jumpbar, + #midleader, #mobad1, #mobaftercomic, #mobfacebook, #mobilefooter, + #mobilemenu, #mobilepermalink, #mobtumblr, #mobtwitter, + #navtop + script + a, #permalink, #sharebar, #sharemob, .cc-tagline { + display: none !important; + } +`); diff --git a/global/.local/share/qutebrowser/greasemonkey/stackexchange.css.js b/global/.local/share/qutebrowser/greasemonkey/stackexchange.css.js new file mode 100644 index 0000000..845b0a6 --- /dev/null +++ b/global/.local/share/qutebrowser/greasemonkey/stackexchange.css.js @@ -0,0 +1,44 @@ +// ==UserScript== +// @name Stack Exchange +// @include *://stackexchange.com* +// @include *://*.stackexchange.com* +// @include *://stackoverflow.com* +// @include *://mathoverflow.net* +// @include *://superuser.com* +// @include *://askubuntu.com* +// @include *://serverfault.com* +// ==/UserScript== + +/* ~/.config/qutebrowser/greasemonkey/stackexchange.css.js :: */ + +GM_addStyle(` + html, body, .s-sidebarwidget { + background: var(--color-bg) !important; + } + #content, header { + background: var(--color-bg1) !important; + border: 2px solid var(--color-bar) !important; + } + .s-sidebarwidget--header { + background: var(--color-bg1) !important; + } + .s-btn { + background: none !important; + } + + a { + color: var(--color-heading) !important; + text-decoration: none !important; + transition: none !important; + } + a:visited { + color: var(--color-link) !important; + } + a:hover { + color: var(--color-active) !important; + } + + .js-overflowai-cta { + display: none !important; + } +`); diff --git a/global/.local/share/qutebrowser/greasemonkey/termbin.css.js b/global/.local/share/qutebrowser/greasemonkey/termbin.css.js new file mode 100644 index 0000000..0c559aa --- /dev/null +++ b/global/.local/share/qutebrowser/greasemonkey/termbin.css.js @@ -0,0 +1,32 @@ +// ==UserScript== +// @name termbin +// @include *://termbin.com* +// ==/UserScript== + +/* ~/.config/qutebrowser/greasemonkey/termbin.css.js :: */ + +GM_addStyle(` + body { + background: var(--color-bg) !important; + color: var(--color-fg) !important; + } + + pre { + font-size: var(--font-size) !important; + } + + u { + text-decoration: none !important + } + + a { + color: var(--color-heading) !important; + text-decoration: none !important; + } + a:visited { + color: var(--color-link) !important; + } + a:hover { + color: var(--color-active) !important; + } +`); diff --git a/global/.local/share/qutebrowser/greasemonkey/wiki.css.js b/global/.local/share/qutebrowser/greasemonkey/wiki.css.js new file mode 100644 index 0000000..301f85e --- /dev/null +++ b/global/.local/share/qutebrowser/greasemonkey/wiki.css.js @@ -0,0 +1,33 @@ +// ==UserScript== +// @name ArchWiki/Wikimedia +// @include *://*.wikibooks.org/* +// @include *://*.wikidata.org/* +// @include *://*.wikimedia.org/* +// @include *://*.wikinews.org/* +// @include *://*.wikipedia.org/* +// @include *://*.wikiquote.org/* +// @include *://*.wikisource.org/* +// @include *://*.wikiversity.org/* +// @include *://*.wikivoyage.org/* +// @include *://*.wiktionary.org/* +// @include *://wiki.archlinux.org/* +// ==/UserScript== + +/* ~/.config/qutebrowser/greasemonkey/wiki.css.js :: */ + +GM_addStyle(` + body, #mw-head, #mw-panel, .mw-list-item { + background: #ffffff !important; + } + .vector-menu-heading, .vector-menu-tabs a, .vector-menu-tabs, + .vector-toc::after { + background: none !important; + } + + .vector-menu-heading { + border-bottom: 1px solid #606060 !important; + } + .cn-fundraising { + display: none !important; + } +`); diff --git a/global/.local/share/qutebrowser/greasemonkey/xkcd.css.js b/global/.local/share/qutebrowser/greasemonkey/xkcd.css.js new file mode 100644 index 0000000..2dfaa1d --- /dev/null +++ b/global/.local/share/qutebrowser/greasemonkey/xkcd.css.js @@ -0,0 +1,44 @@ +// ==UserScript== +// @name xkcd +// @include *://xkcd.com/* +// ==/UserScript== + +/* ~/.config/qutebrowser/greasemonkey/xkcd.css.js :: */ + +var content = document.getElementById('middleContainer'); +content.innerHTML = content.innerHTML.split('
')[0] + '

\n'; + +GM_addStyle(` + body, #middleContainer { + background: var(--color-bg) !important; + color: var(--color-fg) !important; + } + + #bottom, + #topContainer { + display: none !important; + } + + ul.comicNav li a { + background: var(--color-bar) !important; + border: none !important; + box-shadow: none !important; + -mox-box-shadow: none !important; + -webkit-box-shadow: none !important; + } + + .box { + border: none !important; + } + + a { + text-decoration: none !important; + transition: none !important; + } + a, a:visited { + color: var(--color-link) !important; + } + a:hover { + color: var(--color-active) !important; + } +`); diff --git a/global/.local/share/qutebrowser/greasemonkey/ycombinator.css.js b/global/.local/share/qutebrowser/greasemonkey/ycombinator.css.js new file mode 100644 index 0000000..cdc02a2 --- /dev/null +++ b/global/.local/share/qutebrowser/greasemonkey/ycombinator.css.js @@ -0,0 +1,74 @@ +// ==UserScript== +// @name Hacker News +// @include *://news.ycombinator.com* +// ==/UserScript== + +/* ~/.config/qutebrowser/greasemonkey/ycominator.css.js :: */ + +var style = getComputedStyle(document.body) +var colorBg = style.getPropertyValue('--color-bg') +var colorBg1 = style.getPropertyValue('--color-bg1') +var colorBar = style.getPropertyValue('--color-bar') + +var hnmain = document.getElementById('hnmain'); +hnmain.style.background = colorBg1; + +var tds = document.getElementsByTagName('td'); +for (let i = 0; i < tds.length; i++) { + if (tds[i].bgColor.toLowerCase() == '#ff6600') { + tds[i].bgColor = colorBar; + }; +}; + +var imgs = document.getElementsByTagName('img'); +for (let i = 0; i < imgs.length; i++) { + imgs[i].src = 'data:,'; +}; + +GM_addStyle(` + body, td, input, textarea, .default, .title, .pagetop, .comment { + font-size: 14px !important; + } + .admin, .admin td { + font-size: 12px !important; + } + .subtext, .subtext td { + font-size: 10px !important; + } + + body, input, textarea { + background: var(--color-bg) !important; + } + body { + color: var(--color-fg) !important; + } + input, textarea { + color: var(--color-bar) !important; + border-color: var(--color-bar) !important; + border-style: solid !important; + } + + input[type='submit'] { + background: var(--color-bar) !important; + border-color: var(--color-bg) !important; + color: var(--color-heading) !important; + } + input[type='submit']:hover { + background: var(--color-bg1) !important; + border-color: var(--color-bar) !important; + border-style: solid !important; + color: var(--color-active) !important; + } + + a, .pagetop a:visited, .yclinks a:visited, + a[href='https://www.ycombinator.com/apply/']:visited { + color: var(--color-heading) !important; + } + a:visited { + color: var(--color-link) !important; + } + a:hover, .pagetop a:hover, .yclinks a:hover, + a[href='https://www.ycombinator.com/apply/']:hover { + color: var(--color-active) !important; + } +`); diff --git a/global/.local/share/qutebrowser/greasemonkey/youtube-ads.js b/global/.local/share/qutebrowser/greasemonkey/youtube-ads.js new file mode 100644 index 0000000..21d4214 --- /dev/null +++ b/global/.local/share/qutebrowser/greasemonkey/youtube-ads.js @@ -0,0 +1,23 @@ +// ==UserScript== +// @name Skip YouTube ads +// @description Skips the ads in YouTube videos +// @run-at document-start +// @include *.youtube.com/* +// ==/UserScript== + +document.addEventListener( + "load", + () => { + const btn = document.querySelector( + ".videoAdUiSkipButton,.ytp-ad-skip-button-modern", + ); + if (btn) { + btn.click(); + } + const ad = [...document.querySelectorAll(".ad-showing")][0]; + if (ad) { + document.querySelector("video").currentTime = 9999999999; + } + }, + true, +); diff --git a/global/.local/share/qutebrowser/greasemonkey/youtube.css.js b/global/.local/share/qutebrowser/greasemonkey/youtube.css.js new file mode 100644 index 0000000..e86edf9 --- /dev/null +++ b/global/.local/share/qutebrowser/greasemonkey/youtube.css.js @@ -0,0 +1,18 @@ +// ==UserScript== +// @name YouTube +// @include *://*.youtube.com/* +// ==/UserScript== + +/* ~/.config/qutebrowser/greasemonkey/youtube.css.js :: */ + +document.addEventListener('load', () => { + try { document.querySelector('.ad-showing video').currentTime = 99999 } catch {} + try { document.querySelector('.ytp-ad-skip-button').click() } catch {} +}, true); + +GM_addStyle(` + ytd-compact-promoted-video-renderer, .ytd-action-companion-ad-renderer, + .ytd-ad-slot-renderer, .ytd-promoted-sparkles-web-renderer { + display: none !important; + } +`); diff --git a/global/.local/share/qutebrowser/userscripts/add-nextcloud-bookmarks b/global/.local/share/qutebrowser/userscripts/add-nextcloud-bookmarks new file mode 100755 index 0000000..2a480cc --- /dev/null +++ b/global/.local/share/qutebrowser/userscripts/add-nextcloud-bookmarks @@ -0,0 +1,173 @@ +#!/usr/bin/env python3 + +""" +Behavior: + A qutebrowser userscript that creates bookmarks in Nextcloud's Bookmarks app. + +Requirements: + requests + +userscript setup: + Optionally create ~/.config/qutebrowser/add-nextcloud-bookmarks.ini like: + +[nextcloud] +HOST=https://nextcloud.example.com +USER=username +;PASSWORD=lamepassword +DESCRIPTION=None +;TAGS=just-one +TAGS=read-me-later,added-by-qutebrowser, Another-One + + If settings aren't in the configuration file, the user will be prompted during + bookmark creation. If DESCRIPTION and TAGS are set to None, they will be left + blank. If the user does not want to be prompted for a password, it is recommended + to set up an 'app password'. See the following for instructions: + https://docs.nextcloud.com/server/latest/user_manual/en/session_management.html#managing-devices # noqa: E501 + +qutebrowser setup: + add bookmark via hints + config.bind('X', 'hint links userscript add-nextcloud-bookmarks') + + add bookmark of current URL + config.bind('X', 'spawn --userscript add-nextcloud-bookmarks') + +troubleshooting: + Errors detected within this userscript will have an exit of 231. All other + exit codes will come from requests. +""" + +import configparser +from json import dumps +from os import environ, path +from sys import argv, exit + +from PyQt6.QtWidgets import QApplication, QInputDialog, QLineEdit +from requests import get, post +from requests.auth import HTTPBasicAuth + + +def get_text(name, info): + """Get input from the user.""" + _app = QApplication(argv) # noqa: F841 + if name == "password": + text, ok = QInputDialog.getText( + None, + "add-nextcloud-bookmarks userscript", + "Please enter {}".format(info), + QLineEdit.EchoMode.Password, + ) + else: + text, ok = QInputDialog.getText( + None, "add-nextcloud-bookmarks userscript", "Please enter {}".format(info) + ) + if not ok: + message("info", "Dialog box canceled.") + exit(0) + return text + + +def message(level, text): + """display message""" + with open(environ["QUTE_FIFO"], "w") as fifo: + fifo.write( + 'message-{} "add-nextcloud-bookmarks userscript: {}"\n'.format(level, text) + ) + fifo.flush() + + +if "QUTE_FIFO" not in environ: + print( + "This script is designed to run as a qutebrowser userscript, " + "not as a standalone script." + ) + exit(231) + +if "QUTE_CONFIG_DIR" not in environ: + if "XDG_CONFIG_HOME" in environ: + QUTE_CONFIG_DIR = environ["XDG_CONFIG_HOME"] + "/qutebrowser" + else: + QUTE_CONFIG_DIR = environ["HOME"] + "/.config/qutebrowser" +else: + QUTE_CONFIG_DIR = environ["QUTE_CONFIG_DIR"] + +config_file = QUTE_CONFIG_DIR + "/add-nextcloud-bookmarks.ini" +if path.isfile(config_file): + config = configparser.ConfigParser() + config.read(config_file) + settings = dict(config.items("nextcloud")) +else: + settings = {} + +settings_info = [ + ("host", "host information.", "required"), + ("user", "username.", "required"), + ("password", "password.", "required"), + ("description", "description or leave blank", "optional"), + ("tags", "tags (comma separated) or leave blank", "optional"), +] + +# check for settings that need user interaction and clear optional setting if need be +for setting in settings_info: + if setting[0] not in settings: + userInput = get_text(setting[0], setting[1]) + settings[setting[0]] = userInput + if setting[2] == "optional": + if settings[setting[0]] == "None": + settings[setting[0]] = "" + +tags = settings["tags"].split(",") + +QUTE_URL = environ["QUTE_URL"] +api_url = settings["host"] + "/index.php/apps/bookmarks/public/rest/v2/bookmark" + +auth = HTTPBasicAuth(settings["user"], settings["password"]) +headers = {"Content-Type": "application/json"} +params = {"url": QUTE_URL} + +# check if there is already a bookmark for the URL +r = get( + api_url, + auth=auth, + headers=headers, + params=params, + timeout=(3.05, 27), +) +if r.status_code != 200: + message( + "error", + "Could not connect to {} with status code {}".format( + settings["host"], r.status_code + ), + ) + exit(r.status_code) + +try: + r.json()["data"][0]["id"] +except IndexError: + pass +else: + message("info", "bookmark already exists for {}".format(QUTE_URL)) + exit(0) + +if environ["QUTE_MODE"] == "hints": + QUTE_TITLE = QUTE_URL +else: + QUTE_TITLE = environ["QUTE_TITLE"] + +# JSON format +# https://nextcloud-bookmarks.readthedocs.io/en/latest/bookmark.html#create-a-bookmark +dict = { + "url": QUTE_URL, + "title": QUTE_TITLE, + "description": settings["description"], + "tags": tags, +} +data = dumps(dict) + +r = post(api_url, data=data, headers=headers, auth=auth, timeout=(3.05, 27)) + +if r.status_code == 200: + message("info", "bookmark {} added".format(QUTE_URL)) +else: + message("error", "something went wrong {} bookmark not added".format(QUTE_URL)) + exit(r.status_code) diff --git a/global/.local/share/qutebrowser/userscripts/add-nextcloud-cookbook b/global/.local/share/qutebrowser/userscripts/add-nextcloud-cookbook new file mode 100755 index 0000000..1510907 --- /dev/null +++ b/global/.local/share/qutebrowser/userscripts/add-nextcloud-cookbook @@ -0,0 +1,131 @@ +#!/usr/bin/env python3 + +""" +Behavior: + A qutebrowser userscript that adds recipes to Nextcloud's Cookbook app. + +Requirements: + requests + +userscript setup: + Optionally create ~/.config/qutebrowser/add-nextcloud-cookbook.ini like: + +[nextcloud] +HOST=https://nextcloud.example.com +USER=username +;PASSWORD=lamepassword + + If settings aren't in the configuration file, the user will be prompted. + If the user does not want to be prompted for a password, it is recommended + to set up an 'app password' with 'Allow filesystem access' enabled. + See the following for instructions: + https://docs.nextcloud.com/server/latest/user_manual/en/session_management.html#managing-devices # noqa: E501 + +qutebrowser setup: + add recipe via hints + config.bind('X', 'hint links userscript add-nextcloud-cookbook') + + add recipe of current URL + config.bind('X', 'spawn --userscript add-nextcloud-cookbook') + +troubleshooting: + Errors detected within this userscript will have an exit of 231. All other + exit codes will come from requests. +""" + +import configparser +from os import environ, path +from sys import argv, exit + +from PyQt6.QtWidgets import QApplication, QInputDialog, QLineEdit +from requests import post +from requests.auth import HTTPBasicAuth + + +def get_text(name, info): + """Get input from the user.""" + _app = QApplication(argv) # noqa: F841 + if name == "password": + text, ok = QInputDialog.getText( + None, + "add-nextcloud-cookbook userscript", + "Please enter {}".format(info), + QLineEdit.EchoMode.Password, + ) + else: + text, ok = QInputDialog.getText( + None, "add-nextcloud-cookbook userscript", "Please enter {}".format(info) + ) + if not ok: + message("info", "Dialog box canceled.") + exit(0) + return text + + +def message(level, text): + """display message""" + with open(environ["QUTE_FIFO"], "w") as fifo: + fifo.write( + "message-{} 'add-nextcloud-cookbook userscript: {}'\n".format(level, text) + ) + fifo.flush() + + +if "QUTE_FIFO" not in environ: + print( + "This script is designed to run as a qutebrowser userscript, " + "not as a standalone script." + ) + exit(231) + +if "QUTE_CONFIG_DIR" not in environ: + if "XDG_CONFIG_HOME" in environ: + QUTE_CONFIG_DIR = environ["XDG_CONFIG_HOME"] + "/qutebrowser" + else: + QUTE_CONFIG_DIR = environ["HOME"] + "/.config/qutebrowser" +else: + QUTE_CONFIG_DIR = environ["QUTE_CONFIG_DIR"] + +config_file = QUTE_CONFIG_DIR + "/add-nextcloud-cookbook.ini" +if path.isfile(config_file): + config = configparser.ConfigParser() + config.read(config_file) + settings = dict(config.items("nextcloud")) +else: + settings = {} + +settings_info = [ + ("host", "host information.", "required"), + ("user", "username.", "required"), + ("password", "password.", "required"), +] + +# check for settings that need user interaction +for setting in settings_info: + if setting[0] not in settings: + userInput = get_text(setting[0], setting[1]) + settings[setting[0]] = userInput + +api_url = settings["host"] + "/index.php/apps/cookbook/import" +headers = {"Content-Type": "application/x-www-form-urlencoded"} +auth = HTTPBasicAuth(settings["user"], settings["password"]) +data = "url=" + environ["QUTE_URL"] + +message("info", "starting to process {}".format(environ["QUTE_URL"])) + +r = post(api_url, data=data, headers=headers, auth=auth, timeout=(3.05, 27)) + +if r.status_code == 200: + message("info", "recipe from {} added.".format(environ["QUTE_URL"])) + exit(0) +elif r.status_code == 500: + message("warning", "Cookbook app reports {}".format(r.text)) + exit(0) +else: + message( + "error", + "Could not connect to {} with status code {}".format( + settings["host"], r.status_code + ), + ) + exit(r.status_code) diff --git a/global/.local/share/qutebrowser/userscripts/qr b/global/.local/share/qutebrowser/userscripts/qr new file mode 100755 index 0000000..8421524 --- /dev/null +++ b/global/.local/share/qutebrowser/userscripts/qr @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +pngfile=$(mktemp --suffix=.png) +trap 'rm -f "$pngfile"' EXIT + +qrencode -t PNG -o "$pngfile" -s 10 "$QUTE_URL" +echo ":open -t file:///$pngfile" >> "$QUTE_FIFO" +sleep 1 # give qutebrowser time to open the file before it gets removed diff --git a/global/.local/share/qutebrowser/userscripts/qute-pass b/global/.local/share/qutebrowser/userscripts/qute-pass new file mode 100755 index 0000000..6b071b8 --- /dev/null +++ b/global/.local/share/qutebrowser/userscripts/qute-pass @@ -0,0 +1,411 @@ +#!/usr/bin/env python3 + +# SPDX-FileCopyrightText: Chris Braun (cryzed) +# +# SPDX-License-Identifier: GPL-3.0-or-later + +""" +Insert login information using pass and a dmenu-compatible application (e.g. dmenu, rofi -dmenu, ...). A short +demonstration can be seen here: https://i.imgur.com/KN3XuZP.gif. +""" + +USAGE = """The domain of the site has to appear as a segment in the pass path, +for example: "github.com/cryzed" or "websites/github.com". Alternatively the +parameter `--unfiltered` may be used to get a list of all passwords. How the +username and password are determined is freely configurable using the CLI +arguments. As an example, if you instead store the username as part of the +secret (and use a site's name as filename), instead of the default configuration, +use `--username-target secret` and `--username-pattern "username: (.+)"`. + +The login information is inserted by emulating key events using qutebrowser's +fake-key command in this manner: [USERNAME][PASSWORD], which is compatible +with almost all login forms. + +If you use gopass with multiple mounts, use the CLI switch --mode gopass to switch to gopass mode. + +Suggested bindings similar to Uzbl's `formfiller` script: + + config.bind('', 'spawn --userscript qute-pass') + config.bind('', 'spawn --userscript qute-pass --username-only') + config.bind('

', 'spawn --userscript qute-pass --password-only') + config.bind('', 'spawn --userscript qute-pass --otp-only') +""" + +EPILOG = """Dependencies: tldextract (Python 3 module), pass, pass-otp (optional). + +WARNING: The login details are viewable as plaintext in qutebrowser's debug log (qute://log) and might be shared if +you decide to submit a crash report!""" + +import argparse +import enum +import fnmatch +import functools +import os +import re +import shlex +import subprocess +import sys +import unicodedata +from urllib.parse import urlparse + +import idna +import tldextract + + +def expanded_path(path): + # Expand potential ~ in paths, since this script won't be called from a shell that does it for us + expanded = os.path.expanduser(path) + # Add trailing slash if not present + return os.path.join(expanded, "") + + +argument_parser = argparse.ArgumentParser( + description=__doc__, usage=USAGE, epilog=EPILOG +) +argument_parser.add_argument("url", nargs="?", default=os.getenv("QUTE_URL")) +argument_parser.add_argument( + "--password-store", + "-p", + default=expanded_path(os.getenv("PASSWORD_STORE_DIR", default="~/.password-store")), + help="Path to your pass password-store (only used in pass-mode)", + type=expanded_path, +) +argument_parser.add_argument( + "--mode", + "-M", + choices=["pass", "gopass"], + default="pass", + help="Select mode [gopass] to use gopass instead of the standard pass.", +) +argument_parser.add_argument( + "--prefix", + type=str, + help="Search only the given subfolder of the store (only used in gopass-mode)", +) +argument_parser.add_argument( + "--username-pattern", + "-u", + default=r".*/(.+)", + help="Regular expression that matches the username", +) +argument_parser.add_argument( + "--username-target", + "-U", + choices=["path", "secret"], + default="path", + help="The target for the username regular expression", +) +argument_parser.add_argument( + "--password-pattern", + "-P", + default=r"(.*)", + help="Regular expression that matches the password", +) +argument_parser.add_argument( + "--dmenu-invocation", + "-d", + default="dmenu", + help="Invocation used to execute a dmenu-provider", +) +argument_parser.add_argument( + "--no-insert-mode", + "-n", + dest="insert_mode", + action="store_false", + help="Don't automatically enter insert mode", +) +argument_parser.add_argument( + "--io-encoding", + "-i", + default="UTF-8", + help="Encoding used to communicate with subprocesses", +) +argument_parser.add_argument( + "--merge-candidates", + "-m", + action="store_true", + help="Merge pass candidates for fully-qualified and registered domain name", +) +argument_parser.add_argument( + "--extra-url-suffixes", + "-s", + default="", + help="Comma-separated string containing extra suffixes (e.g local)", +) +argument_parser.add_argument( + "--unfiltered", + dest="unfiltered", + action="store_true", + help="Show an unfiltered selection of all passwords in the store", +) +argument_parser.add_argument( + "--always-show-selection", + dest="always_show_selection", + action="store_true", + help="Always show selection, even if there is only a single match", +) +group = argument_parser.add_mutually_exclusive_group() +group.add_argument( + "--username-only", "-e", action="store_true", help="Only insert username" +) +group.add_argument( + "--password-only", "-w", action="store_true", help="Only insert password" +) +group.add_argument("--otp-only", "-o", action="store_true", help="Only insert OTP code") + +stderr = functools.partial(print, file=sys.stderr) + + +class ExitCodes(enum.IntEnum): + SUCCESS = 0 + FAILURE = 1 + # 1 is automatically used if Python throws an exception + NO_PASS_CANDIDATES = 2 + COULD_NOT_MATCH_USERNAME = 3 + COULD_NOT_MATCH_PASSWORD = 4 + + +class CouldNotMatchUsername(Exception): + pass + + +class CouldNotMatchPassword(Exception): + pass + + +def qute_command(command): + with open(os.environ["QUTE_FIFO"], "w") as fifo: + fifo.write(command + "\n") + fifo.flush() + + +# Encode candidate string parts as Internationalized Domain Name, doing +# Unicode normalization before. This allows to properly match (non-ASCII) +# pass entries with the corresponding domain names. +def idna_encode(name): + # Do Unicode normalization first, we use form NFKC because: + # 1. Use the compatibility normalization because these sequences have "the same meaning in some contexts" + # 2. idna.encode() below requires the Unicode strings to be in normalization form C + # See https://en.wikipedia.org/wiki/Unicode_equivalence#Normal_forms + unicode_normalized = unicodedata.normalize("NFKC", name) + # Empty strings can not be encoded, they appear for example as empty + # parts in split_path. If something like this happens, we just fall back + # to the unicode representation (which may already be ASCII then). + try: + idna_encoded = idna.encode(unicode_normalized) + except idna.IDNAError: + idna_encoded = unicode_normalized + return idna_encoded + + +def find_pass_candidates(domain, unfiltered=False): + candidates = [] + + if arguments.mode == "gopass": + gopass_args = ["gopass", "list", "--flat"] + if arguments.prefix: + gopass_args.append(arguments.prefix) + all_passwords = ( + subprocess.run(gopass_args, stdout=subprocess.PIPE) + .stdout.decode("UTF-8") + .splitlines() + ) + + for password in all_passwords: + if unfiltered or domain in password: + candidates.append(password) + else: + idna_domain = idna_encode(domain) + for path, directories, file_names in os.walk( + arguments.password_store, followlinks=True + ): + secrets = fnmatch.filter(file_names, "*.gpg") + if not secrets: + continue + + # Strip password store path prefix to get the relative pass path + pass_path = path[len(arguments.password_store) :] + split_path = pass_path.split(os.path.sep) + idna_split_path = [idna_encode(part) for part in split_path] + for secret in secrets: + secret_base = os.path.splitext(secret)[0] + idna_secret_base = idna_encode(secret_base) + if not unfiltered and idna_domain not in ( + idna_split_path + [idna_secret_base] + ): + continue + + # Append the unencoded Unicode path/name since this is how pass uses them + candidates.append(os.path.join(pass_path, secret_base)) + return candidates + + +def _run_pass(pass_arguments): + # The executable is conveniently named after it's mode [pass|gopass]. + pass_command = [arguments.mode] + env = os.environ.copy() + env["PASSWORD_STORE_DIR"] = arguments.password_store + process = subprocess.run( + pass_command + pass_arguments, env=env, stdout=subprocess.PIPE + ) + return process.stdout.decode(arguments.io_encoding).strip() + + +def pass_(path): + return _run_pass(["show", path]) + + +def pass_otp(path): + if arguments.mode == "gopass": + return _run_pass(["otp", "-o", path]) + return _run_pass(["otp", path]) + + +def dmenu(items, invocation): + command = shlex.split(invocation) + process = subprocess.run( + command, + input="\n".join(items).encode(arguments.io_encoding), + stdout=subprocess.PIPE, + ) + return process.stdout.decode(arguments.io_encoding).strip() + + +def fake_key_raw(text): + for character in text: + # Escape all characters by default, space requires special handling + sequence = '" "' if character == " " else r"\{}".format(character) + qute_command("fake-key {}".format(sequence)) + + +def extract_password(secret, pattern): + match = re.match(pattern, secret) + if not match: + raise CouldNotMatchPassword("Pattern did not match target") + try: + return match.group(1) + except IndexError: + raise CouldNotMatchPassword( + "Pattern did not contain capture group, please use capture group. Example: (.*)" + ) + + +def extract_username(target, pattern): + match = re.search(pattern, target, re.MULTILINE) + if not match: + raise CouldNotMatchUsername("Pattern did not match target") + try: + return match.group(1) + except IndexError: + raise CouldNotMatchUsername( + "Pattern did not contain capture group, please use capture group. Example: (.*)" + ) + + +def main(arguments): + if not arguments.url: + argument_parser.print_help() + return ExitCodes.FAILURE + + extractor = tldextract.TLDExtract( + extra_suffixes=arguments.extra_url_suffixes.split(",") + ) + extract_result = extractor(arguments.url) + + # Try to find candidates using targets in the following order: fully-qualified domain name (includes subdomains), + # the registered domain name, the IPv4 address if that's what the URL represents and finally the private domain + # (if a non-public suffix was used), and the URL netloc. + candidates = set() + attempted_targets = [] + + private_domain = "" + if not extract_result.suffix: + private_domain = ( + ".".join((extract_result.subdomain, extract_result.domain)) + if extract_result.subdomain + else extract_result.domain + ) + + netloc = urlparse(arguments.url).netloc + + for target in filter( + None, + [ + extract_result.fqdn, + extract_result.registered_domain, + extract_result.ipv4, + private_domain, + netloc, + ], + ): + attempted_targets.append(target) + target_candidates = find_pass_candidates( + target, unfiltered=arguments.unfiltered + ) + if not target_candidates: + continue + + candidates.update(target_candidates) + if not arguments.merge_candidates: + break + else: + if not candidates: + stderr( + "No pass candidates for URL {!r} found! (I tried {!r})".format( + arguments.url, attempted_targets + ) + ) + return ExitCodes.NO_PASS_CANDIDATES + + if len(candidates) == 1 and not arguments.always_show_selection: + selection = candidates.pop() + else: + selection = dmenu(sorted(candidates), arguments.dmenu_invocation) + + # Nothing was selected, simply return + if not selection: + return ExitCodes.SUCCESS + + # If username-target is path and user asked for username-only, we don't need to run pass. + # Or if using otp-only, it will run pass on its own. + secret = None + if ( + not (arguments.username_target == "path" and arguments.username_only) + and not arguments.otp_only + ): + secret = pass_(selection) + username_target = selection if arguments.username_target == "path" else secret + try: + if arguments.username_only: + fake_key_raw(extract_username(username_target, arguments.username_pattern)) + elif arguments.password_only: + fake_key_raw(extract_password(secret, arguments.password_pattern)) + elif arguments.otp_only: + otp = pass_otp(selection) + fake_key_raw(otp) + else: + # Enter username and password using fake-key and (which seems to work almost universally), then switch + # back into insert-mode, so the form can be directly submitted by hitting enter afterwards + fake_key_raw(extract_username(username_target, arguments.username_pattern)) + qute_command("fake-key ") + fake_key_raw(extract_password(secret, arguments.password_pattern)) + except CouldNotMatchPassword as e: + stderr("Failed to match password, target: secret, error: {}".format(e)) + return ExitCodes.COULD_NOT_MATCH_PASSWORD + except CouldNotMatchUsername as e: + stderr( + "Failed to match username, target: {}, error: {}".format( + arguments.username_target, e + ) + ) + return ExitCodes.COULD_NOT_MATCH_USERNAME + + if arguments.insert_mode: + qute_command("mode-enter insert") + + return ExitCodes.SUCCESS + + +if __name__ == "__main__": + arguments = argument_parser.parse_args() + sys.exit(main(arguments)) diff --git a/global/.local/share/qutebrowser/userscripts/translate b/global/.local/share/qutebrowser/userscripts/translate new file mode 100755 index 0000000..25c66dd --- /dev/null +++ b/global/.local/share/qutebrowser/userscripts/translate @@ -0,0 +1,116 @@ +#! /usr/bin/env python3 + +import argparse +import json +import os +import sys +import urllib.parse + +import requests + + +def js(message): + return f""" + (function() {{ + var box = document.createElement('div'); + box.style.position = 'fixed'; + box.style.bottom = '10px'; + box.style.right = '10px'; + box.style.backgroundColor = 'white'; + box.style.color = 'black'; + box.style.borderRadius = '8px'; + box.style.padding = '10px'; + box.style.boxShadow = '0 2px 10px rgba(0,0,0,0.2)'; + box.style.zIndex = '10000'; + box.innerText = decodeURIComponent("{message}"); + document.body.appendChild(box); + + function removeBox(event) {{ + if (!box.contains(event.target)) {{ + box.remove(); + document.removeEventListener('click', removeBox); + }} + }} + document.addEventListener('click', removeBox); + }})(); + """ + + +def translate_google(text, target_lang): + encoded_text = urllib.parse.quote(text) + response = requests.get( + f"https://translate.googleapis.com/translate_a/single?client=gtx&sl=auto&tl={target_lang}&dt=t&q={encoded_text}" + ) + response_json = json.loads(response.text) + translated_text = "" + for i in response_json[0]: + translated_text += i[0] + return translated_text + + +def translate_libretranslate(text, url, key, target_lang): + response = requests.post( + f"{url}/translate", + data={"q": text, "source": "auto", "target": target_lang, "api_key": key}, + ) + return response.json()["translatedText"] + + +def main(): + parser = argparse.ArgumentParser( + description="Translate text using different providers." + ) + parser.add_argument( + "--provider", + choices=["google", "libretranslate"], + required=False, + default="google", + help="Translation provider to use", + ) + parser.add_argument( + "--libretranslate_url", + required=False, + default="https://libretranslate.com", + help="URL for LibreTranslate API", + ) + parser.add_argument( + "--libretranslate_key", + required=False, + default="", + help="API key for LibreTranslate", + ) + parser.add_argument( + "--target_lang", + required=False, + default="en", + help="Target language for translation", + ) + args = parser.parse_args() + + qute_fifo = os.getenv("QUTE_FIFO") + if not qute_fifo: + sys.stderr.write( + f"Error: {sys.argv[0]} can not be run as a standalone script.\n" + ) + sys.stderr.write( + "It is a qutebrowser userscript. In order to use it, call it using 'spawn --userscript' as described in qute://help/userscripts.html\n" + ) + sys.exit(1) + + text = os.getenv("QUTE_SELECTED_TEXT", "") + + if args.provider == "google": + translated_text = translate_google(text, args.target_lang) + elif args.provider == "libretranslate": + translated_text = translate_libretranslate( + text, args.libretranslate_url, args.libretranslate_key, args.target_lang + ) + + js_code = js(urllib.parse.quote(translated_text)).replace("\n", " ") + + with open(qute_fifo, "a") as fifo: + fifo.write(f"jseval -q {js_code}\n") + + +if __name__ == "__main__": + main() diff --git a/global/.local/share/venvs/default-requirements.txt b/global/.local/share/venvs/default-requirements.txt index a92c5ed..f4a7360 100644 --- a/global/.local/share/venvs/default-requirements.txt +++ b/global/.local/share/venvs/default-requirements.txt @@ -19,6 +19,7 @@ pynvim pyperclip requests stig +torch trash-cli urlscan websocket-client -- cgit v1.2.3