I'm trying to expand a shorturl using an API in an injected script in a Safari Extension:
$.getJSON('http://api.longurl.org/v2/expand?format=json&url=' + encodeURIComponent(href) + '&callback=?', function(data) {
console.log(data);
});
And I'm getting the following error:
ReferenceError: Can't find variable: jQuery15103411371528636664_1298845652395
I've tried a different API and get the same error, so I know it is not that. Also, if I execute the same code from the console, I get a successful response. So it must be something to do with being inside the Safari Extension's injected script.
Any ideas?
I believe you have to add jQuery to the plugin first. Here's an example of how:
Then you can do jQuery in a tab using your plugin. ;)