Dive Into Greasemonkey
  • Author: Mark Pilgrim
  • Format: online HTML, archived HTML, archived PDF, archived plain text, Palm OS, archived video demonstrations
  • Price: free

Greasemonkey is a Firefox extension that allows you to write scripts that alter the web pages you visit. You can use it to make a web site more readable or more usable. You can fix rendering bugs that the site owner can’t be bothered to fix themselves. You can alter pages so they work better with assistive technologies that speak a web page out loud or convert it to Braille. You can even automatically retrieve data from other sites to make two sites more interconnected.

There is a huge repository of user scripts that do all kinds of amazing things at Userscripts.org.

But Firefox isn’t the only browser that you can write these scripts for. There is also a macro for K-Meleon called GreaseMeleon, that will allow that browser to use Greasemonkey scripts, too. And there is even a way to use them in Google’s Chrome browser. (instructions)

All this is great if all you want to do is use Greasemonkey scripts, but what if you want to write your own? That’s where Dive Into Greasemonkey can help.

It takes you step-by-step from explaining what Greasemonkey is, installing it into Firefox, installing user scripts, to actually writing and debugging your own. Chock full of information that will help the beginner and expert, alike.

Dive into Greasemonkey is a valuable reference for anyone that wants to truly unleash the power of user scripts.

Chapters include:

  • What is Greasemonkey?
  • Installing Greasemonkey
  • Installing a user script
  • Managing your user scripts
  • Hello World
  • Describing your user script with metadata
  • Coding your user script
  • Editing your user script
  • Debugging User Scripts
  • Tracking crashes with JavaScript Console
  • Logging with GM_log
  • Inspecting elements with DOM Inspector
  • Evaluating expressions with Javascript Shell
  • Other debugging tools
  • Executing a user script on a domain and all its subdomains
  • Testing whether a Greasemonkey function is available
  • Testing whether a page includes an HTML element
  • Doing something for every HTML element
  • Doing something for every instance of a specific HTML element
  • Doing something for every element with a certain attribute
  • Inserting content before an element
  • Inserting content after an element
  • Removing an element
  • Replacing an element with new content
  • Inserting complex HTML quickly
  • Adding images without hitting a central server
  • Adding CSS styles
  • Getting an element’s style
  • Setting an element’s style
  • Post-processing a page after it renders
  • Matching case-insensitive attribute values
  • Getting the current domain name
  • Rewriting links
  • Redirecting pages
  • Intercepting user clicks
  • Overriding a built-in Javascript method
  • Parsing XML
  • Case Studies
  • Case study: GMail Secure
  • Case study: Bloglines Autoload
  • Case study: Ain’t It Readable
  • Case study: Offsite Blank
  • Case study: Dumb Quotes
  • Case study: Frownies
  • Case study: Zoom Textarea
  • Case study: Access Bar
  • Storing and retrieving persistent data
  • Adding items to the menubar
  • Integrating data from other sites
  • Compiling your user script into an extension
  • Greasemonkey API Reference
  • GM_log – log messages to the JavaScript Console
  • GM_getValue – get script-specific configuration value
  • GM_setValue – set script-specific configuration value
  • GM_registerMenuCommand – add a menu item to the User Script Commands submenu
  • GM_xmlhttpRequest – make an arbitrary HTTP request
  • List of “further reading” links
  • List of tips
  • List of examples
  • List of procedures

http://web.archive.org/web/20110726001221/http://diveintogreasemonkey.org/