Skip to content

Documentation of and Experimentation with the New Version of Greasemonkey

In the previous entry here, the release of the newest version of Firefox was mentioned. Also mentioned in that entry was the release of a new version of Greasemonkey that coincided with the release of this new version of Firefox. I mentioned that what may have been most important about this new version of Greasemonkey was its compatibility with this new version of Firefox. And what seems to be the most discussed topic regarding this new version is the new Greasemonkey icon. However, there is more to this Greasemonkey version than compatibility with Firefox 3 and a new icon. And this post is about actual improvements made to Greasemonkey, rather than cosmetic changes or updates to simply make it compatible with the new version of Firefox.

There are a number of new features that the new version of Greasemonkey has that are actual improvements upon the previous version of it. There is now the @resource directive, which can be used with the new GM_getResourceURL and GM_getResourceText functions in user scripts. The @resource directive is one that can be used for storing base64-encoded data from a specified URL, and the GM_getResourceURL function is used for putting that data into a string. Similarly, the @resource directive can also be used to load external text data which is accessed through the GM_getResourceText function. In addition, the @require directive is used for including JavaScript code from other source files, and those who write user scripts for Greasemonkey have wanted a feature for including JavaScript code from other files for a long time.

Interestingly, there is not much that has been said about these new features by those who would use them. In fact, there seems to be much more discussion of the new Greasemonkey icon. And in addition to the lack of discussion of these new features in online forums, there is a lack of information about these new features on the GreaseSpot wiki. Although there are basic examples there about how these new directives and functions can be used, there is not much detail about when and why these directives and functions would be used. Perhaps working code examples could be provided to make script writers see why these features can be used, and how they can make Greasemonkey scripts better. Inclusion of these explanations of how these new features make Greasemonkey more useful and powerful could make more people want to use it and write scripts for it. It is mentioned on pages on the GreaseSpot wiki that these new features allow inclusion of data from other sources, although some might consider it important for more details to be included about these features. And little is said about another new feature in this new version, which is the finalURL property that is now included in the GM_xmlhttpRequest function. The advantages of this property would be good to know about.

Some might wonder why I have not modified the GreaseSpot wiki to improve on the documentation of these features. Well, I personally would need to work with these features before documenting them. And a number of factors have conspired to keep me from performing these experiments with features that could make Greasemonkey even better than it previously was. What is written on the GreaseSpot wiki may be written by those who write Greasemonkey scripts. However, attempts to make it for those who write these scripts could be better. Many of those who use Greasemonkey may prefer writing scripts to writing documentation. And I would need time to write scripts that use these features to document them as well as they can be documented. And we who write these scripts still have yet to write documentation that is as good as it can and should be.