I wonder if anybody can lay out the general logic of what I should do to achieve the following:
I have an extension for Chrome, that gets a list of user's bookmarks.
When user visits web page, the information that was retrieved by extension is accessed and displayed on web page.
I already have an extension, I wonder how do I access it from a web page?
I wonder if anybody can lay out the general logic of what I should do to achieve the following:
I have an extension for Chrome, that gets a list of user's bookmarks.
When user visits web page, the information that was retrieved by extension is accessed and displayed on web page.
I already have an extension, I wonder how do I access it from a web page?
Share Improve this question edited Oct 3, 2011 at 10:42 Wladimir Palant 57.7k12 gold badges99 silver badges127 bronze badges asked Oct 3, 2011 at 3:02 StpnStpn 6,4048 gold badges48 silver badges96 bronze badges 1- 1 why ? cant you just use a content script and put the data on the page, when user visits it ? – c69 Commented Oct 3, 2011 at 5:36
2 Answers
Reset to default 4To municate with a web page you need a content script that will load on that page. Then you can then use events to municate. The content script can receive messages from your background page and forward them to the web page if necessary.
Make sure that you take the security considerations section to heart. You make user's bookmarks available to a web page, you should be very certain that this web page should have access to them.
So, if the author of the extension wrote the extension, and sandboxed his code (this means that he/she did something to keep his vars out of the global namespace), then there isn't much that you are going to be able to do. So... check to see if the author left his variables accessible at the global namespace level. To do this in Chrome, go to the page, open the Dev Tools, go to the console and type
console.log(window);
This will show you the global namespace, and should show you what you are looking for. If you see anything that doesn't look like a traditional variable or object or function, then that is something you should investigate. I wish I could give you clearer steps here, but you are essentially trying to hijack the code from the extension, and that kind of stuff takes a lot of testing/investigating.
If there isn't anything abnormal in the global namespace, then that means that the code is sandboxed, and you are in a tough spot. It will be tough for you to get any of the vars/values/objects from the extension code.
Good luck.