Greasemonkey
From Wikipedia, the free encyclopedia
| This article needs additional citations for verification. Please help improve this article by adding reliable references. Unsourced material may be challenged and removed. (August 2008) |
| Original author(s) | Aaron Boodman |
|---|---|
| Stable release | 0.8.20090123.1 / 2009-02-18 |
| Operating system | Cross-platform |
| Available in | English |
| Type | Mozilla extension |
| License | Expat License |
| Website | www.greasespot.net |
(category) |
|---|
| Contents |
| Origins and Lineage |
|
|
Greasemonkey is a Mozilla Firefox add-on that allows users to install scripts that make on-the-fly changes to most HTML-based web pages (also known as augmented browsing). 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 functions 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.
Contents |
[edit] Technical details
Greasemonkey user scripts are written in JavaScript with limitations[1] and manipulate the contents of a web page using the Document Object Model interface. Scripts are site-specific and written by hand. userscripts.org maintains a database of Greasemonkey scripts, and for each, lists the URLs of web pages to which the script pertains. When the user visits a matching website, Greasemonkey invokes the relevant scripts, which can modify a webpage in any way JavaScript could. Greasemonkey scripts can also poll external HTTP resources via a non-domain-restricted XMLHTTP request. Scripts are named somename.user.js, and Greasemonkey offers to install any such script when a URL ending in that suffix is requested. Greasemonkey scripts contain optional metadata, which specifies the name of the script, a description, relevant resources to the script, a namespace URL used to differentiate identically named scripts, and URL patterns for which the script is intended to be invoked or not.
[edit] Limitations
Writing a Greasemonkey script is similar to writing JavaScript for a web page, with some additional allowances such as cross-site XMLHttpRequests. Compared to writing a full-fledged Firefox extension, user scripting is a very modest step up in complexity from basic web programming. However, Greasemonkey scripts are limited due to security restrictions imposed by Mozilla's XPCNativeWrappers. For example, Greasemonkey scripts do not have access to many of Firefox's components, such as the download manager, IO processes or it's main toolbars. Additionally, Greasemonkey scripts run per instance of a matching webpage. Because of this, managing lists of items globally is difficult. However, script writers have been using cookies and Greasemonkey even offers API's such as GM_getValue and GM_setValue to overcome this.
[edit] 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 content and layout beyond that which the page author considered. (For example, add floating elements, make elements collapsible, 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 retrieving correlating information from related pages on the same site, or other sites. (For example, list the prices of competing retailers' for the same product.)
- In general, take advantage of extended JavaScript behavior to add previously non-existent functionality to pages. (For example, collate RSS feeds on the current page into a floating panel. Allow the user save an FLV file from popular video streaming sites such as Google Video, YouTube, and Facebook.)
[edit] Greasemonkey compatibility and equivalents for other browsers
[edit] 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 are also custom versions for SeaMonkey[2] and Songbird.[3]
[edit] Opera
Version 8 and upwards of Opera also have user scripting functionality. Both Opera and Firefox support the W3C DOM. Opera is capable of running many Greasemonkey user scripts.[4]
[edit] Safari
GreaseKit (formerly Creammonkey) and PithHelmet (shareware) are similar tools for the Mac OS version of the Safari browser, along with other WebKit based applications such as MailPlane.
[edit] Konqueror
Konqueror Userscript is a webpage manipulation tool for KDE's Konqueror browser that aims for compatibility with Greasemonkey scripts and metadata. It is available as a KPart.
[edit] Internet Explorer
For Internet Explorer, similar functionality is offered by IE7pro, iMacros, Trixie (last updated 2005), Turnabout (last updated 2006) and Greasemonkey for IE (last updated 2006). Turnabout used to be open source software (under the BSD License), but as of September 2006, the source code is no longer available.
[edit] Google Chrome/Chromium
As of November 2008[update], there is only limited support for Greasemonkey scripts in the Chrome beta (since build 3499).[5] It is disabled by default, but can be enabled by adding --enable-greasemonkey as a startup parameter. As there is currently no method to load scripts within Chrome, scripts must be placed into the C:\scripts directory for Chrome, and into the "user data directory" for newer builds of Chromium.[6] Chrome ignores @exclude metadata within the scripts, so the scripts are executed for all domains/pages. On the other hand, Chromium honors the @include directives and executes the scripts only for the domains/pages specified. However, the pre-beta version of Google Chrome 2.0, released in early January 2009, is reported to support Greasemonkey.
[edit] Similar software
[edit] 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.
- Platypus is a Firefox extension that lets you interactively modify any Web page from your browser, and optionally to save those transformations as a Greasemonkey script so that they'll be repeated the next time you visit the page.
- 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 that allows arbitrary real time changes to a page's DOM
- Bubbles is the first Site-Specific-Browser, and it uses JS injection of user-scripts, very much like Greasemonkey.
- Jetpack is an API that allows to write Firefox add-ons using JavaScript, JQuery and Firebug.
[edit] Proxy level
- Monkeygrease is a Java Servlet that alters 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 a similar function for all browsers using a regexp-like matching language.
- Proximodo, inspired by- and interoperable with proxomitron, is an open source, client side proxy server that allows page content manipulation.
- Privoxy is an open source, client side proxy server that allows manipulation of page content available in many OS flavors.
- MouseHole is a client side proxy server that allows manipulation of page content using Ruby.
- Muffin is a Java open-source stand alone proxy server that allows manipulation of page content (usually client-side, but sports a web interface in addition to a Swing GUI for configuration).
- BFilter is an open source, client side proxy server that allows manipulation of page content available in many OS flavors.
- GrimeApe is a Javascript injection proxy which provides the GreaseMonkey API for running userscripts in other browsers (currently Konqueror and Firefox are supported).
- Scone is an open source stand alone proxy server (client and server side) that allows any manipulation of transferred web resources. It also provides an personal web crawler, user action logging as well as an mysql persistence component.
[edit] Alternatives
Without an extension like Greasemonkey, developers still can modify websites other ways:
- Enter javascript: URLs in the Location Bar or using bookmarklets
- Use the browser's DOM Inspector
- Use a full-fledged extension that serves the same purpose. (It is possible to convert much of the code in a GreaseMonkey script to become part of a Firefox extension. This is how GreaseMonkey scripters often "graduate" to extension writers.)
- Use a local HTTP proxy that modifies the HTML, such as WebWasher or Proxomitron
[edit] See also
- List of Firefox extensions
- ShiftSpace, an extensible platform for annotating and modifying web content, built on top of Greasemonkey
[edit] References
- ^ "Avoid Common Pitfalls". O'Reilly Commons. http://commons.oreilly.com/wiki/index.php/Greasemonkey_Hacks/Getting_Started#Avoid_Common_Pitfalls. Retrieved on 2009-05-05.
- ^ "Greasemonkey". mozdev. http://xsidebar.mozdev.org/modifiedmisc.html#greasemonkey. Retrieved on 2009-05-05.
- ^ ianloic. "Greasemonkey". Songbird. http://addons.songbirdnest.com/addon/79. Retrieved on 2009-05-05.
- ^ "Take Control with User JavaScript". Opera Software. http://www.opera.com/docs/userjs/examples/#greasemonkey. Retrieved on 2009-03-26.
- ^ Brinkmann, Martin (2008-08-18). "Google Chrome Adds Greasemonkey Support". ghacks.net. http://www.ghacks.net/2008/10/18/google-chrome-adds-greasemonkey-support/. Retrieved on 2009-04-15.
- ^ "User Scripts". Chromium Developer Documentation. http://dev.chromium.org/developers/design-documents/user-scripts. Retrieved on 2009-04-15.
[edit] External links
| This article includes a list of references, related reading or external links, but its sources remain unclear because it lacks inline citations. Please improve this article by introducing more precise citations where appropriate. (August 2008) |
- Official Greasemonkey Mozilla Add-on page
- GreaseFire - a Firefox add-on, licensed under the GPL, that automatically notifies the user (via a statusbar icon) if a page they are visiting has Greasemonkey scripts available for use with it
- Greasemonkey Wiki
- Dive Into Greasemonkey - A free online book on Greasemonkey script writing by Mark Pilgrim
- UserScripts.org (formerly Greasemonkeyed.com) - User script repository
- UserStyles.org - User styles (CSS) for Stylish extension (many of which are also available in Greasemonkey format)
- UserJS.org - User JavaScript for Opera (many of which are also available in Greasemonkey format)
- Greasemonkey etiquette
- Nivi. "Greasemonkey will blow up business models (as well as your mind)". Archived from the original on 2008-02-05. http://web.archive.org/web/20080205114115/http://www.nivi.com/blog/article/greasemonkey-and-business-models/. Retrieved on 2008-09-29.
- Greasemonkey script compiler Converts Greasemonkey scripts into extensions
- Script compiler for conversion of Greasemonkey scripts to extensions
- Greasemonkey multi-script compiler converts multiple Greasemonkey users scrips into extensions
- Greasemonkey Explained for non-techies
- Greasemonkey in the Enterprise - blog series on security and deployment issues when using Greasemonkey for IT projects
- InternetDuctTape.com - Beginner's Guide to installing and using Greasemonkey user scripts
- Versions of Greasemonkey addon for the Seamonkey browser
[edit] External reviews
- Festa, Paul (24 March 2005). "Firefox add-on lets surfers tweak sites, but is it safe?". CNET. http://www.cnet.com.au/software/internet/0,39029524,40053700,00.htm.
- Singel, Ryan (17 May 2005). "Firefox Users Monkey With the Web?". Wired magazine. http://www.wired.com/news/technology/0,1282,67527,00.html.

