I'm tryng to make an extension for google chrome that does this things:
Run when loading www.example.com example.com has an iframe to another site, i need to get access to a link from this iframe (this is rapidshare, I need to grab the downloadlink)
So far so good, but..
Then I need the extension to inform the link url to example.com for further processing.
Any ideas o directions??
I've read http://code.google.com/chrome/extensions/content_scripts.html#host-page-communication but can't make it work...
You need to inject 2 content scripts:
"content_scripts": [
{
"matches": ["http://www.example.com/*"],
"js": ["example.js"]
},{
"matches": ["http://www.rapidshare.com/*"],
"all_frames": true,
"js": ["rapidshare.js"]
}
]
In order to transfer the link from one script to another you need to communicate through background page:
rapidshare.js:
chrome.extension.sendRequest({url: "link"});
background.js:
chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
chrome.tabs.sendRequest(sender.tab.id, request);
sendResponse({});
});
example.js:
chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
console.log("received url:", request.url);
sendResponse({});
});
iframe is a separate document for the browser, that's why you can use chrome extension and integrate it directly into iframe. You need just mention URL of the iframe in chrome extension manifest file. We use integration of some menus and toolbars of our chrome extension apps into iframes. It works.
There is a nice article as additional info for Chrome Extensions and iFrames http://www.natewillard.com/blog/chrome/javascript/iframes/2015/10/20/chrome-communication/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With