Jump to content

Greasemonkey: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Arantius (talk | contribs)
m change to new, correct url
Line 85: Line 85:
* {{cite news | last=Festa | first=Paul | title=Firefox add-on lets surfers tweak sites, but is it safe? | date=[[24 March]] [[2005]] | publisher=CNET | url=http://www.cnet.com.au/software/internet/0,39029524,40053700,00.htm}}
* {{cite news | last=Festa | first=Paul | title=Firefox add-on lets surfers tweak sites, but is it safe? | date=[[24 March]] [[2005]] | publisher=CNET | url=http://www.cnet.com.au/software/internet/0,39029524,40053700,00.htm}}
*{{cite news | last=Singel | first=Ryan | title=Firefox Users Monkey With the Web? | date=[[17 May]] [[2005]] | publisher=Wired magazine | url=http://www.wired.com/news/technology/0,1282,67527,00.html}}
*{{cite news | last=Singel | first=Ryan | title=Firefox Users Monkey With the Web? | date=[[17 May]] [[2005]] | publisher=Wired magazine | url=http://www.wired.com/news/technology/0,1282,67527,00.html}}
* [http://www.arantius.com/misc/greasemonkey/script-compiler.php Script compiler] for conversion of Greasemonkey scripts to [[Extension (Mozilla)|Mozilla extensions]]
* [http://arantius.com/misc/greasemonkey/script-compiler Script compiler] for conversion of Greasemonkey scripts to [[Extension (Mozilla)|Mozilla extensions]]


[[Category:Mozilla extensions]]
[[Category:Mozilla extensions]]

Revision as of 18:59, 24 September 2006

For the slang term referring to mechanics see Grease monkey.For the comic see Grease Monkey (comics).
File:Jfader greasemonkey bookburro.png
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. 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 [1] 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:

  • Alter Gmail to provide an instantaneous deletion control (Gmail has now been altered to include a delete button, making the script obsolete)
  • Show a list of competing retailers' prices for a book when viewing the book on online retailers
  • Remove advertisements from many sites, including popups and google text ads.
  • Alter the layout of pages.
  • Autofill forms.
  • Add or remove accessibility features from pages.
  • Let a user save an .flv file from popular video streaming sites such as Google Video and YouTube.

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:

  • Possible disruption to revenue of some websites. Some Firefox users already block web advertisements, but Greasemonkey may be used to change ads from one company to those of their competitor, to artificially inflate web advertising scores, or to fool the statistics programs run by paid browsing companies.
  • Increases in the web traffic that arise from every page. Some Greasemonkey scripts obtain additional information about pages the user visits, for example from services such as del.icio.us and Bloglines. If these scripts were widely used, they would cause substantial additional traffic to the target websites.
  • The proliferation of scripts acting on many pages, and the difficulty of distinguishing whether problems in a page are caused by actual web-programming bugs or by local Greasemonkey scripts, may make troubleshooting defects more difficult.

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 and PithHelmet (shareware, $10) are similar tools for the Safari browser.

For Internet Explorer, GreasemonkIE, Trixie and Turnabout offer similar functionality. Turnabout used to be open source software (under the BSD License), but as of September 2006, the source code was no longer available.

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

  • Proxomitron, available since late 1990s, predates JavaScript active browsing and provides similar functionality for all browsers using regexp matching.
  • Proximodo, inspired by- and interoperable with proxomitron, is an open source, client side Proxy Server which allows manipulation of page content
  • Privoxy is an open source, client side Proxy Server which allows manipulation of page content available in many OS flavors
  • MouseHole is a client side Proxy Server which allows manipulation of page content using Ruby.
  • Monkeygrease is a Java Servlet which can be used to alter the output of a closed-source Java web application before its output is sent to the client.
  • Chickenfoot is a Firefox extension that aims to enable both end-user programmers and hackers to script interactions on the Web.

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.

Alternatives

Without an extension like Greasemonkey, modifications to websites can also be done in one of the following ways:

See also

  • Homepage of the Greasemonkey extension
  • Blog with the latest Greasemonkey information and updates
  • The old Greasemonkey script repository contains a number of scripts created by people for their personal needs, and uploaded for use by others.
  • UserScripts.org (formerly Greasemonkeyed.com) - the script repository that replaces dunck.us
  • UserJS.org - User Javascripts for Opera (many of which are also available in Greasymonkey format)
  • Dive Into Greasemonkey, a free book by Mark Pilgrim
  • Internet Week's review of Greasemonkey
  • InformationWeek's review of Greasemonkey
  • Greasemonkey etiquette
  • Greasemonkey and its effect on business models
  • Festa, Paul (24 March 2005). "Firefox add-on lets surfers tweak sites, but is it safe?". CNET. {{cite news}}: Check date values in: |date= (help)
  • Singel, Ryan (17 May 2005). "Firefox Users Monkey With the Web?". Wired magazine. {{cite news}}: Check date values in: |date= (help)
  • Script compiler for conversion of Greasemonkey scripts to Mozilla extensions