darkreader: Don't invert dark pages

I couldn’t find an existing issue for this.

Currently the extension seems to blindly invert all pages, even ones that are already dark. Example: https://www.cs.ru.nl/~freek/fta/xindex.html

Perhaps it could check whether colours are already sufficiently dark before inverting them?

I know about dark_sites.json, but I’m talking about automatic detection of dark pages.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 8
  • Comments: 16 (6 by maintainers)

Most upvoted comments

I am working on a detection algorithm for dark pages, but it is not that easy, since it should be reliable and efficient for all/most pages. I got two approaches so far:

  1. Traverse DOM tree and determine background brightness of the biggest elements (which take the most screen space) and maybe foreground colors, too. Not that easy with transparency and possibly absolute positioned elements deeper in the DOM tree.
  2. Get pixel colors over screen. Probably randomly distributed over entire page for a compromise between accuracy and performance. But getting the image representation / pixel data of the page, like with captureVisibleTab, will probably already be too slow.

Currently, I am going for option 1, but the base is the same (color => brightness => dark/light), which I already got. If anybody has better ideas, I am thankful for suggestions or discussing the approach.