Site structure:
Site1
-dynamic iframe (using document.write)
--iframe src="site2"
I want to change the content of site2 with my chrome extension.
Using a content script that walks the iframes from site1 will not work. Soon as it gets to site2 chrome gets anal about security and no way to make an exception through manifest setting. Manifest file:
"content_scripts": [
{
"matches": ["http://site1/*"],
"js": ["script.js"],
}
],
"permissions": [
"tabs"
],
So i tried to get the script to run on site2 directly like so (manifest file):
"content_scripts": [
{
"matches": ["http://site2/*"],
"js": ["script.js"],
}
],
"permissions": [
"tabs"
],
It didn’t work. Doesn’t seem to work when site2 is within an iframe of another site.
Here is the test script i used:
function check_player() {
//var player = document.getElementById("player");
var player = self.document.getElementById("player");
if (player) {
console.log(player);
} else {
setTimeout("check_player()", 100);
}
}
check_player();
So what am i supposed to do ?
Do you have any suggestions ?
You need to specify all_frames: true for you content script on the manifest. That way it will run your script in all iframes with a matching url. See http://developer.chrome.com/extensions/content_scripts.html