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.
This commit is contained in:
rnhmjoj 2021-03-08 17:40:57 +01:00
parent 76b03db20e
commit 55fdae8eed
No known key found for this signature in database
GPG Key ID: BFBAF4C975F76450
2 changed files with 6 additions and 0 deletions

View File

@ -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())

View File

@ -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}"`])