shivaprsd / doqment

Mozilla's HTML5 PDF Viewer with Reader-mode add-on. πŸ“–
https://shivaprsd.github.io/doqment/src/pdfjs/web/viewer.html
MIT License
33 stars 1 forks source link

Need to set PDF.js preferences #2

Closed MagicalDrizzle closed 6 months ago

MagicalDrizzle commented 1 year ago

It seems that since pdf.js only honors prefers-color-scheme, setting privacy.resistFingerprinting = true will force it to be white, and people have been asking for a manual dark mode toggle for quite a while: https://github.com/mozilla/pdf.js/issues/12290

The official pdf.js team however seems to have made a pref specifically for this, but that doesn't apply to doqment for obvious reasons

Could a manual toggle be implemented?

shivaprsd commented 1 year ago

Thanks for pointing this out! I did know of that pref, but I did not know about privacy.resistFingerprinting and its effect on prefers-color-scheme.

I would be hard-pressed to implement a manual toggle; even the original maintainers could not find a way to modify the needed CSS dynamically – see https://github.com/mozilla/pdf.js/pull/12625#issue-743267748. πŸ™ƒ

A wider-scoped workaround would be to provide an Options page to set the pref, as well as the other prefs. This has been wanting since v0.1 and I've been planning to add one on the lines of the PDF.js Chrome extension.

Will the Options page cover your use-case well enough? It would be quickly accessible, by right-clicking on the doqment button on the toolbar.

MagicalDrizzle commented 1 year ago

it'd definitely be good enough!

provide an Options page to set the pref, as well as the other prefs.

oh that was what I meant by "manual toggle" oops

also not having a toggle and having the dark theme only accessible by prefers-color-scheme is my biggest gripe of quite a few extensions that are like, out for my eyes (onetab being the biggest offender :p) that was not directed at you by any means btw

shivaprsd commented 1 year ago

Great!

oh that was what I meant by "manual toggle" oops

In the linked issue, somebody was asking for a manual toggle button on the toolbar itself, so I thought you meant that. πŸ˜…

~This should be ready by v0.3~.

shivaprsd commented 1 year ago

I am deferring this to a future release. The Options page would need some work, and I have other finished features to ship.

Meanwhile, you can always have a dark Reader theme even when the PDF.js toolbars and stuff are light. doqment's prefs are separate from PDF.js's, and they are directly set from the toolbar.

MagicalDrizzle commented 1 year ago

May I ask if you still have plan to work on this?

shivaprsd commented 1 year ago

@MagicalDrizzle Sorry about that! I'm sort of too busy to work on it at the moment. πŸ˜₯

Meanwhile can you try the method given in https://github.com/shivaprsd/doqment/issues/5#issuecomment-1421103657? You'll have to execute something like:

PDFViewerApplication.preferences.set('viewerCssTheme', 2)    /* for dark */

It's not as convenient as an options page, still, better than nothing for the time being.

MagicalDrizzle commented 1 year ago

@shivaprsd It just returns a not defined error for me... not defined

shivaprsd commented 1 year ago

@MagicalDrizzle Can you tell me what OS & browser you use and their versions? And also the version of doqment?

The code should be executed in the console opened for a doqment tab, with or without any PDF loaded. But I guess you are doing just that, looking at the screenshot. I am curious why it shouldn't work.

MagicalDrizzle commented 1 year ago

Windows 10 19045.2965, Firefox 114.0.1, doqment v0.4

MagicalDrizzle commented 1 year ago

@shivaprsd It seems it only works when you open the extension page itself (so address bar shows the "ugly" moz-extension url) If you paste it in a tab with something other than that (like when you paste the DOI in scihub) then it won't work (probably for obvious reasons) ugly

KiitoX commented 1 year ago

On that particular page (and many others), the pdf is shown inside an