gdh1995 / vimium-c

A keyboard shortcut browser extension for keyboard-based navigation and tab operations with an advanced omnibar
https://chrome.google.com/webstore/detail/vimium-c/hfjbmagddngcpeloejdejnfgbamkjaeg
Other
3.43k stars 253 forks source link

[PDF Viewer] breaks Dark Reader on PDF files #781

Open MahdiNazemi opened 2 years ago

MahdiNazemi commented 2 years ago

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

gdh1995 commented 2 years ago

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.

MahdiNazemi commented 2 years ago

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.

gdh1995 commented 2 years ago

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

MahdiNazemi commented 2 years ago

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.

gdh1995 commented 2 years ago

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

ericauld commented 1 year ago

+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 commented 1 year ago

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.

hacker-DOM commented 1 year ago

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!

gdh1995 commented 1 year ago

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.

ericauld commented 1 year ago

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.