I am starting to develop a an extension for google chrome, and i quickly realized that it will be almost imperative to have some kind of modularity.
However, i am unsure on what the best way to proceed would be.
Ideally, plugins should be easy enough to create and publish/share, even for non experts (given some sort of API), so i would rather avoid having them be other chrome extensions (with message passing, etc).
I have read a fair share of the docs and so far haven't found much helpful information, so any ideas are welcome
Updated
Sorry if i didn't make myself as clear as possible. The main issues are:
- Sharing aditional code ("plugins") without modifying/updating the extension.
- Allowing custom code to be used without being publicly hosted (either privately or stored and evaluated?)
While both points go against each other, it would still quite possible to implement in a reasonable manner, if not for the security model implemented in google extensions...
Calling external code from within an extension (content script) doesn't seem to be possible by regular means, and neither is accessing the extension from the webpage context.
New Updated
Not enough coffee lately... i hope this is c开发者_运维技巧lear enough, and my apologies again.
I basically comes down to 2 choices:
- Run new code (from source or url) in the context of the extension's content script (no idea how).
- Inject new code into the webpage's document and implement message passing - i have looked into HTML5's MessageEvent and it would work, but with a lot of extra work.
Thanks for the comments, I believe i have this mostly covered:
- use a listener in background page that takes requests for scripts (urls are x-origin)
- set appropriate permissions in manifest ("tabs", "http:///")
- use localStorage for caching
use chrome.tabs.executeScript to run code just as if part of the extension.
Allow users to add new code (into localStorage)
- host some kind of 'plugins.json' file (description version, url, etc) for publishing new content for all the users
精彩评论