krynio
krynio

Reputation: 2492

Chrome extensions disable web security

I write chrome extension. When user go to page http://foo.com/ i load content script. foo.com code like this:

<iframe src="http://bar.com/" id="bar"></iframe>

An i need in extension access to iframe content:

document.getElementById('bar').contentDocument.body.innerHTML

When I run chrome with flag disable-web-security it works, but when chrome is running without this flag code don't work.

Is possible run chrome without flag disable web security and disable web security only for extension?

Upvotes: 2

Views: 1184

Answers (1)

Xan
Xan

Reputation: 77601

I think you're looking at the problem from the wrong angle. You just need to inject a content script into the iframe itself to access its contents.

For that, you will need "all_frames" : true property of the content script.

Upvotes: 1

Related Questions