Greasemonkey 0.8 candiate -- Let us know what you think

Skip to first unread message

Aaron Boodman

Dec 9, 2007, 2:57:46 AM12/9/07
Hello everyone,

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:

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:
(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

@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:

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.

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
location.href = "javascript:void(" + GM_getResourceText("prototype") + ")";

Looking forward to hearing your feedback,

- a


Feb 5, 2008, 1:30:08 PM2/5/08
to greasemonkey-users
"@require <js-url>" is a big help. Not having an "include" or
separate compilation capability was a real limitation.
Reply all
Reply to author
0 new messages