Content scripts on PDF pages when chrome://flags/#pdf-oopif is enabled

136 views
Skip to first unread message

Andreas Gruber

unread,
Sep 3, 2024, 12:28:01 PMSep 3
to Chromium Extensions
We are injecting a content script into PDF pages like https://arxiv.org/pdf/1801.00006. The content script then shows a div element. When chrome://flags/#pdf-oopif is enabled this does not work anymore. 

The Save to Pocket extension suffers from the same problem like we do: https://chromewebstore.google.com/detail/save-to-pocket/niloccemoadcdkdjlinkgdfekeahmflj?hl=en

Best,
Andreas

Andreas Gruber

unread,
Sep 4, 2024, 4:15:22 AMSep 4
to Chromium Extensions, Andreas Gruber
Also the Google Keep extension (https://chromewebstore.google.com/detail/google-keep-chrome-extens/lpcaedmchfhocbbapmcbpinfpgnhiddi) does not work with this flag being enabled.

woxxom

unread,
Sep 4, 2024, 11:29:08 AMSep 4
to Chromium Extensions, Andreas Gruber
If you use devtools you should see that the content script is actually injected (devtools -> Sources -> Content scripts), but your code fails because the document is different now.
  1. Don't append your UI to document.body, use document.documentElement and z-index:2 or higher.
  2. To access the pdf's iframe element use chrome.dom.openOrClosedShadowRoot(document.body).querySelector('iframe')

Reply all
Reply to author
Forward
0 new messages