diff options
author | rnhmjoj <rnhmjoj@inventati.org> | 2021-03-08 17:40:57 +0100 |
---|---|---|
committer | rnhmjoj <rnhmjoj@inventati.org> | 2021-03-08 17:55:48 +0100 |
commit | 55fdae8eed0f93152b5676cca77b6243fd95d9b0 (patch) | |
tree | 6dcb8da4c8016a4f3743360f24a3404438fb343a | |
parent | 76b03db20eac1d9b52156191656d4c2adb290911 (diff) | |
download | qutebrowser-55fdae8eed0f93152b5676cca77b6243fd95d9b0.tar.gz qutebrowser-55fdae8eed0f93152b5676cca77b6243fd95d9b0.zip |
userscripts/readability: add unique body class
Until per-domains stylesheets are implemented, there is no way to
apply style to the readability page only. With this patch, you can
just use the global setting `content.user_stylesheets` by writing
a more specific CSS selector. For example:
body.qute-readability {
font-family: Libertinus;
font-size: 1.2em;
text-align: justify;
}
will change the font and text alignment of the readability page,
without altering the style of other websites.
-rwxr-xr-x | misc/userscripts/readability | 3 | ||||
-rwxr-xr-x | misc/userscripts/readability-js | 3 |
2 files changed, 6 insertions, 0 deletions
diff --git a/misc/userscripts/readability b/misc/userscripts/readability index f9cbbf829..a6a6f2d52 100755 --- a/misc/userscripts/readability +++ b/misc/userscripts/readability @@ -57,6 +57,9 @@ with codecs.open(os.environ['QUTE_HTML'], 'r', 'utf-8') as source: title = doc.title() content = doc.summary().replace('<html>', HEADER % title) + # add a class to make styling the page easier + content = content.replace('<body>', '<body class="qute-readability">') + with codecs.open(tmpfile, 'w', 'utf-8') as target: target.write(content.lstrip()) diff --git a/misc/userscripts/readability-js b/misc/userscripts/readability-js index 2f24e065d..532df51c6 100755 --- a/misc/userscripts/readability-js +++ b/misc/userscripts/readability-js @@ -131,6 +131,9 @@ getDOM(target, domOpts).then(dom => { let article = reader.parse(); let content = util.format(HEADER, article.title) + article.content; + // add a class to make styling the page easier + content = content.replace('<body>', '<body class="qute-readability">') + fs.writeFile(tmpFile, content, (err) => { if (err) { qute.messageError([`"${err}"`]) |