How can I preview PDFs with Google Chrome in dark mode?

Paste this JavaScript code in your console:

var cover = document.createElement("div");
let css = `
    position: fixed;
    pointer-events: none;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: white;
    mix-blend-mode: difference;
    z-index: 1;
`
cover.setAttribute("style", css);
document.body.appendChild(cover);

Special thanks: https://www.reddit.com/r/chrome/comments/e3txhi/comment/fem1cto


You can use the Dark Reader Google Chrome extension and used the Filter+ mode. It will work on the online PDF files, but not at the local PDF files.

enter image description here