diff options
Diffstat (limited to '.config/qutebrowser')
-rwxr-xr-x | .config/qutebrowser/config.py | 94 | ||||
-rwxr-xr-x | .config/qutebrowser/greasemonkey/fandom-to-breezewiki.js | 21 | ||||
-rwxr-xr-x | .config/qutebrowser/greasemonkey/gensdeconfiance.js | 8 | ||||
-rwxr-xr-x | .config/qutebrowser/greasemonkey/gitlab.js | 18 | ||||
-rwxr-xr-x | .config/qutebrowser/greasemonkey/glassdoor.js | 3 | ||||
-rwxr-xr-x | .config/qutebrowser/greasemonkey/google.js | 13 | ||||
-rwxr-xr-x | .config/qutebrowser/greasemonkey/imgur-to-imgin.js | 2 | ||||
-rwxr-xr-x | .config/qutebrowser/greasemonkey/imgur-to-rimgo.js | 8 | ||||
-rwxr-xr-x | .config/qutebrowser/greasemonkey/instagram-to-bibliogram.js | 3 | ||||
-rwxr-xr-x | .config/qutebrowser/greasemonkey/linkedin.js | 59 | ||||
-rwxr-xr-x | .config/qutebrowser/greasemonkey/minimal-css.js | 16 | ||||
-rwxr-xr-x | .config/qutebrowser/greasemonkey/rarbg.js | 12 | ||||
-rwxr-xr-x | .config/qutebrowser/greasemonkey/teddit.js | 23 | ||||
-rwxr-xr-x | .config/qutebrowser/greasemonkey/yewtube.js | 9 |
14 files changed, 245 insertions, 44 deletions
diff --git a/.config/qutebrowser/config.py b/.config/qutebrowser/config.py index cd3695d..d9aaa8f 100755 --- a/.config/qutebrowser/config.py +++ b/.config/qutebrowser/config.py @@ -2,38 +2,75 @@ # ~/.config/qutebrowser/config.py # rgoncalves.se +import html import logging import os import re -import subprocess -import platform +import socket + +from PyQt5.QtCore import QUrl + +from qutebrowser.api import cmdutils +from qutebrowser.browser.urlmarks import ( + AlreadyExistsError as UrlAlreadyExistsError +) +from qutebrowser.browser.urlmarks import UrlMarkManager +from qutebrowser.config.config import ConfigContainer +from qutebrowser.config.configfiles import ConfigAPI +from qutebrowser.utils import message, objreg +from qutebrowser.utils.usertypes import PromptMode +from userscripts.urlmarks import urlmarkmanager_save + +config: ConfigAPI = config # noqa: F821 pylint: disable=E0602,C0103 +c: ConfigContainer = c # noqa: F821 pylint: disable=E0602,C0103 logging.basicConfig(level=logging.DEBUG) -""" -Bypass flake8 warnings. -""" -try: - config -except NameError: - config = None +UrlMarkManager.save = ( + lambda manager: urlmarkmanager_save(manager, config.configdir) +) -def is_musl_system(): - return bool(re.search('musl', os.popen("ldd /bin/ls").read())) +def is_musl_system() -> bool: + return bool(re.search('musl', os.popen('ldd /bin/ls').read())) -def select_qt_arguments(): + +def get_qt_arguments() -> list: """ Select best arguments for launching qutebrowser. Empty by default, it picks lag free options for musl systems. """ - args = [] - - if is_musl_system(): - args.append('disable-seccomp-filter-sandbox') - - return args + filters = { + 'disable-seccomp-filter-sandbox': is_musl_system() + } + + return list( + filter(lambda x: x, map(lambda x: x[1], list(filters.items()))) + ) + + +@cmdutils.register() +def bookmark_save(url: QUrl): + """Save the current page as a bookmark.""" + manager = objreg.get('bookmark-manager') + tags = message.ask( + title="Add bookmark:", + mode=PromptMode.text, + url=url.toString(QUrl.RemovePassword | QUrl.FullyEncoded), + text=( + "Please enter bookmark tags for<br/><b>" + f"{html.escape(url.toDisplayString())}</b>" + ), + ) + + if not tags: + return + + try: + manager.add(url, tags) + except UrlAlreadyExistsError: + message.warning("Bookmark already exists.") config.load_autoconfig(False) @@ -41,10 +78,8 @@ config.set('auto_save.session', True) config.set('scrolling.smooth', False) config.set('qt.highdpi', False) config.set('qt.force_software_rendering', 'none') -config.set('qt.args', select_qt_arguments()) -config.set('messages.timeout', 1000) - -config.bind(',m', 'spawn mpv {url}') +config.set('qt.args', get_qt_arguments()) +config.set('messages.timeout', 2500) config.set('content.images', True, 'chrome-devtools://*') config.set('content.images', True, 'devtools://*') @@ -57,6 +92,8 @@ config.set('content.notifications.enabled', False) config.set('content.notifications.enabled', True, '*://*.zoho.eu/*') config.set('content.notifications.enabled', True, '*://*.viperdev.io/*') config.set('content.notifications.enabled', True, '*://*.rgoncalves.se/*') +config.set('content.notifications.enabled', True, '*://app.slack.com/*') +config.set('content.notifications.enabled', True, '*://mail.google.com/*') config.set('content.register_protocol_handler', False) config.set('content.geolocation', False) @@ -93,13 +130,22 @@ config.set('content.prefers_reduced_motion', True) config.set('content.headers.referer', 'same-domain') config.set('url.default_page', 'https://lite.duckduckgo.com/lite/') config.set('url.start_pages', 'https://lite.duckduckgo.com/lite/') -config.set('url.searchengines', - {'DEFAULT': 'https://lite.duckduckgo.com/lite/?q={}'}) +config.set( + 'url.searchengines', {'DEFAULT': 'https://lite.duckduckgo.com/lite/?q={}'} +) config.set('downloads.location.directory', f'{os.environ["HOME"]}/downloads') +config.set('downloads.prevent_mixed_content', False) config.set('content.autoplay', False) config.set('content.cookies.accept', 'no-3rdparty') +config.set('content.javascript.alert', False) config.set('content.headers.do_not_track', False, '*://*.thetrainline.com/*') config.set('content.blocking.enabled', False, '*://*.thetrainline.com/*') config.set('content.cookies.accept', 'all', '*://*.thetrainline.com/*') + +config.bind(',m', 'spawn mpv {url}') +config.bind('M', 'bookmark-save {url}') + +if socket.gethostname() == 'work-01': + config.set('fonts.default_size', '14pt') diff --git a/.config/qutebrowser/greasemonkey/fandom-to-breezewiki.js b/.config/qutebrowser/greasemonkey/fandom-to-breezewiki.js new file mode 100755 index 0000000..59369f5 --- /dev/null +++ b/.config/qutebrowser/greasemonkey/fandom-to-breezewiki.js @@ -0,0 +1,21 @@ +// ==UserScript== +// @name fandom to breezewiki +// @match *://*.fandom.com/* +// @grant none +// @run-at document-start +// ==/UserScript== + +BREEZEWIKI_INSTANCE = "breezewiki.pussthecat.org" + +url = location.href +url = url.replace(/\bwww\.\b/, "") +host = location.hostname +path = location.pathname +if (url.includes("/wiki/")) { + // this is bad + location.href = "https://" + BREEZEWIKI_INSTANCE + "/" + host.split(".")[0] + path +} +else { + url = url.replace("fandom.com", BREEZEWIKI_ISNTANCE) + location.href = url +} diff --git a/.config/qutebrowser/greasemonkey/gensdeconfiance.js b/.config/qutebrowser/greasemonkey/gensdeconfiance.js new file mode 100755 index 0000000..8e62a30 --- /dev/null +++ b/.config/qutebrowser/greasemonkey/gensdeconfiance.js @@ -0,0 +1,8 @@ +// ==UserScript== +// @name gensdeconfiance +// @match https://gensdeconfiance.com/* +// @run-at document-end +// @grant none +// ==/UserScript== + +document.getElementById('react-paywall').remove() diff --git a/.config/qutebrowser/greasemonkey/gitlab.js b/.config/qutebrowser/greasemonkey/gitlab.js new file mode 100755 index 0000000..5ebb8a3 --- /dev/null +++ b/.config/qutebrowser/greasemonkey/gitlab.js @@ -0,0 +1,18 @@ +// ==UserScript== +// @name gitlab +// @match *://*/* +// @run-at document-end +// @grant none +// ==/UserScript== + +(async function unwrap(subgroups) { + await new Promise(resolve => setTimeout(resolve, 600)); + for (subgroup of subgroups) { + if (! subgroup.classList.contains("has-children")) { + continue; + } + subgroup.click() + unwrap(subgroup.getElementsByClassName("group-row has-children")); + } + return +})(document.getElementsByClassName("group-row has-children")); diff --git a/.config/qutebrowser/greasemonkey/glassdoor.js b/.config/qutebrowser/greasemonkey/glassdoor.js index e6e44fc..664448c 100755 --- a/.config/qutebrowser/greasemonkey/glassdoor.js +++ b/.config/qutebrowser/greasemonkey/glassdoor.js @@ -1,6 +1,7 @@ // ==UserScript== // @name glassdoor // @match https://*.glassdoor.com/* +// @match https://*.glassdoor.ch/* // @match https://*.glassdoor.fr/* // @run-at document-end // @grant none @@ -20,5 +21,3 @@ window.addEventListener('load', function() { ]; functions.forEach(f => f()); }); - -console.log('aaaaaaaaaaaaa'); diff --git a/.config/qutebrowser/greasemonkey/google.js b/.config/qutebrowser/greasemonkey/google.js new file mode 100755 index 0000000..b410eff --- /dev/null +++ b/.config/qutebrowser/greasemonkey/google.js @@ -0,0 +1,13 @@ +// ==UserScript== +// @name custom google +// @match https://www.google.com/* +// @grant none +// ==/UserScript== + +(function() { + 'use strict'; + + document.querySelectorAll('.ads-ad').forEach(function(e){ + e.remove(); + }); +})(); diff --git a/.config/qutebrowser/greasemonkey/imgur-to-imgin.js b/.config/qutebrowser/greasemonkey/imgur-to-imgin.js index d4ac434..1263eb5 100755 --- a/.config/qutebrowser/greasemonkey/imgur-to-imgin.js +++ b/.config/qutebrowser/greasemonkey/imgur-to-imgin.js @@ -5,4 +5,4 @@ // @run-at document-start // ==/UserScript== -top.location.hostname = "imgin.voidnet.tech"; +// top.location.hostname = "imgin.voidnet.tech"; diff --git a/.config/qutebrowser/greasemonkey/imgur-to-rimgo.js b/.config/qutebrowser/greasemonkey/imgur-to-rimgo.js new file mode 100755 index 0000000..d0735cb --- /dev/null +++ b/.config/qutebrowser/greasemonkey/imgur-to-rimgo.js @@ -0,0 +1,8 @@ +// ==UserScript== +// @name imgur to rimgo +// @match *://imgur.com/* +// @grant none +// @run-at document-start +// ==/UserScript== + +top.location.hostname = "rimgo.pussthecat.org"; diff --git a/.config/qutebrowser/greasemonkey/instagram-to-bibliogram.js b/.config/qutebrowser/greasemonkey/instagram-to-bibliogram.js index a608059..53f11ee 100755 --- a/.config/qutebrowser/greasemonkey/instagram-to-bibliogram.js +++ b/.config/qutebrowser/greasemonkey/instagram-to-bibliogram.js @@ -5,4 +5,5 @@ // @run-at document-start // ==/UserScript== -top.location.hostname = "bibliogram.art"; +top.location.hostname = "bibliogram.pussthecat.org"; +// document.getElementsByClassName('explanation')[0].getElementsByTagName('a')[0].click() diff --git a/.config/qutebrowser/greasemonkey/linkedin.js b/.config/qutebrowser/greasemonkey/linkedin.js new file mode 100755 index 0000000..b8468ec --- /dev/null +++ b/.config/qutebrowser/greasemonkey/linkedin.js @@ -0,0 +1,59 @@ +// ==UserScript== +// @name linkedin css +// @match *://*.linkedin.com/* +// @grant none +// @inject-into content +// ==/UserScript== + +(function() { + 'use strict'; + + // Selectors + const storySelector = '.feed-shared-update-v2'; + const descriptionSelector = '.feed-shared-actor__description, .feed-shared-actor__sub-description'; + + // Search strings + const searchStrings = { + 'da': ['Promoveret'], + 'en': ['Promoted'], + 'es': ['Promocionado'], + 'fr': ['Post sponsorisé'] + }; + + const language = searchStrings.hasOwnProperty(document.documentElement.lang) ? document.documentElement.lang : 'en'; + + function blockSponsoredPosts() { + const stories = document.querySelectorAll(storySelector); + for (const story of stories) { + if (story.style.display == 'none') { + continue; + } + + const descriptions = story.querySelectorAll(descriptionSelector); + for (const description of descriptions) { + + const descriptionContent = description.innerText.trim(); + if (searchStrings[language].find(searchString => searchString == descriptionContent)) { + + console.debug('Blocked sponsored story', story); + story.style.display = 'none'; + } + } + } + } + + const observer = new MutationObserver(blockSponsoredPosts); + observer.observe(document.body, { + 'childList': true, + 'subtree': true + }); + + blockSponsoredPosts(); + + GM_addStyle(` + .scaffold-layout__aside { + visibility: hidden; + } + `) + +})(); diff --git a/.config/qutebrowser/greasemonkey/minimal-css.js b/.config/qutebrowser/greasemonkey/minimal-css.js deleted file mode 100755 index 1fe1414..0000000 --- a/.config/qutebrowser/greasemonkey/minimal-css.js +++ /dev/null @@ -1,16 +0,0 @@ -// ==UserScript== -// @name minimal css -// @match *://www.google.com -// @match *://www.google.com/search* -// @match *://cliq.zoho.eu/chats/* -// @match *://www.pinterest.com/* -// @grant none -// ==/UserScript== - -GM_addStyle(` - * { - border-radius: 0px !important; - transition: none !important; - animation: none !important; - } -`) diff --git a/.config/qutebrowser/greasemonkey/rarbg.js b/.config/qutebrowser/greasemonkey/rarbg.js new file mode 100755 index 0000000..cb99969 --- /dev/null +++ b/.config/qutebrowser/greasemonkey/rarbg.js @@ -0,0 +1,12 @@ +// ==UserScript== +// @name rarbg css +// @match *://rarbg.to/* +// @match *://rarbgaccessed.org/* +// @grant none +// ==/UserScript== + +GM_addStyle(` + div:last-of-type { + z-index: -1 !important; + } +`) diff --git a/.config/qutebrowser/greasemonkey/teddit.js b/.config/qutebrowser/greasemonkey/teddit.js new file mode 100755 index 0000000..2e9c829 --- /dev/null +++ b/.config/qutebrowser/greasemonkey/teddit.js @@ -0,0 +1,23 @@ +// ==UserScript== +// @name yewtube +// @match *://*.teddit.net/* +// @match *://teddit.net/* +// @grant none +// @run-at document-start +// ==/UserScript== + +document.cookie = "post_media_max_height=medium"; +document.cookie = "flairs=true"; +document.cookie = "highlight_controversial=true"; +document.cookie = "show_upvotes=true"; +document.cookie = "collapse_child_comments=false"; +document.cookie = "nsfw_enabled=false"; +document.cookie = "show_upvoted_percentage=false"; +document.cookie = "videos_muted=true"; +document.cookie = "show_large_gallery_images=true"; +document.cookie = "domain_twitter="; +document.cookie = "domain_youtube="; +document.cookie = "domain_instagram="; +document.cookie = "prefer_frontpage=true"; +document.cookie = "default_comment_sort=best"; +document.cookie = "theme=white"; diff --git a/.config/qutebrowser/greasemonkey/yewtube.js b/.config/qutebrowser/greasemonkey/yewtube.js new file mode 100755 index 0000000..0362a7b --- /dev/null +++ b/.config/qutebrowser/greasemonkey/yewtube.js @@ -0,0 +1,9 @@ +// ==UserScript== +// @name yewtube +// @match *://*.yewtu.be/* +// @match *://yewtu.be/* +// @grant none +// @run-at document-start +// ==/UserScript== + +document.cookie = "PREFS=%7B%22annotations%22%3Afalse%2C%22annotations_subscribed%22%3Afalse%2C%22autoplay%22%3Atrue%2C%22automatic_instance_redirect%22%3Afalse%2C%22captions%22%3A%5B%22%22%2C%22%22%2C%22%22%5D%2C%22comments%22%3A%5B%22youtube%22%2C%22reddit%22%5D%2C%22continue%22%3Afalse%2C%22continue_autoplay%22%3Atrue%2C%22dark_mode%22%3A%22%22%2C%22latest_only%22%3Afalse%2C%22listen%22%3Afalse%2C%22local%22%3Atrue%2C%22watch_history%22%3Afalse%2C%22vr_mode%22%3Atrue%2C%22show_nick%22%3Afalse%2C%22locale%22%3A%22en-US%22%2C%22region%22%3A%22US%22%2C%22max_results%22%3A40%2C%22notifications_only%22%3Afalse%2C%22player_style%22%3A%22invidious%22%2C%22quality%22%3A%22dash%22%2C%22quality_dash%22%3A%221080p%22%2C%22default_home%22%3A%22Popular%22%2C%22feed_menu%22%3A%5B%22Popular%22%2C%22Trending%22%5D%2C%22related_videos%22%3Atrue%2C%22sort%22%3A%22published%22%2C%22speed%22%3A1%2C%22thin_mode%22%3Afalse%2C%22unseen_only%22%3Afalse%2C%22video_loop%22%3Afalse%2C%22extend_desc%22%3Afalse%2C%22volume%22%3A50%2C%22save_player_pos%22%3Afalse%7D"; |