()
| 643 | } |
| 644 | |
| 645 | function 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() |
no outgoing calls
no test coverage detected
searching dependent graphs…