View Single Post
Old 11-03-2025, 10:36 AM   #1
tentakel
Member
tentakel began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Mar 2019
Device: Kobo Clara HD
Here is a css fix for Articles in darkmode.

Hello all!

I noticed that instapaper articles don't render nicely in especially in dark mode.

Some headlines are rendered black on black, thus disappear and links lack contrast in my opinion.

This script walks through the subfolders of articles and injects a line of css that fixes the issues.

Code:
#!/bin/sh
BASE="/mnt/onboard/.kobo/articles"
STYLE='<style>a, p a { color: inherit !important; font-style: italic; text-decoration: none; border-bottom: 0.5px solid currentColor; padding-bottom: 0.05em; line-height: 1.1; } h1, h2, h3, h4 { color: inherit !important; }</style>'

find "$BASE" -mindepth 2 -maxdepth 2 -type f -name "index.html" | while IFS= read -r file; do
  if grep -q '<style>.*a, p a' "$file"; then
    echo "Skipping (already styled): $file"
  else
    echo "Injecting inline style into: $file"
    tmp="$(mktemp "${file%.html}.XXXX" 2>/dev/null || echo "${file}.tmp")"
    printf '%s\n' "$STYLE" > "$tmp" && cat "$file" >> "$tmp" && mv -f "$tmp" "$file"
  fi
done
I chained it with fix pocket images, which still works for instapaper :

Code:
menu_item:library:Fix Pocket Images:cmd_spawn:quiet:/bin/sh /mnt/onboard/.kobo/articles/inject-style.sh
  chain_success:cmd_spawn:quiet:/bin/sh /mnt/onboard/.adds/pocket/fix.sh
  chain_success:dbg_toast:Done
Question:
Which renderer is kobo using for articles? Obviously a one time patch would be more elegant; The patch for Kepub that should override a link style did not work for me in this case.

Best
tentakel is offline   Reply With Quote