MCPcopy Create free account
hub / github.com/darkreader/darkreader / tryInvertChromePDF

Function tryInvertChromePDF

src/inject/dynamic-theme/index.ts:645–664  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

643}
644
645function tryInvertChromePDF() {
646 if (!document.body || !chrome.dom) {
647 return;
648 }
649
650 const root = chrome.dom.openOrClosedShadowRoot(document.body);
651 if (!root || !root.querySelector('link[href$="/pdf_embedder.css"]')) {
652 return;
653 }
654
655 const sheet = new CSSStyleSheet();
656 sheet.replaceSync('[type="application/pdf"] { filter: invert(1) contrast(0.9); }');
657 root.adoptedStyleSheets.push(sheet);
658 cleaners.push(() => {
659 const index = root.adoptedStyleSheets.indexOf(sheet);
660 if (index >= 0) {
661 root.adoptedStyleSheets.splice(index, 1);
662 }
663 });
664}
665
666/**
667 * TODO: expose this function to API builds via src/api function enable()

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…