开发者

Using a remote script in a Google Chrome extension

I would like to create a Google Chrome extension that can fetch a remote javascript (via HTTPS) and execute it on a webpage (from within the extension sandbox). Basically, the script parses the page and generates data that I could then send back to my remote server.

The reason I want to do this is because I have a similar extension in Firefox, and I would like to unify the codebase as much as possible. I've already figured out how to do this in Firefox using a XmlHttpRequest and their evalInSandbox function.

Is this even possible in Chrome? It appears I can't use a XmlHttpRequest in Chrome, because it only allows XML or valid JSON (which excludes functions). I couldn't just insert a script tag on the page开发者_开发技巧 either, because then it wouldn't execute within the extension sandbox. Is there any way to do this?


What about converting your js code into a string, passing it through json or xml and then evaluating it using eval() (all security issues aside)?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜