Greasemonkey is a
userscript manager made available as a
Mozilla Firefox
Mozilla Firefox, or simply Firefox, is a free and open-source web browser developed by the Mozilla Foundation and its subsidiary, the Mozilla Corporation. It uses the Gecko rendering engine to display web pages, which implements curren ...
extension. It enables users to install
scripts that make on-the-fly changes to
web page
A web page (or webpage) is a World Wide Web, Web document that is accessed in a web browser. A website typically consists of many web pages hyperlink, linked together under a common domain name. The term "web page" is therefore a metaphor of pap ...
content after or before the page is loaded in the browser (also known as
augmented browsing Web augmentation is the process of modifying or enriching existing web pages by adding new features, altering layouts, or injecting additional data at the client side. Common methods include installing browser extensions, using userscripts (client- ...
).
The changes made to the web pages are executed every time the page is viewed, making them effectively permanent for the user running the script.
Greasemonkey can be used for customizing page appearance, adding new functions to web pages (for example, embedding price comparisons within shopping sites), fixing rendering bugs, combining data from multiple web pages, and numerous other purposes.
History
The Greasemonkey project began 28 November 2004, written by Aaron Boodman. Boodman was inspired to write Greasemonkey after looking at a Firefox extension designed to clean up the interface of
AllMusic
AllMusic (previously known as All-Music Guide and AMG) is an American online database, online music database. It catalogs more than three million album entries and 30 million tracks, as well as information on Musical artist, musicians and Mus ...
,
written by
Adrian Holovaty
Adrian Holovaty (born 1981) is an American web developer, musician and entrepreneur from Chicago, Chicago, Illinois, living in Amsterdam, the Netherlands. He is co-creator of the Django (web framework), Django web framework and an advocate of "jou ...
, who later became a userscript developer. By May 2005, there were approximately 60 general and 115 site-specific userscripts distributed for Greasemonkey.
In July 2005, serious vulnerabilities were found in Greasemonkey by Mark Pilgrim, and fixed in the 3.5 version of Greasemonkey. During this time, a Greasemonkey compiler was also developed for converting a userscript into a standalone Firefox extension. Greasemonkey was initially met with complaints by publishers for its ability to block ads. However, this criticism shifted its focus to other addons starting with the 2006 release of
Adblock Plus
Adblock Plus (ABP) is a free and open-source browser extension for content-filtering and ad blocking. It is developed by Eyeo GmbH, a German software company. The extension has been released for Mozilla Firefox (including mobile), Google Chro ...
.
Userscripts.org
To accommodate the growing number of scripts, userscripts.org was founded by Britt Selvitelle and other members of the Greasemonkey community in late 2005. Userscripts.org was open sourced in 2007 but the site later moved away from this code base. As the main script repository listed on Greasemonkey's official site, userscripts.org accumulated thousands of scripts per year.
In 2010, the last known admin Jesse Andrews posted that the site was in maintenance mode due to lack of time and asked for a new maintainer to volunteer. Nevertheless, he remained the sole admin of the site until a discussion about install counts began on 1 April 2013.
Prior to this, many of the "most popular scripts" as listed by the site had nominal install counts of zero. Over the following year spam scripts became more common, server downtime increased and the install count bug remained.
With no further communication by Andrews, userscript writers described the site as neglected and the official Greasemonkey site removed its front page link. In response, script writers and other developers began working on the
fork
In cutlery or kitchenware, a fork (from 'pitchfork') is a utensil, now usually made of metal, whose long handle terminates in a head that branches into several narrow and often slightly curved tines with which one can spear foods either to h ...
"openuserjs.org",
and later greasyfork.org,
as an immediate replacement.
In May 2014, userscripts.org became inaccessible on port 80, prompting users to access it on port 8080 instead.
In August 2014, the site was shut down completely. Most of its scripts were backed up to the static mirror userscripts-mirror.org where they can now be found.
Technical details
Greasemonkey user scripts are written in
JavaScript
JavaScript (), often abbreviated as JS, is a programming language and core technology of the World Wide Web, alongside HTML and CSS. Ninety-nine percent of websites use JavaScript on the client side for webpage behavior.
Web browsers have ...
and manipulate the contents of a web page using the
Document Object Model
The Document Object Model (DOM) is a cros s-platform and language-independent API that treats an HTML or XML document as a tree structure wherein each node is an object representing a part of the document. The DOM represents a document with ...
interface. Scripts are generally written to be either page-specific or domain-specific (applying to all pages within a domain) but may also be tagged to apply to all domains for global browser enhancements. Users of Greasemonkey can write or download scripts and save them to their own personal library. When users visit a website matching a script in their personal script library, Greasemonkey invokes the relevant scripts.
Greasemonkey scripts can modify a webpage in any way that JavaScript allows, with certain Greasemonkey security restrictions. Scripts can also access other web pages and
web service
A web service (WS) is either:
* a service offered by an electronic device to another electronic device, communicating with each other via the Internet, or
* a server running on a computer device, listening for requests at a particular port over a n ...
s via a
non-domain-restricted XMLHTTP request, allowing external content to be merged with the original page content.
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
metadata
Metadata (or metainformation) is "data that provides information about other data", but not the content of the data itself, such as the text of a message or the image itself. There are many distinct types of metadata, including:
* Descriptive ...
which specifies the name of the script, a description, resources required by the script, a
namespace
In computing, a namespace is a set of signs (''names'') that are used to identify and refer to objects of various kinds. A namespace ensures that all of a given set of objects have unique names so that they can be easily identified.
Namespaces ...
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
XMLHttpRequest
XMLHttpRequest (XHR) is an API in the form of a JavaScript object whose methods transmit HTTP requests from a web browser to a web server. The methods allow a browser-based application to send requests to the server after page loading is complet ...
s. 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.
User scripts
File hosting servers for Greasemonkey require that the
URL
A uniform resource locator (URL), colloquially known as an address on the Web, is a reference to a resource that specifies its location on a computer network and a mechanism for retrieving it. A URL is a specific type of Uniform Resource Identi ...
s for the scripts end with
.user.js
and not with a
MIME type
In information and communications technology, a media type, content type or MIME type is a two-part identifier for file formats and content formats. Their purpose is comparable to filename extensions and uniform type identifiers, in that they ide ...
like
text/html
. Support for
HTTPS
Hypertext Transfer Protocol Secure (HTTPS) is an extension of the Hypertext Transfer Protocol (HTTP). It uses encryption for secure communication over a computer network, and is widely used on the Internet. In HTTPS, the communication protoc ...
will meet with Greasemonkey's built in update checker. As of July 2019, the Greasemonkey project lists three recommended user script hostings:
*
Gist
In computing, GiST or Generalized Search Tree, is a data structure and API that can be used to build a variety of disk-based search trees. GiST is a generalization of the B+ tree, providing a concurrent and recoverable height-balanced search tree ...
, a
pastebin service operated by GitHub where simple files are hosted. Files can be pasted into a web form and saved.
HTTPS
Hypertext Transfer Protocol Secure (HTTPS) is an extension of the Hypertext Transfer Protocol (HTTP). It uses encryption for secure communication over a computer network, and is widely used on the Internet. In HTTPS, the communication protoc ...
is used by default. Files may follow the naming scheme with the ".user.js" suffix for the URL serving as an install link.
*Greasy Fork, a site created by the maintainer of userstyles.org.
*OpenUserJS.org, a site that started as a
fork
In cutlery or kitchenware, a fork (from 'pitchfork') is a utensil, now usually made of metal, whose long handle terminates in a head that branches into several narrow and often slightly curved tines with which one can spear foods either to h ...
for the deprecated script repository userscripts.org.
Compatibility
Greasemonkey is available for
Firefox
Mozilla Firefox, or simply Firefox, is a free and open-source web browser developed by the Mozilla Foundation and its subsidiary, the Mozilla Corporation. It uses the Gecko rendering engine to display web pages, which implements curr ...
,
Flock, and
GNOME Web
GNOME Web, called Epiphany until 2012 and still known by that code name, is a free and open-source web browser based on the GTK port of Apple's WebKit rendering engine, called WebKitGTK. It is developed by the GNOME project for Unix-like syst ...
(formerly called Epiphany). The Greasemonkey extension for Web is part of the
Web extensions package. However, this extension is not fully compatible as of release 2.15.1, since some Greasemonkey
API
An application programming interface (API) is a connection between computers or between computer programs. It is a type of software interface, offering a service to other pieces of software. A document or standard that describes how to build ...
functions (e.g. ''GM_getValue'') are unsupported. There are also custom versions for
SeaMonkey
SeaMonkey is a free and open-source Internet suite. It is the continuation of the former Mozilla Application Suite, based on the same source code, which itself grew out of Netscape Communicator and formed the base of Netscape 6 and Netscape ...
,
Songbird
A songbird is a bird belonging to the suborder Passeri of the perching birds (Passeriformes). Another name that is sometimes seen as the scientific or vernacular name is Oscines, from Latin ''oscen'', "songbird". The Passeriformes contains 5,00 ...
,
Pale Moon
Pale Moon is a free and open-source web browser licensed under the MPL-2.0 with an emphasis on customization. There are official releases for Microsoft Windows, FreeBSD, macOS, and Linux.
Pale Moon originated as a fork of Firefox, but has subs ...
,
qutebrowser,
and
Falkon browser.
See also
*
List of augmented browsing software
*
List of Firefox extensions
*
Tampermonkey
Tampermonkey is a closed-source donationware userscript manager that is available as a browser extension. This software enables the user to add and use userscripts, which are JavaScript programs that can be used to modify web pages.
History
Tamp ...
References
External links
*{{Official website, https://www.greasespot.net/
Free Firefox WebExtensions
Free software programmed in JavaScript
Web scraping