Skip to content

Need to set PDF.js preferences #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
MagicalDrizzle opened this issue Sep 28, 2022 · 15 comments · Fixed by #12
Closed

Need to set PDF.js preferences #2

MagicalDrizzle opened this issue Sep 28, 2022 · 15 comments · Fixed by #12
Assignees
Labels
enhancement New feature or request work-in-progress This is being worked on

Comments

@MagicalDrizzle
Copy link

MagicalDrizzle commented Sep 28, 2022

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: mozilla/pdf.js#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
Copy link
Owner

shivaprsd commented Sep 30, 2022

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 mozilla/pdf.js#12625 (comment). 🙃

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.

@shivaprsd shivaprsd added the enhancement New feature or request label Sep 30, 2022
@shivaprsd shivaprsd self-assigned this Sep 30, 2022
@shivaprsd shivaprsd added the need info Further information is requested label Sep 30, 2022
@MagicalDrizzle
Copy link
Author

MagicalDrizzle commented Sep 30, 2022

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 shivaprsd moved this to Todo in doqment v0.3 Oct 1, 2022
@shivaprsd
Copy link
Owner

shivaprsd commented Oct 1, 2022

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 shivaprsd removed the need info Further information is requested label Oct 2, 2022
@shivaprsd
Copy link
Owner

shivaprsd commented Oct 7, 2022

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.

@shivaprsd shivaprsd removed this from doqment v0.3 Oct 7, 2022
@shivaprsd shivaprsd added the future Todo sometime later label Oct 7, 2022
@MagicalDrizzle
Copy link
Author

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

@shivaprsd
Copy link
Owner

@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 #5 (comment)? 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
Copy link
Author

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

@shivaprsd
Copy link
Owner

@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

This comment was marked as outdated.

@MagicalDrizzle
Copy link
Author

@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
Copy link

KiitoX commented Jun 12, 2023

On that particular page (and many others), the pdf is shown inside an <iframe>
You can list these different frames, and select which you want to attach the console to in this menu:
Screenshot_20230612_235232

Edit: that button is only shown when there is at least one iframe present

@shivaprsd
Copy link
Owner

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

@KiitoX I had suspected this. But I didn't know the button shows up only in pages with iframes. Thanks for clearing it up!

It seems it only works when you open the extension page itself

@MagicalDrizzle Yes, correct. Just execute it with the value 2 in the extension page and reload it. It will then start to apply everywhere automatically, including iframes, so you don't have to do it again for the other page.

You can use the same command to revert it as well. The values are 0 = automatic (default), 1 = always light, 2 = always dark.

@shivaprsd shivaprsd changed the title Dark mode and resistFingerprinting Need to set PDF.js preferences Dec 15, 2023
@shivaprsd
Copy link
Owner

The Options page is in the works, and should be ready by the next release. The progress can be tracked here.

Currently it looks like this, embedded in Extension Settings in Firefox (feedback welcome):
options-page

The values are viewer defaults, but any overrides set via the console are respected; so migration won’t be a problem.

@shivaprsd shivaprsd added work-in-progress This is being worked on and removed future Todo sometime later labels Dec 15, 2023
@MagicalDrizzle
Copy link
Author

do your best!
I will say this extension has basically saved my eyesights as I look at sci-hub all the time at 2am...
I'm glad to be able to see it develop ^^

@shivaprsd
Copy link
Owner

@MagicalDrizzle Version 0.7 in now live in the Add-ons store.

Happy New Year! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request work-in-progress This is being worked on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants