Opentopia Directory Encyclopedia Tools

Greasemonkey

Encyclopedia : G : GR : GRE : Greasemonkey


For the slang term referring to mechanics see Grease monkey
Screenshot of the BookBurro user script running in Greasemonkey.  BookBurro alters an amazon.com page to show the prices of the same book offered by competing retailers.
Enlarge
Screenshot of the BookBurro user script running in Greasemonkey. BookBurro alters an amazon.com page to show the prices of the same book offered by competing retailers.

Greasemonkey is a Mozilla Firefox extension that allows users to install scripts that make on-the-fly changes to specific web pages. Without an extension like Greasemonkey, this modification has to be done manually, using Firefox's JavaScript Console or the JavaScript: protocol, the browser's Document Object Model Inspector, or bookmarklets. As the Greasemonkey scripts are persistent, the changes made to the web pages are executed every time the page is opened, making them effectively permanent for the user running the script.

Greasemonkey can be used for adding new functionality to webpages (like embedding price comparison in amazon.com webpages), fixing rendering bugs, combining data from multiple webpages, and numerous other purposes. Well written Greasemonkey scripts can integrate changes so well that their additions appear to be natural parts of the web page.

Technical details

Most Greasemonkey user scripts are written by hand, using site-specific JavaScript code which manipulates the contents of a webpage using the Document Object Model interface. [userscripts.org] maintains a database of Greasemonkey scripts, and for each it lists the URLs of webpages to which the scripts pertain. (N.B. The [obsolescent script repository] might contain some older scripts that have not yet migrated to the [new repository].) When the user loads a matching page Greasemonkey invokes the relevant scripts, which can then add to the page, delete parts of it, or move parts around. Greasemonkey scripts can also contact other websites, and several query pages related to the current page and use this to add additional information to the page. Greasemonkey scripts have the format somename.user.js, and Greasemonkey automatically detects and offers to install any such scripts which it encounters. In addition to JavaScript code, Greasemonkey scripts contain limited optional metadata, which specifies the name of the script, a description, a namespace URL used to differentiate identically named scripts, and the default list of URLs for which the script is intended.

Writing a Greasemonkey script is a technically demanding process (although rather easier than writing a fully-fledged Firefox extension). This means that few ordinary users can practically write Greasemonkey extensions. The Platypus [link] extension, however, allows users to edit a page (deleting parts of it, or moving parts around); Platypus then saves these changes as a persistent Greasemonkey script.

Typical Greasemonkey scripts

Users have written scripts which:

Technical, operational, and ethical issues arising from user scripting

Some in the Firefox community, and a number of technical analysts, warn that widespread use of Greasemonkey and related user scripting technologies will require care in deployment. Their concerns include:

Greasemonkey equivalents for other browsers

Greasemonkey is available for Firefox, Flock and Epiphany. The Epiphany Greasemonkey extension is part of the Epiphany-extensions package. However, this extension is not fully compatible as of release 2.15.1, since some Greasemonkey API functions (e.g. GM_getValue) are unsupported.

[Creammonkey] is available for the Safari browser.

For Internet Explorer, [GreasemonkIE], [Trixie] and [Turnabout] offer similar functionality. Only Turnabout is open source software (under the BSD License).

Version 8 of Opera also adds [user scripting functionality].

As both Opera and Firefox support the W3C DOM, many Greasemonkey user scripts also work correctly on Opera.

Similar software

Bookmarklets can execute arbitrary JavaScript on any page, but they require a user to click them, rather than running automatically.

Major security hole

On July 20, 2005 a security hole in Greasemonkey version 0.3.4 was discovered. This allowed specially crafted websites to hijack Greasemonkey functionality normally reserved for user scripts, and thus to access the user's local machine or probe other machines on their intranet. No exploit is known to exist, however. [(Announcement of the vulnerability)] [(Details of the security hole)]

The [next major release], Greasemonkey 0.5.1 final, fixed this problem and all other known Greasemonkey security holes.

See also

External links

 


From Wikipedia, the Free Encyclopedia. Original article here. Support Wikipedia by contributing or donating.
All text is available under the terms of the GNU Free Documentation License See Wikipedia Copyrights for details.

Search Titles
0123456789
ABCDEFGHIJ
KLMNOPQRST
UVWXYZ?

E-mail this article to:

Personal Message: