vimium-c icon indicating copy to clipboard operation
vimium-c copied to clipboard

[PDF Viewer] breaks Dark Reader on PDF files

Open MahdiNazemi opened this issue 3 years ago • 10 comments

Describe the bug

When a PDF file is opened with Brave's default PDF viewer, Dark Reader can invert the colors in dark mode. However, when using PDF Viewer for Vimium C, the PDF's colors remain the same regardless of Dark Reader's light/dark mode.

Browser, OS, and Vimium C versions

  • Browser name: Brave
  • Browser version: 1.45.116 Chromium: 107.0.5304.91
  • PDF Viewer for Vimium C version: 2.15.349
  • OS name and version: macOS 13.0

MahdiNazemi avatar Nov 02 '22 02:11 MahdiNazemi

The PDF Viewer for Vimium C itself supports color themes and you can make it dark on its Options dialog.

image

There's no way to bypass this conflict, because an extension can not modify another extension's tabs directly.

gdh1995 avatar Nov 02 '22 03:11 gdh1995

Thanks for the explanation.

My theme is set to the system's, but the PDF is still black-on-white. Based on your answer, I suspect there is no solution for this.

MahdiNazemi avatar Nov 02 '22 03:11 MahdiNazemi

Um dark reader can not modify "system-level (browser-level) color theme", while it just simulates the effects.

gdh1995 avatar Nov 02 '22 03:11 gdh1995

I found that adding the following CSS to PDF.js would make the background of PDFs black and their text white (source):

#viewerContainer > #viewer > .page > .canvasWrapper > canvas {
    filter: grayscale(100%);
    filter: invert(100%);
}

Adding an option to inject custom CSS in PDF Viewer for Vimium C would allow users to customize the looks of their PDFs.

MahdiNazemi avatar Nov 02 '22 13:11 MahdiNazemi

This will break image displaying. Maybe I can add it when I have a longer rest.

gdh1995 avatar Nov 02 '22 13:11 gdh1995

+1, anything to allow darker pdf's would be great. I'm using Vivaldi, and it has a feature to simply invert the colors on the page, and it usually works for pdf's, but it doesn't work in PDF Viewer for Vimium C. Strangely, other, similar features still work, like changing to sepia-toned colors. (Vivaldi calls these "filters")

ericauld avatar Feb 22 '23 16:02 ericauld

Do you know whether allowing "filter invert" in Vivaldi for the pdf viewer would be a simple PR I could put up? Happy to contribute if so.

ericauld avatar Mar 07 '23 18:03 ericauld

I'm also curious about this. maybe @gdh1995 can help us understand how it works under the hood? Does the PDF extension kind of take-over the entire tab, so that Dark Reader (which injects some css afaict?) cannot modify it

Btw, is the PDF extension open-source (eg, is it somewhere in this repo)? Thanks!

hacker-DOM avatar May 17 '23 16:05 hacker-DOM

Dark Reader is just an "extension" and then it can not affect other extensions including PDF Viewer. The way that Vimium C works on PDF Viewer for Vimium C requires special handling in the two extensions.

BTW, Chrome has a plan to force extensions to use Manifest V3, and when it lands, PDF Viewer for Vimium C may fail to work with Vimium C - I've filed a bug report about the shortage of Manifest V3, but the Chromium team doesn't care it.

gdh1995 avatar May 25 '23 14:05 gdh1995

Coming back to this after a while. Do you know whether there's a simple way to allow "filter invert" to work with PDF Viewer? I notice that "filter sepia" works fine.

ericauld avatar Jun 07 '23 00:06 ericauld