ArticleslgStudy

computer science

Greasemonkey

Greasemonkey is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Greasemonkey rather than just read about it. In short: Greasemonkey is a userscript manager made available as a Mozilla Firefox extension. It enables users to install scripts that make on-the-fly changes to web page content after or before the page is loaded in the browser (also known as augmented browsing).

Greasemonkey — main illustration
Greasemonkey — illustration

Key takeaways

  • Greasemonkey belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Greasemonkey to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Greasemonkey from memory before moving on to harder problems.

Reference excerpt

Greasemonkey is a userscript manager made available as a Mozilla Firefox extension. It enables users to install scripts that make on-the-fly changes to web page content after or before the page is loaded in the browser (also known as augmented browsing). 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, written by Adrian Holovaty, 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.

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 "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 and manipulate the contents of a web page using the Document Object Model 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 services 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 which specifies the name of the script, a description, resources required by 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.

User scripts File hosting servers for Greasemonkey require that the URLs for the scripts end with .user.js and not with a MIME type like text/html. Support for HTTPS will meet with Greasemonkey's built in update checker. As of July 2019, the Greasemonkey project lists three recommended user script hostings:

Gist, a pastebin service operated by GitHub where simple files are hosted. Files can be pasted into a web form and saved. HTTPS 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 for the deprecated script repository userscripts.org.

Compatibility Greasemonkey is available for Firefox, Flock, and GNOME Web (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 functions (e.g. GM_getValue) are unsupported. There are also custom versions for SeaMonkey, Songbird, Pale Moon, qutebrowser, and Falkon browser.

See also List of augmented browsing software List of Firefox extensions Tampermonkey

References

External links Media related to Greasemonkey at Wikimedia Commons

Official website

Illustrations

Greasemonkey illustration

Worked examples

Example 1 — a first encounter with Greasemonkey

Start with the simplest possible case. Write down what Greasemonkey claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Greasemonkey before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Greasemonkey ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Greasemonkey

In research
Greasemonkey appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Greasemonkey in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Greasemonkey is common in secondary-school and first-year university syllabi. It links to neighbouring topics Free Firefox WebExtensions, Free software programmed in JavaScript, Software using the MIT license, so understanding it makes those chapters shorter.
In everyday life
Look for Greasemonkey outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Greasemonkey” →

How to study Greasemonkey in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Greasemonkey means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Greasemonkey out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Greasemonkey in simple terms?

Greasemonkey is a userscript manager made available as a Mozilla Firefox extension. It enables users to install scripts that make on-the-fly changes to web page content after or before the page is loaded in the browser (also known as augmented browsing).

Why does Greasemonkey matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Greasemonkey?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Greasemonkey.

Tags

  • Free Firefox WebExtensions
  • Free software programmed in JavaScript
  • Software using the MIT license
  • Web scraping

Keep exploring