L
L
Lex3gp2014-04-13 22:17:16
JavaScript
Lex3gp, 2014-04-13 22:17:16

Is it possible to change the content of an Iframe from within a Chrome extension?

I'm writing a Chrome extension and I need to modernize the content of an Iframe on a page.

Paste the code through executeScript and there it is impossible to access the frame: it gives a security error.

Is there any way to change the contents of an IFrame directly from an extension? (For example, as with ajax requests: you cannot insert a script into a page and from there send a request to another domain - a security error, but it is possible to send requests from the extension itself).

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Maxim Vasiliev, 2014-04-14
@Lex3gp

You need a content script that is loaded on the URL that is loaded in the frame.
This script will have access to the content.
There can be several content scripts in one extension.

"content_scripts": [
{ "matches: "http://урл_по_которому_грузится_фрейм",
  "js": "скрипт_коорый_грузить_в_этот_фрейм" }
]

The problem will be that this script will not be able to communicate directly with the background script (they have different origins and they are isolated)
. -scripts in multiple frames/pages.

M
Maxim Vasiliev, 2014-04-13
@qmax

manifest.permissions for the extension must match the frame url.
no other way.
there, however, you can shove patterns.

A
Alexander Borisovich, 2014-04-14
@Alexufo

Get an iframe extension. Modify and paste on the page. It's better to parse with an iframe extension if you have large modifications.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question