Greasemonkey
From Wikipedia, the free encyclopedia
This article needs additional citations for verification. Please help improve this article by adding reliable references (ideally, using inline citations). Unsourced material may be challenged and removed. (August 2008) |
Design by | Aaron Boodman |
---|---|
Latest 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 |
Mozilla Firefox (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. 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 it lists the URLs of web pages to which the scripts pertain. 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 XPCNativeWrappers. Compared to writing a full-fledged Firefox extension, user scripting is a very modest step up in complexity from basic web programming.
For an interactive approach to modifying web pages that does not require programming, see Platypus [2], a Firefox extension that allows you to modify pages by clicking on objects.
[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 correlating information from related pages on the same site, or other sites. (For example, list the prices of competing retailers' for the same product.)
- Add extended JavaScript behavior 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[3] and Songbird.[4]
[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.[5]
[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 function 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).[6] 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.[7] Chrome ignores @include 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
- Super GreaseMonkey is a mod of Greasemonkey that supports runtime libraries (specifically jquery) for user scripts.
- Bubbles is the first Site-Specific-Browser, and it uses JS injection of user-scripts, very much like Greasemonkey.
[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.
[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
[edit] Notes
- ^ http://commons.oreilly.com/wiki/index.php/Greasemonkey_Hacks/Getting_Started#Avoid_Common_Pitfalls
- ^ [1]
- ^ [2]
- ^ [3]
- ^ "Take Control with User JavaScript". Opera Software. http://www.opera.com/docs/userjs/examples/#greasemonkey. Retrieved on 2009-03-26.
- ^ [4]
- ^ http://dev.chromium.org/developers/design-documents/user-scripts
[edit] External links
This article includes a list of references 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 compiler converts Greasemonkey user scripts into full-fledged 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.