Sorry for jumping in so late on this...
CmdUtils.injectJavascript() will inject JavaScript into the *current tab
content*. Which means it will run with content privileges - not what you
want if you want it for your command. Then accessing that code opens the
possibility of other code from that page intercepting it, and gaining
chrome privledges - which would be very bad.
The correct way of doing this is to load it via a XMLHttpRequest (ie,
Ajax). Using jQuery, the code would be:
jQuery.get("http://example.com/script.js", function(data) {
eval(data);
doStuff();
});
Just be very careful about what code you're fetching. Make sure you can
definitely trust it, as it will be running with full chrome privileges,
so can do everything a command can do. Ubiquity doesn't yet have an easy
way to ensure a safe sandbox, although it should by the time v0.2 comes out.
If its just JSON data, use Utils.decodeJson() instead - its always safe
to use that, even with untrusted data.
Also, note that if any commands depend on the functionality in remote
code, they won't work until that code is loaded. So you may wish to put
all your commands (ie, calls to CmdUtils.CreateCommand()) inside the
callback (ie, where the call to doStuff() is). You could also load it
inside of every preview/execute method of the commands that use depend
on that code (I think the browser should cache the remote script
automatically).
- Blair
On 28/11/2008 4:39 AM, [EMAIL PROTECTED] wrote:
> Hi,
>
> I am not sure if this was covered before, but I have a external .JS lib
> that I want to be able to call within my ubiquity command. Can anyone
> give me any pointers? From some previous thread, I think
> CmdUtils.injectJavascript needs to be used. Is this correct?
>
> thanks,
>
> --
> Mayuresh
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"ubiquity-firefox" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/ubiquity-firefox?hl=en
-~----------~----~----~----~------~----~------~--~---