How to inject script in iframes of a extension page

398 views
Skip to first unread message

Himanshu Mishra

unread,
Aug 6, 2020, 4:37:13 AM8/6/20
to Chromium Extensions
Hi I'm working on a chrome extension which opens a bunch of iframes in a extension page which I get through chrome.runtime.getUrl. Iframes are of different origin so I want to inject some content script in these iframes but executeScript does not work in "chrome://*" urls. 
Is there a way I can get around this?

Thanks!

Deco

unread,
Aug 6, 2020, 4:39:47 AM8/6/20
to Himanshu Mishra, Chromium Extensions
This is not possible as it is a violation of CORS restrictions - other scripts can not be injected into cross-domain iframes.

Thanks,
Deco

--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/d992500a-ba69-497a-a17d-c4991564d453n%40chromium.org.

wOxxOm

unread,
Aug 6, 2020, 10:07:36 AM8/6/20
to Chromium Extensions, warlo...@gmail.com
Content script injection is for web pages/frames, not for extension pages/frames. For an extension page/frame there's no need to inject anything. Simply use a standard tag in your page.html or frame.html like this <script src=script.js></script> and it'll load script.js from your extension package.
Reply all
Reply to author
Forward
0 new messages