Greasemonkey Explained

Greasemonkey
Author:Aaron Boodman
Developer:Anthony Lieuallen, Johan Sundström,[1] 13 more[2]
Released:[3]
Latest Release Version:4.13
Programming Language:JavaScript, XUL, CSS
Operating System:Cross-platform
Language:English
Genre:Mozilla extension
License:MIT License

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.[4] [5] [6] 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.[7] In July 2005, serious vulnerabilities were found in Greasemonkey by Mark Pilgrim,[8] [9] and fixed in the 3.5 version of Greasemonkey.[10] During this time, a Greasemonkey compiler was also developed for converting a userscript into a standalone Firefox extension.[11] Greasemonkey was initially met with complaints by publishers for its ability to block ads.[12] 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.[13] 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.[14] Nevertheless, he remained the sole admin of the site until a discussion about install counts began on 1 April 2013.[15] 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.[16] With no further communication by Andrews, userscript writers described the site as neglected and the official Greasemonkey site removed its front page link.[17] [18] In response, script writers and other developers began working on the fork "openuserjs.org",[19] [20] and later greasyfork.org,[21] as an immediate replacement.[22]

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[23] 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:[24]

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,[25] [26] Songbird,[27] Pale Moon,[28] qutebrowser,[29] and Falkon browser.

See also

Notes and References

  1. Web site: Greasespot: Outie. boots. 23 August 2009. Greasespot.
  2. Web site: The greasemonkey network graph. GitHub.
  3. Web site: Version history – GreaseSpot Wiki. wiki.greasespot.net.
  4. Web site: Greasemonkey Project Info. 31 August 2011. https://web.archive.org/web/20120325005436/https://www.mozdev.org/projects/overview/greasemonkey/. 25 March 2012. dead.
  5. Book: Pilgrim, Mark . Greasemonkey Hacks . O'Reilly . 2005 . 978-0-596-55357-9 .
  6. Web site: Boodman . Aaron . 1 February 2010 . 40,000 More Extensions! . 5 March 2023 . Chromium Blog.
  7. News: Singel . Ryan . Firefox Users Monkey With the Web? . 17 May 2005 . Wired magazine .
  8. Web site: [Greasemonkey] greasemonkey for secure data over insecure networks / Sites . 24 February 2021 . 3 March 2020 . https://web.archive.org/web/20200303221552/http://mozdev.org/pipermail/greasemonkey/2005-July/004033.html . dead .
  9. Web site: Security [LWN.net].
  10. Web site: mozdev.org – : /pipermail/greasemonkey/2005-July/004379 . mozdev.org . dead . https://web.archive.org/web/20050729013418/http://mozdev.org/pipermail/greasemonkey/2005-July/004379.html . 2005-07-29.
  11. Web site: Greasemonkey will blow up business models (as well as your mind) . https://wayback.archive-it.org/all/20060603031119/http://www.nivi.com/blog/article/greasemonkey-and-business-models/ . 8 May 2005 . Nivi . 3 June 2006 . 22 July 2010 . dead .
  12. News: Festa . Paul . Firefox add-on lets surfers tweak sites, but is it safe? . 24 March 2005 . CNET .
  13. Web site: Userscripts.org... Opensource!. Britt. Selvitelle. 3 January 2007. 21 May 2014. 17 January 2007. https://web.archive.org/web/20070117065443/http://lukewarmtapioca.com/2007/1/3/userscripts-org-opensource.
  14. Web site: Passing the torch on userscripts.org. Hacker News. 2010. 24 October 2014.
  15. Web site: Fixing Install Counts. 1 April 2013. 21 May 2014. https://web.archive.org/web/20131103143628/http://userscripts.org/topics/124726. 3 November 2013.
  16. Web site: Userscripts.org down for good? Here are alternatives. Martin. Brinkmann. 9 May 2014. 21 May 2014.
  17. Web site: User Script Hosting. 16 May 2014. 21 May 2014.
  18. Please change the official userscript site. 21 April 2014. 21 May 2014. greasemonkey-dev.
  19. Web site: OpenUserJS. openuserjs.org.
  20. Web site: Fixing Install Counts – Page 6. 1 April 2013. 5 November 2015. https://web.archive.org/web/20131103143628/http://userscripts.org/topics/124726?page=6. 3 November 2013.
  21. Web site: Greasy Fork. greasyfork.org.
  22. Web site: Introducing Greasy Fork – a user scripts site. Jason. Barnabe. 19 February 2014. 5 November 2015.
  23. Web site: XPCNativeWrapper – MDC Docs . 16 March 2011 . 28 June 2011 . https://web.archive.org/web/20110628193117/https://developer.mozilla.org/en/XPCNativeWrapper . dead .
  24. Web site: User Script Hosting – GreaseSpot Wiki. wiki.greasespot.net. 2019-07-22.
  25. Web site: Greasemonkey. mozdev. 2009-05-05. mozdev.org. 23 April 2015. https://web.archive.org/web/20150423025939/http://xsidebar.mozdev.org/modifiedmisc.html#greasemonkey. dead.
  26. Web site: Greasemonkey Port for SeaMonkey – About – OpenUserJS. openuserjs.org.
  27. Web site: Greasemonkey. ianloic. Songbird. 5 May 2009. dead. https://web.archive.org/web/20080602060326/http://addons.songbirdnest.com/addon/79. 2 June 2008. dmy-all.
  28. Web site: janekptacijarabaci/greasemonkey. GitHub. en. 2020-03-23.
  29. Web site: Improvements for GreaseMonkey support · Issue #3238 · qutebrowser/qutebrowser. GitHub. en. 2020-05-19.