Skip to content

Instantly share code, notes, and snippets.

@olmokramer
Created September 6, 2018 22:53
Show Gist options
  • Save olmokramer/fe23c8cdd29a8b567343aa575e5cdeaa to your computer and use it in GitHub Desktop.
Save olmokramer/fe23c8cdd29a8b567343aa575e5cdeaa to your computer and use it in GitHub Desktop.
Qutebrowser per-domain stylesheets
c.content.user_stylesheets = ['/path/to/reddit.user.css']
# or if you have a directory with .user.css files:
import glob
c.content.user_stylesheets = glob.glob('/path/to/*.user.css')
// ==UserScript==
// @name DomainStyles
// @namespace https://github.com/olmokramer
// @description Make it possible to use per-domain stylesheets.
// @include *
// @run-at document-start
// @version 2
// @author Olmo Kramer
// ==/UserScript==
(function IIFE() {
'use strict';
document.addEventListener('readystatechange', function onReadyStateChange() {
if (document.readyState == 'interactive') {
const doc = document.documentElement;
doc.setAttribute('data-qb-url', window.location.href);
doc.setAttribute('data-qb-domain', window.location.host);
}
});
})();
/* Sticky header. */
[data-qb-domain="www.reddit.com"] #header,
[data-qb-domain="old.reddit.com"] #header {
position: sticky !important;
top: 0 !important;
z-index: 1000 !important;
}
[data-qb-domain="www.reddit.com"] #sr-header-area,
[data-qb-domain="old.reddit.com"] #sr-header-area {
position: relative !important;
z-index: 1000 !important;
}
@Granitosaurus
Copy link

is there a way to bypass restrictive security policy here?
It throws errors like this:

fused to apply inline style because it violates the following Content Security Policy directive: "style-src 'self' https://fosstodon.org 'nonce-jJa91KgPpC7r9LwolMHHxQ=='". Either the 'unsafe-inline' keyword, a hash ('sha256-0GRPHCxZARgw5+MFOj1rhn5QEX7s9YZP98ffIKJKFiU='), or a nonce ('nonce-...') is required to enable inline execution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment