O'Reilly Hacks
oreilly.comO'Reilly NetworkSafari BookshelfConferences Sign In/My Account | View Cart   
Book List Learning Lab PDFs O'Reilly Gear Newsletters Press Room Jobs  


 
Buy the book!
Greasemonkey Hacks
By Mark Pilgrim
November 2005
More Info

How do these hacks stand up? Comment on a hack from the book by choosing the associated "Discuss" link below. You can also view the code from any of the hacks by clicking on the "Listing" or "Code" links. A number of hacks have been selected to be featured online in their entirety; you may view those hacks by clicking on the hack titles that are linked.

You can also download all the scripts and other files for this book here.

Jump to: Getting Started  | Linkmania!  | Beautifying the Web  | Web Forms  | Developer Tools  | Search  | Web Mail  | Accessibility  | Taking Back the Browser  | Syndication  | Site Integration  | Those Not Included in This Classification

Getting Started

HACK
#1

Install a User Script
Greasemonkey won't do anything until you start installing user scripts to customize specific web pages
[Discuss (0) | Link to this hack]

HACK
#2

Provide a Default Configuration
User scripts can be self-describing; they can contain information about what they do and where they should run by default
The Code
[Discuss (0) | Link to this hack]

HACK
#3

Master the @include and @exclude Directives
Describing exactly where you want your user script to execute can be tricky
[Discuss (0) | Link to this hack]

HACK
#4

Prevent a User Script from Executing
You can disable a user script temporarily, disable all user scripts, or uninstall a user script permanently
[Discuss (0) | Link to this hack]

HACK
#5

Configure a User Script
There's more than one way to configure Greasemonkey user scripts: before, during, and after installation
[Discuss (0) | Link to this hack]

HACK
#6

Add or Remove Content on a Page
Use DOM methods to manipulate the content of a web page
[Discuss (0) | Link to this hack]

HACK
#7

Alter a Page's Style
There are four basic ways to add or modify a page's CSS rules
[Discuss (0) | Link to this hack]

HACK
#8

Master XPath Expressions
Tap into a powerful new way to find exactly what you're looking for on a page
[Discuss (0) | Link to this hack]

HACK
#9

Develop a User Script "Live"
Edit a user script and see your changes immediately
[Discuss (0) | Link to this hack]

HACK
#10

Debug a User Script
Learn the subtle art of Greasemonkey debugging
[Discuss (0) | Link to this hack]

HACK
#11

Embed Graphics in a User Script
Add images to web pages without hitting a remote server
The Code
[Discuss (0) | Link to this hack]

HACK
#12

Avoid Common Pitfalls
Learn the history of Greasemonkey security and how it affects you now
[Discuss (0) | Link to this hack]

Linkmania!

HACK
#13

Turn Naked URLs into Hyperlinks
Make every URL clickable
The Code
[Discuss (0) | Link to this hack]

HACK
#14

Force Offsite Links to Open in a New Window
Keep your browser organized by automatically opening each site in its own window
The Code
[Discuss (0) | Link to this hack]

HACK
#15

Fix Broken Pop-up Links
Change javascript: pseudo-protocol pop-up windows into normal hyperlinks
The Code
[Discuss (0) | Link to this hack]

HACK
#16

Remove URL Redirections
Cut out the middleman and make links point directly to where you want to go
The Code
[Discuss (0) | Link to this hack]

HACK
#17

Warn Before Opening PDF Links
Make your browser double-check that you really want to open that monstrous PDF
The Code
[Discuss (0) | Link to this hack]

HACK
#18

Avoid the Slashdot Effect
Add web cache links to Slashdot articles
The Code
[Discuss (0) | Link to this hack]

HACK
#19

Convert UPS and FedEx Tracking Numbers to Links
Make it easier to track packages
The Code
[Discuss (0) | Link to this hack]

HACK
#20

Follow Links Without Clicking Them
Hover over any link for a short time to open it in a new tab in the background
The Code
[Discuss (0) | Link to this hack]

Beautifying the Web

HACK
#21

Banish the Scourge of Arial
Make the Web a typographically better place
The Code
[Discuss (0) | Link to this hack]

HACK
#22

Add Stripes to Data Tables
Make tables easier to read by highlighting alternate rows
The Code
[Discuss (0) | Link to this hack]

HACK
#23

Straighten Smart Quotes
Convert curly quotes, apostrophes, and other fancy typographical symbols back to their ASCII equivalents
The Code
[Discuss (0) | Link to this hack]

HACK
#24

Convert Graphical Smileys to Text
Are you tired of little smiley icons infesting web pages and discussion forums? Convert them back to text
The Code
[Discuss (0) | Link to this hack]

HACK
#25

Make Amazon Product Images Larger
Amazon lets you see larger product images in a separate window. Display them inline instead
The Code
[Discuss (0) | Link to this hack]

HACK
#26

Convert Straight Quotes
Automatically convert straight quotes to "smart" quotes, like word processors do
The Code
[Discuss (0) | Link to this hack]

HACK
#27

Add Dynamic Highlighting to Tables
Make tables easier to navigate by highlighting the current row
The Code
[Discuss (0) | Link to this hack]

HACK
#28

Make Pop-up Titles Prettier
Spice up those boring link tool tips
The Code
[Discuss (0) | Link to this hack]

Web Forms

HACK
#29

Display Form Actions in a Tool Tip
Hover over a form's Submit button to see where the form will be submitted
The Code
[Discuss (0) | Link to this hack]

HACK
#30

Show Hidden Form Fields
See what hidden information you're submitting to a site
The Code
[Discuss (0) | Link to this hack]

HACK
#31

Identify Password Fields
Decorate password fields with a special background pattern
The Code
[Discuss (0) | Link to this hack]

HACK
#32

Allow Password Remembering
Let the browser's password manager do its job
The Code
[Discuss (0) | Link to this hack]

HACK
#33

Confirm Before Closing Modified Pages
Don't lose your changes in web forms when you accidentally close your browser window
The Code
[Discuss (2) | Link to this hack]

HACK
#34

Resize Text Input Fields with the Keyboard
Give yourself some more room to type in web forms
The Code
[Discuss (0) | Link to this hack]

HACK
#35

Enter Textile Markup in Web Forms
Add a button to textareas to convert textile input to XHTML
The Code
[Discuss (0) | Link to this hack]

HACK
#36

Select Multiple Checkboxes
Toggle series of checkboxes at once in web forms with a Shift-click
The Code
[Discuss (0) | Link to this hack]

HACK
#37

Keep Track of Secure Site Passwords
Generate random passwords for every site based on a master password
The Code
[Discuss (0) | Link to this hack]

HACK
#38

Automatically Log into Web Mail and Other Sites
Automate the hassle of using web-based login forms
The Code
[Discuss (0) | Link to this hack]

HACK
#39

Build Calendar Events
Use a graphical interface to construct HCalendar event markup
The Code
[Discuss (0) | Link to this hack]

Developer Tools

HACK
#40

Remove All Page Styles on Selected Sites
Disable all CSS styling on sites that go out of their way to make themselves unreadable
The Code
[Discuss (0) | Link to this hack]

HACK
#41

Refresh Pages Automatically
Reload selected pages every 20 minutes
The Code
[Discuss (0) | Link to this hack]

HACK
#42

Make External Stylesheets Clickable
Ever want to see a page's stylesheets? Stop digging through source code to find them
The Code
[Discuss (0) | Link to this hack]

HACK
#43

Show Image Information
Generate a report of all the images on a page
The Code
[Discuss (0) | Link to this hack]

HACK
#44

Filter Code Examples on MSDN
Display only the MSDN code samples and APIs for the languages you care about
The Code
[Discuss (0) | Link to this hack]

HACK
#45

Intercept and Modify Form Submissions
Gain the ultimate control over web forms
The Code
[Discuss (0) | Link to this hack]

HACK
#46

Trace XMLHttpRequest Activity
Log XMLHttpRequest calls into JavaScript Console
The Code
[Discuss (1) | Link to this hack]

Search

HACK
#47

Add a Site Search
Google can restrict your search to a specific site. You can take advantage of this feature to add a site search to every page you visit
The Code
[Discuss (0) | Link to this hack]

HACK
#48

Remove Spammy Domains from Search Results
Fight back against search engine spammers who register domains with multiple "hot" keywords separated by hyphens
The Code
[Discuss (0) | Link to this hack]

HACK
#49

Find Similar Images
Explore the Web in a new way by finding other images of the same name
The Code
[Discuss (0) | Link to this hack]

HACK
#50

Search Wikipedia with Google Site Search
Replace Wikipedia's slow search engine with Google's lightning-quick site search
The Code
[Discuss (0) | Link to this hack]

HACK
#51

Link to Other Search Engines from Google
Make Google even more useful by adding links to competitors
The Code
[Discuss (0) | Link to this hack]

HACK
#52

Prefetch Yahoo! Search Results
Automatically prefetch and cache the first search result on Yahoo! Web Search
The Code
[Discuss (0) | Link to this hack]

HACK
#53

Browse the Web Through Google's Cache
Change links in cached pages to point to the cached version
The Code
[Discuss (0) | Link to this hack]

HACK
#54

Add More Book Reviews to Google Print
Link to other book review and shopping sites after reading Google's book excerpts
The Code
[Discuss (0) | Link to this hack]

HACK
#55

Autocomplete Search Terms as You Type
Google can suggest your search terms before you even finish typing them
The Code
[Discuss (0) | Link to this hack]

HACK
#56

Highlight Search Terms
When you click through to a page from a search engine, highlight the terms you originally searched for
The Code
[Discuss (0) | Link to this hack]

HACK
#57

Remember Recent Google Searches
Track what you search for and which search results you follow
The Code
[Discuss (0) | Link to this hack]

HACK
#58

Add Keyboard Shortcuts to Google Search Results
If you search frequently and type as quickly as you think, you'll appreciate this keyboard-only hack
The Code
[Discuss (0) | Link to this hack]

HACK
#59

Use Recent Searches and Google SearchKeys Together
Recent Searches needs an update to play nicely with Google SearchKeys
The Code
[Discuss (0) | Link to this hack]

Web Mail

HACK
#60

Force Gmail to Use a Secure Connection
Protect your inbox by automatically redirecting Gmail to an https:// address
The Code
[Discuss (0) | Link to this hack]

HACK
#61

Warn Before Replying to Multiple Recipients in Gmail
Don't embarrass yourself by sending private replies to everyone
The Code
[Discuss (0) | Link to this hack]

HACK
#62

Warn Before Sending Gmail Messages with Missing Attachments
Never again forget to attach a file to your email
The Code
[Discuss (0) | Link to this hack]

HACK
#63

Compose Your Mail in Gmail
Make mailto: links open the Gmail compose page
The Code
[Discuss (1) | Link to this hack]

HACK
#64

Add a Delete Button to Gmail
Improve the Gmail interface with the most requested feature that Google doesn't want you to have
The Code
[Discuss (0) | Link to this hack]

HACK
#65

Select Your Yahoo! ID from a List
Add a drop-down menu on Yahoo!'s login form to select your username
The Code
[Discuss (0) | Link to this hack]

HACK
#66

Add Saved Searches to Gmail
Keep often-used searches at your fingertips
The Code
[Discuss (2) | Link to this hack]

Accessibility

HACK
#67

Highlight Images Without Alternate Text
Quickly see which of your images are missing the required alt attribute
The Code
[Discuss (0) | Link to this hack]

HACK
#68

Add an Access Bar with Keyboard Shortcuts
Display shortcut keys defined by a page
The Code
[Discuss (0) | Link to this hack]

HACK
#69

Remove Conflicting Keyboard Shortcuts
Remove annoying access keys from web pages that define conflicting shortcuts
The Code
[Discuss (0) | Link to this hack]

HACK
#70

Make Image alt Text Visible
Display otherwise invisible information in image alt attributes as a tool tip
The Code
[Discuss (0) | Link to this hack]

HACK
#71

Add a Table of Contents to Long Pages
Create a menu out of a page's header tags
The Code
[Discuss (0) | Link to this hack]

HACK
#72

Use Real Headers on Google Web Search
Make Google's markup more semantic, and learn why it matters
The Code
[Discuss (0) | Link to this hack]

HACK
#73

Add a Toolbar to Zoom Images Easily
Reduce or enlarge individual images with a single click
The Code
[Discuss (0) | Link to this hack]

HACK
#74

Make Apache Directory Listing Prettier
Enhance Apache's autogenerated directory listing pages with semantic, accessible tables
The Code
[Discuss (1) | Link to this hack]

HACK
#75

Add a Text-Sizing Toolbar to Web Forms
Insert buttons before <textarea> elements to make the text larger or smaller
The Code
[Discuss (0) | Link to this hack]

HACK
#76

Make Google More Accessible for Low-Vision Users
Change Google's layout to make it easier for low-vision users to read
The Code
[Discuss (0) | Link to this hack]

Taking Back the Browser

HACK
#77

Reenable Context Menus on Sites That Disable Them
Tired of too-clever web developers disabling right-click on images? Reenable the full functionality of your browser
The Code
[Discuss (0) | Link to this hack]

HACK
#78

Bypass Weight Watchers' Browser Checker
For some reason, WeightWatchers.com doesn't like Firefox
The Code
[Discuss (0) | Link to this hack]

HACK
#79

Easily Download Embedded Movies
Add a download link next to movies and Flash animations in web pages
The Code
[Discuss (0) | Link to this hack]

HACK
#80

Break Out of Frames
Replace a framed document with the biggest single frame
The Code
[Discuss (0) | Link to this hack]

HACK
#81

Disable Targets for Downloads
Don't open a new window when downloading a file
The Code
[Discuss (0) | Link to this hack]

HACK
#82

Automatically Link to Printer-Friendly Versions
Get the content without the cruft by changing selected article links to "printer-friendly" versions
The Code
[Discuss (0) | Link to this hack]

HACK
#83

Restore Functionality in Google Print
Google Print goes to extraordinary lengths to keep you from downloading images, but you don't need to go to the same extraordinary lengths to get them anyway
The Code
[Discuss (0) | Link to this hack]

HACK
#84

Bypass Annoying Site Registrations
Autofill privacy-invading registration pages
The Code
[Discuss (0) | Link to this hack]

Syndication

HACK
#85

Automatically Display Unread Items in Bloglines
Bloglines already defines a function to display unread items. Save yourself a click and call it automatically
The Code
[Discuss (0) | Link to this hack]

HACK
#86

Zap Ugly XML Buttons
Make weblogs more palatable by replacing those orange XML buttons
The Code
[Discuss (0) | Link to this hack]

HACK
#87

Squeeze More Feeds into the Bloglines Sidebar
Tweak Bloglines' style to see more subscriptions without scrolling
The Code
[Discuss (0) | Link to this hack]

HACK
#88

Automatically Collect Syndicated Feeds
Autodiscover RSS and Atom feeds as you browse, and then generate a subscriptions file you can import into any news aggregator
The Code
[Discuss (0) | Link to this hack]

HACK
#89

Syndicate Encrypted Content
Publish sensitive data securely and decrypt it on the fly
The Code
[Discuss (0) | Link to this hack]

Site Integration

HACK
#90

Translate Any Web Page
Add a form at the top of every web page to translate it into your language
The Code
[Discuss (0) | Link to this hack]

HACK
#91

Warn Before Buying an Album
Find out whether an album is produced by a record label that supports the RIAA
The Code
[Discuss (0) | Link to this hack]

HACK
#92

Find Out Who's Reading What You're Reading
Use Feedster to find weblogs that link to the current page
The Code
[Discuss (0) | Link to this hack]

HACK
#93

Add Wikipedia Links to Any Web Page
Turn the Web into the ultimate cross-referenced library
The Code
[Discuss (0) | Link to this hack]

HACK
#94

Compare Book Prices
Add competitors' prices to online book retailers
The Code
[Discuss (0) | Link to this hack]

Those Not Included in This Classification

HACK
#95

Maximize HomestarRunner Cartoons
Make Flash animations fill the entire browser window
The Code
[Discuss (0) | Link to this hack]

HACK
#96

Refine Your Google Search
Google might already know what keywords you should add to your search to find exactly what you're looking for
The Code
[Discuss (0) | Link to this hack]

HACK
#97

Check Whether Pages Really Validate
If someone puts a badge on her site claiming to be "Valid XHTML," run it through the W3C Validator and see if she's telling the truth
The Code
[Discuss (0) | Link to this hack]

HACK
#98

Animate Wikipedia History
Watch a full-screen timeline of how a Wikipedia page evolved
The Code
[Discuss (0) | Link to this hack]

HACK
#99

Create Greasemonkey Scripts Automatically
Meet Platypus, the graphical interface for Greasemonkey
[Discuss (0) | Link to this hack]

HACK
#100

Remember Everything You Read
Create a personal command line for the Web
The Code
[Discuss (0) | Link to this hack]


O'Reilly Home | Privacy Policy

© 2007 O'Reilly Media, Inc.
Website: | Customer Service: | Book issues:

All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.