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 bugs that site owners 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.
The term hacking has a bad reputation in the press. They use it to refer to someone who breaks into systems or wreaks havoc with computers as their weapon. Among people who write code, though, the term hack refers to a “quick-and-dirty” solution to a problem, or a clever way to get something done. And the term hacker is taken very much as a compliment, referring to someone as being creative, having the technical chops to get things done. The Hacks series is an attempt to reclaim the word, document the good ways people are hacking, and pass the hacker ethic of creative participation on to the uninitiated. Seeing how others approach systems and problems is often the quickest way to learn about a new technology.
Clearly, there were a lot of itches waiting to be scratched.
Some hacks in this book are short and sweet; they do one thing and do it well. (One is just a single line of code!) Other hacks are hundreds of lines long, complete with their own user interface, their own data cache, and their own preferences. This book showcases the best of the best, from “Hey, that’s always bugged me,” to “Gee, I don’t know how I ever lived without this,” to “Wow, I had no idea a browser could do that.”
You can read this book from cover to cover if you like, but each hack stands on its own, so feel free to browse and jump to the different sections that interest you most. If there’s a prerequisite you need to know about, a cross-reference will guide you to the right hack.
The book is divided into 12 chapters, roughly organized by topic:
It’s hard to do cool stuff when you don’t even know where to click. The hacks in this chapter will get you started using the Greasemonkey interface, installing user scripts, and developing your own.
You can’t spit in this town without hitting a web form.
<input> boxes in particular make a satisfying “ping” when you hit them. Discover what all those forms are doing behind your back. Plus, never forget a web site password again.
You don’t just live online; you occasionally work there, too. Make the browser a better tool for web development with these hacks. Does the term AJAX ring a bell? You’re going to love this chapter.
Hey there! Yes, you. Stop searching for porn long enough to read this chapter. It’s all about how to make searching the Web easier and faster. What you do with that information is between you and your webcam.
Web-based email sucks. But you can’t live without it. Have you ever accidentally hit “Reply All” instead of “Reply”? (Did your coworkers ever forgive you?) Who the hell put them one inch away from each other? Find out how to add essential features to web mail services such as Gmail and Yahoo! Mail.
Accessibility affects everyone, in every walk of life. One in 13 workers reported some form of disability last year. Learn how to make your own web site more accessible, and see how Greasemonkey can help people with disabilities use the Web.
Invasive site registrations. Brain-dead browser sniffers. Frames. Something about the Web makes content providers stupid. Learn how to route around them.
Blogs are all the rage. They’ve reached the tipping point. They’ve jumped the shark. They’ve taken the meme by the horns and the cliché by the throat. Dive into the wonderful world of syndicated feeds.
Find a book on Amazon.com and get price quotes from five other retailers without leaving the page. Enough said.
Good things come to those who wait. No, wait; this is a Hacks book! Jump right to the end; I’ve saved the best for last.
The following is a list of the typographical conventions used in this book:
Used to indicate URLs, filenames, filename extensions, and directory/folder names. For example, a path in the filesystem appears as /Developer/Applications.
Used to show code examples, the contents of files, console output, as well as the names of variables, commands, and other code excerpts.
Constant width bold
Used to highlight portions of code, typically new additions to old code.
Constant width italic
Used in code examples and tables to show sample text to be replaced with your own values.
You should pay special attention to notes set apart from the text with the following icons:
This is a tip, suggestion, or general note. It contains useful supplementary information about the topic at hand.
This is a warning or note of caution, often indicating that your money or your privacy might be at risk.
The thermometer icons, found next to each hack, indicate the relative complexity of the hack:
This book is here to help you get your job done. Thus, you may use the code in this book in your programs and documentation without contacting us for permission as long as you are reproducing limited portions for use in your own original programming and documentation projects, consistent with fair use under U.S. copyright law.
Thus, although incorporating some code from this book in a program that you write does not require permission, permission is required (whether or not you charge for access) if you want to include our code examples in a collection, inventory, or code repository—for instance, in a DVD collection of code examples from O’Reilly books. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission.
If you reproduce portions of our code examples, we appreciate an attribution that informs people of the title, author, publisher, and ISBN for this book, such as: "Greasemonkey Hacks by Mark Pilgrim, Copyright © 2006 O’Reilly Media, Inc., 0-596-10165-1.”
Information about fair use is available on the Copyright Office web site (www.copyright.gov), and from other online sources such as Stanford University’s copyright and fair use page (http://fairuse.stanford.edu/).
Permission requests for proposed uses of code examples that fall outside the scope of fair use should be sent to email@example.com.
When you see a Safari® Enabled icon on the cover of your favorite technology book, that means the book is available online through the O’Reilly Network Safari Bookshelf.
Safari offers a solution that’s better than e-books. It’s a virtual library that lets you easily search thousands of top tech books, cut and paste code samples, download chapters, and find quick answers when you need the most accurate, current information. Try it for free at http://safari.oreilly.com.
We have tested and verified the information in this book to the best of our ability, but you may find that features have changed (or even that we have made mistakes!). As a reader of this book, you can help us to improve future editions by sending us your feedback. Please let us know about any errors, inaccuracies, bugs, misleading or confusing statements, and typos that you find anywhere in this book.
Please also let us know what we can do to make this book more useful to you. We take your comments seriously and will try to incorporate reasonable suggestions into future editions. You can write to us at:
|O’Reilly Media, Inc.|
|1005 Gravenstein Highway North|
|Sebastopol, CA 95472|
|(800) 998-9938 (in the United States or Canada)|
|(707) 829-0515 (international/local)|
|(707) 829-0104 (fax)|
To ask technical questions or to comment on the book, send email to:
The web site for Greasemonkey Hacks lists examples, errata, and plans for future editions. You can find this page at:
For more information about this book and others, see the O’Reilly web site:
To explore Hacks books online or to contribute a hack for future titles, visit: