We're getting close to releasing a new version of Greasemonkey and I'd
like to get your feedback. Here's what new in Greasemonkey 0.8:
* FF3 beta support
* Songbird support (thanks Ian McKellar)
* New cute monkey icons in the status bar and addons panel (thanks to driz).
* Resources (see below for details)
You can download the new release here:
http://youngpup.net/z_dropbox/greasemonkey-0.8.20071208.0.xpi
Please try it out and let us know what works and what doesn't. We are
especially interested in what the script authors think of the APIs.
Resources Details
This is one that people have been asking for for a long time now.
Thanks mainly to Gareth Andrew, you can now include images, css,
javascript files, and any other resource in a Greasemonkey script. So,
for example, you can use the Prototype or MochiKit javascript
libraries with Greasemonkey.
You can see a working example here:
http://www.youngpup.net/userscripts/i-can-has-mochikit.user.js
(obviously only works with Greasemonkey 0.8).
Resources are implemented using two new metadata tags and two new API
functions. Here are the new metadata tags:
@resource <name> <url>
Include the resource <url> when this script is installed and make it
available to the script using the name <name>. So, for example:
@resource google-logo http://www.google.com/intl/en_ALL/images/logo.gif
@require <js-url>
A special form of @resource for including JS libraries. The URL is
included, just like with @resource, but it is automatically added to
the beginning of the script. @require'd libraries are included in the
order they are declared. Here is an example:
@resource mochikit ../shared-libs/MochiKit-1.3-packed.js
Both metadata tags can accept relative or absolute URLs. Relative URLs
are resolved relative to the path of the user script requesting them.
Here are the new API functions:
GM_getResourceURL(resourceName)
Gets a URL for the resource with name <resourceName>. For example, you
could use this to set the src attribute of an image element to a
resource you included.
GM_getResourceText(resourceName)
Gets the textual content of the resource with name <resourceName>.
Note: some popular JS libraries will not work with @require because
they don't work in Greasemonkey's XPCNativeWrapper environment. You
have two choices:
* Fix the script (and ideally submit a patch to the developer)
* Use @resource and GM_getResourceText, like this:
@resource prototype http://www.prototypejs.org/assets/2007/11/6/prototype.js
location.href = "javascript:void(" + GM_getResourceText("prototype") + ")";
Looking forward to hearing your feedback,
- a