Approch overview:
- By default PDF viewer will be inverted with
hue-rotate(180deg)to retain colors. - A JavaScript bookmarklet lets you invert back to light mode.
Put these lines in your config:
programs.firefox.your-profile = {
userContent = ''
#viewerContainer > #viewer.pdfViewer > .page {
filter: invert(100%) hue-rotate(180deg);
}
'';
bookmarks.settings = [{
name = "Invert PDF";
url = ''javascript:/*PDF%20-%20filter%20invert*/(function(){var%20L='style_PDFI',S='#viewerContainer>#viewer.pdfViewer>.page{filter:unset!important}',SS,E=document.querySelector('style[id="'+L+'"]');if(E){SS=E.disabled;E.disabled=(SS==true)?false:true}else{SS=document.createElement('style');SS.setAttribute('type','text/css');SS.id=L;SS.innerHTML=S;document.querySelector('head').appendChild(SS);}})()'';
}];
}Rebuild and restart firefox. Open any PDF in the browser, for example try this paper that I had open while writing this tutorial. To invert back to light mode click the Invert PDF bookmark.
- The solution by എല്ലാ മറുപടികളും to this mozilla support forum question is where I got the bookmarklet from.