'How can I enable dark mode when viewing a pdf file in firefox
I have enabled the dark mode in Firefox version 76.0 as well as installed the dark reader extension. The extension allows web pages to go dark. These changes do not affect any PDFs that have been opened in Firefox.
Solution 1:[1]
Recording this for anyone who has this problem
Create a bookmarklet - a bookmark with the following in the location/address field
javascript:(function(){viewer.style = 'filter: grayscale(1) invert(1) sepia(1) contrast(75%)';})()
Hope this helps.
Solution 2:[2]
You can see it in https://pncnmnp.github.io/blogs/firefox-dark-mode.html
- Open Firefox and press
Altto show the top menu, then click onHelp ? Troubleshooting Information - Click the
Open Folderbutton beside theProfile Folderentry - Create a folder named
chromein the directory that opens - In the
chromefolder, create a CSS file with the nameuserContent.css - Open the
userContent.cssfile and insert -
#viewerContainer > #viewer > .page > .canvasWrapper > canvas {
filter: grayscale(100%);
filter: invert(100%);
}
- On Firefox's URL bar, type
about:config. - Search for
toolkit.legacyUserProfileCustomizations.stylesheetsand set it to true. - Restart Firefox and fire up a PDF file to see the change!
Solution 3:[3]
Simple bookmarklet toggler
Just run snippet and drag link to Bookmarks Toolbar
<a href="javascript:(function(v) {v.style = v.classList.contains('dm')?'':'filter: grayscale(1) invert(1) sepia(1) contrast(75%)';v.classList.toggle('dm');})(viewer)">PDF darkmode toggler</a>
Unminified:
(
function() {
if (viewer.classList.contains("dm")) viewer.style = "";
else viewer.style = "filter: grayscale(1) invert(1) sepia(1) contrast(75%)'";
viewer.classList.toggle("dm");
}
)()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | DxTx |
| Solution 2 | Alfian Hamdani |
| Solution 3 | psydvl |
