Greasemonkey

From Wikipedia, the free encyclopedia
Jump to: navigation, search
Greasemonkey
Gm icon.png
Original author(s) Aaron Boodman
Developer(s) Anthony Lieuallen, Johan Sundström[1], 13 more[2]
Initial release March 28, 2005; 5 years ago (2005-03-28)[3]
Stable release 0.8.20100408.6 / April 8, 2010; 4 months ago (2010-04-08)
Preview release 0.9.0 / September 1, 2010; 5 days ago (2010-09-01)[4]
Written in JavaScript, XUL, CSS
Operating system Cross-platform
Available in English
Type Mozilla extension
License Expat License
Website www.greasespot.net
Firefox.svg
(category)
Contents
Origins and Lineage

Greasemonkey is a Mozilla Firefox extension that allows users to install scripts that make on-the-fly changes to HTML web page content on the DOMContentLoaded event, which happens immediately after it is loaded in the browser (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 comparisons within shopping sites), fixing rendering bugs, combining data from multiple webpages, and numerous other purposes.

Contents

[edit] Technical details

Greasemonkey user scripts are written in JavaScript 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.

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, I/O processes or its 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 APIs such as GM_getValue and GM_setValue to overcome this.

[edit] Typical Greasemonkey scripts

Users have written scripts that:

[edit] Compatibility

Greasemonkey is available for Firefox, Flock and Epiphany. Google Chrome has built-in support for Greasemonkey scripts. 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[5] and Songbird.[6]

[edit] Equivalents for other browsers

Versions 8 and upwards of Opera also have user scripting functionality and are capable of running many Greasemonkey user scripts.[7]

For Internet Explorer, similar functionality is offered by IE7Pro,[8] Sleipnir,[9] and iMacros.

As of February 2010, Chrome has "native support" for Greasemonkey scripts.[10] They are internally converted to extensions, and are managed as such. 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. In Chrome, scripts that use one of the GM_setValue or GM_getValue initiatives will break, and scripts that use the popular E4X standard will not run.[citation needed]

On Safari (and other Webkit applications), there is a SIMBL-managed plug-in called GreaseKit. Since the release of Safari 5 there is an extension called NinjaKit that uses the new API interface.[11]

Fluid, is by nature, a site specific browser which supports userscripts.

Also there is a script which emulates greasemonkeys API in not gecko browsers.Project Page

[edit] See also

[edit] References

[edit] External links

Personal tools
Namespaces
Variants
Actions
Navigation
Interaction
Toolbox
Print/export
Languages