Jump to content

Greasemonkey: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
SmackBot (talk | contribs)
m Date the maintenance tags and general fixes
changed the two other uses links to actually link to those things
Line 1: Line 1:
{{two other uses||Grease monkey|the comic|Grease Monkey}}
{{two other uses||the comic|Grease Monkey|other uses|Grease monkey}}
{{Infobox Software
{{Infobox Software
| name = Greasemonkey
| name = Greasemonkey

Revision as of 19:30, 14 May 2008

Template:Two other uses

Greasemonkey
Original author(s)Aaron Boodman
Developer(s)?
Initial release?
Stable release
0.7.20080121.0 / 2008-01-21
Repository
Operating systemCross-platform
Available inEnglish
TypeMozilla extension
LicenseExpat License
Websitewww.greasespot.net/

Greasemonkey is a Mozilla Firefox extension that allows users to install scripts that make on-the-fly changes to most HTML-based web pages. As 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 web pages (for example, embedding price comparison in Amazon.com web pages), 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 web page using the Document Object Model interface. userscripts.org maintains a database of Greasemonkey scripts, and for each it lists the URLs of web pages 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 poll external HTTP resources via a non-domain-restricted XMLHTTP request. Greasemonkey scripts are named somename.user.js, and Greasemonkey automatically detects and offers to install any such script, when a URL ending in that suffix is loaded. 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 URL patterns for which the script is intended to be invoked or not.

Writing a Greasemonkey script is similar to writing javascript for a web page, with some additional restrictions imposed by the security provisions of Mozilla's XPCNativeWrapers. Compared to writing a full-fledged Firefox extension, user scripting is a very modest step up in complexity from basic web programming, but for the JavaScript illiterate and non-programmer incapable of writing a user script, the Platypus [1] extension allows them to edit a page (deleting or moving parts of it around) to create persistent Greasemonkey scripts automating their changes.

Typical Greasemonkey scripts

Users have written scripts that:

  • Auto fill forms.
  • Alter the formatting of text, borders, graphics, etc. (For example, highlight first-run programs in a TV listing.)
  • Remove specific content, such as advertising, popups, even whole sections of a page. (For example, filter specific posters from a message board site.)
  • Alter page content and layout beyond what the author considered. (For example, add table headers, floating elements, etc.)
  • Add links, buttons, or any other type of HTML element anywhere on the page. (For example, embed Google Reader into Gmail, thus providing an RSS feed option.)
  • Enhance the content of pages by correlating information from related pages on the same site, and/or other sites. (For example, show a list of competing retailers' prices for the same product.)
  • Add extended JavaScript behavior to pages. (For example, discover RSS feeds on the current page, displaying them in a floating panel. Let the user save an FLV file from popular video streaming sites such as Google Video, YouTube, and Facebook.)

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 with Adblock Plus, 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 some scripts. Such 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.
  • Script errors resulting from lack of coordination between Greasemonkey developers and the original website developers.
  • Greasemonkey only works on HTML-based pages, and does not work on Flash, Flex, and Silverlight content within web pages.
  • Rich Internet Applications are more difficult for a Greasemonkey script developer to control than static web pages. This is because the more logic that a page performs, the more complexities there are to consider for the Greasemonkey script writer to develop a script that will not interfere with the original application's functionality.
  • The original site developers can release a new version of the site that causes the Greasemonkey script designed for that site to stop working. Therefore, a Greasemonkey script written for a specific site without developer coordination cannot be considered a long-term solution.
  • There is no official way for userscripts to update themselves; some developers added such functionality to their userscripts but most of them remain static, and eventually break.

Greasemonkey compatibility and equivalents for other browsers

Other Mozilla-based 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. There is also a custom version for SeaMonkey: [2]. There is also a version out for Songbird.

Opera

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.

Safari

GreaseKit (formerly Creammonkey) and PithHelmet (shareware) are similar tools for the Safari browser and other WebKit based applications such as MailPlane.

Konqueror

Konqueror Userscript is a webpage manipulation tool for KDE's Konqueror browser which aims for compatibility with Greasemonkey scripts and metadata. It is available as a KPart.

Internet Explorer

For Internet Explorer, IE7pro, iMacros, Trixie (last updated 2005), Turnabout (last updated 2006) and Greasemonkey for IE (last updated 2006) offer similar functionality. Turnabout used to be open source software (under the BSD License), but as of September 2006, the source code is no longer available.

Similar software

Browser level only (Firefox)

  • AlchemyPoint combines a Firefox extension with a client side Proxy Server to allow for manipulation of web content, scraping of data from websites, detection/parsing of microformats, etc.
  • Chickenfoot is a Firefox extension that aims to enable both end-user programmers and hackers to script interactions on the Web.
  • iMacros for Firefox is a Firefox extension that allows the user to record and replay so called "Internet Macros" for web automation, web scraping or web testing.
  • Stylish is a Firefox extension that allows for client-side manipulation of webpage content through Cascading Style Sheets.
  • Bookmarklets can execute arbitrary JavaScript on any page, but they require a user to click them, rather than running automatically.
  • Firebug is a developers extension which allows arbitrary realtime changes to a page's DOM
  • Super GreaseMonkey is a mod of GreaseMonkey which supports runtime libraries (specifically jquery) for user scripts.
  • 3D3R Bubbles is the first Site-Specific-Browser, and it uses JS injection of user-scripts, very much like GreaseMonkey.

Proxy level

  • 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.
  • Proxomitron, available since late 1990s, predates JavaScript active browsing and provides similar functionality for all browsers using a regexp-like matching language.
  • 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.

Alternatives

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

  • Entering javascript: URLs in the Location Bar or using bookmarklets
  • Using the browser's DOM Inspector
  • Using a full-fledged extension that serves the same purpose
  • Using a local HTTP proxy that modifies the HTML, such as WebWasher or Proxomitron
  • Using the Opera browser and user.js scripts

See also

External reviews

  • 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)