Greasemonkey Hacks

Book description

Greasemonkey Hacks is an invaluable compendium 100 ingenious hacks for power users who want to master Greasemonkey, the hot new Firefox extension that allows you to write scripts that alter the web pages you visit. With Greasemonkey, you can create scripts that make a web site more usable, fix rendering bugs that site owners can't be bothered to fix themselves, or add items to a web site's menu bar. You can alter pages so they work better with technologies that speak a web page out loud or convert it to Braille. Greasemonkey gurus can even import, combine, and alter data from different web sites to meet their own specific needs.

Greasemonkey has achieved a cult-like following in its short lifespan, but its uses are just beginning to be explored. Let's say you're shopping on an e-commerce site. You can create a script that will automatically display competitive prices for that particular product from other web sites. The possibilities are limited only by your imagination and your Greasemonkey expertise. Greasemonkey Hacks can't help you with the imagination part, but it can provide the expert hacks-complete with the sample code-you need to turn your brainstorms into reality.

More than just an essential collection of made-to-order Greasemonkey solutions, Greasemonkey Hacks is crammed with sample code, a Greasemonkey API reference, and a comprehensive list of resources, to ensure that every resource you need is available between its covers.

Some people are content to receive information from websites passively; some people want to control it. If you are one of the latter, Greasemonkey Hacks provides all the clever customizations and cutting-edge tips and tools you need to take command of any web page you view.

Publisher resources

View/Submit Errata

Table of contents

  1. Greasemonkey Hacks
    1. SPECIAL OFFER: Upgrade this ebook with O’Reilly
    2. A Note Regarding Supplemental Files
    3. Foreword
    4. Credits
      1. About the Author
      2. Contributors
      3. Acknowledgments
    5. Preface
      1. Why Greasemonkey Hacks?
      2. How This Book Is Organized
      3. Conventions Used in This Book
      4. Using Code Examples
      5. Safari Enabled
      6. How to Contact Us
      7. Got a Hack?
    6. 1. Getting Started
      1. 1.1. Hacks 1–12: Introduction
      2. Hack #1. Install a User Script
        1. 1.2.1. Installing from the Context Menu
        2. 1.2.2. Installing from the Tools Menu
        3. 1.2.3. Editing Greasemonkey's Configuration Files
      3. Hack #2. Provide a Default Configuration
        1. 1.3.1. The Code
        2. 1.3.2. Wrapper
        3. 1.3.3. Name
        4. 1.3.4. Namespace
        5. 1.3.5. Description
        6. 1.3.6. URL Directives
      4. Hack #3. Master the @include and @exclude Directives
        1. 1.4.1. Matching with or Without the www. Prefix
        2. 1.4.2. Matching All Subdomains of a Site
        3. 1.4.3. Matching Different Top-Level Domains of a Site
        4. 1.4.4. Deciding Between * and http://*
      5. Hack #4. Prevent a User Script from Executing
        1. 1.5.1. Disabling a User Script Without Uninstalling It
        2. 1.5.2. Disabling All User Scripts
        3. 1.5.3. Disabling a User Script by Removing All Included Pages
        4. 1.5.4. Disabling a User Script by Excluding All Pages
        5. 1.5.5. Disabling a User Script by Editing config.xml
        6. 1.5.6. Uninstalling a User Script
      6. Hack #5. Configure a User Script
        1. 1.6.1. Inline
        2. 1.6.2. During Installation
        3. 1.6.3. After Installation
        4. 1.6.4. Editing Configuration Files
      7. Hack #6. Add or Remove Content on a Page
        1. 1.7.1. Adding an Element
        2. 1.7.2. Removing an Element
        3. 1.7.3. Inserting an Element
        4. 1.7.4. Replacing an Element
        5. 1.7.5. Modifying an Element's Attributes
      8. Hack #7. Alter a Page's Style
        1. 1.8.1. Adding a Global Style
        2. 1.8.2. Inserting or Removing a Single Style
        3. 1.8.3. Modifying an Element's Style
      9. Hack #8. Master XPath Expressions
        1. 1.9.1. Basic Syntax
        2. 1.9.2. Examples
      10. Hack #9. Develop a User Script "Live"
        1. 1.10.1. Setting Up File Associations
          1. 1.10.1.1. On Mac OS X.
          2. 1.10.1.2. On Windows.
        2. 1.10.2. The "Live Editing" Development Cycle
      11. Hack #10. Debug a User Script
        1. 1.11.1. Check Error Messages
        2. 1.11.2. Log Errors
        3. 1.11.3. Find Page Elements
        4. 1.11.4. Test JavaScript Code Interactively
      12. Hack #11. Embed Graphics in a User Script
        1. 1.12.1. The Code
        2. 1.12.2. Running the Hack
      13. Hack #12. Avoid Common Pitfalls
        1. 1.13.1. Security Hole #1: Source Code Leakage
        2. 1.13.2. Security Hole #2: API Leakage
        3. 1.13.3. Security Hole #3: Local File Access
        4. 1.13.4. Redesigning from the Ground Up
        5. 1.13.5. Going Deeper
        6. 1.13.6. Pitfall #1: Auto-eval Strings
        7. 1.13.7. Pitfall #2: Event Handlers
        8. 1.13.8. Pitfall #3: Named Forms and Form Elements
        9. 1.13.9. Pitfall #4: Custom Properties
        10. 1.13.10. Pitfall #5: Iterating Collections
        11. 1.13.11. Pitfall #6: scrollIntoView
        12. 1.13.12. Pitfall #7: location
        13. 1.13.13. Pitfall #8: Calling Remote Page Scripts
        14. 1.13.14. Pitfall #9: watch
        15. 1.13.15. Pitfall #10: style
        16. 1.13.16. Conclusion
    7. 2. Linkmania!
      1. 2.1. Hacks 13–20: Introduction
      2. Hack #13. Turn Naked URLs into Hyperlinks
        1. 2.2.1. The Code
        2. 2.2.2. Running the Hack
        3. 2.2.3. Hacking the Hack
      3. Hack #14. Force Offsite Links to Open in a New Window
        1. 2.3.1. The Code
        2. 2.3.2. Running the Hack
        3. 2.3.3. Hacking the Hack
      4. Hack #15. Fix Broken Pop-up Links
        1. 2.4.1. The Code
        2. 2.4.2. Running the Hack
        3. 2.4.3. Hacking the Hack
      5. Hack #16. Remove URL Redirections
        1. 2.5.1. The Code
        2. 2.5.2. Running the Hack
      6. Hack #17. Warn Before Opening PDF Links
        1. 2.6.1. The Code
        2. 2.6.2. Running the Hack
      7. Hack #18. Avoid the Slashdot Effect
        1. 2.7.1. The Code
        2. 2.7.2. Running the Hack
      8. Hack #19. Convert UPS and FedEx Tracking Numbers to Links
        1. 2.8.1. The Code
        2. 2.8.2. Running the Hack
      9. Hack #20. Follow Links Without Clicking Them
        1. 2.9.1. The Code
        2. 2.9.2. Running the Hack
    8. 3. Beautifying the Web
      1. 3.1. Hacks 21–28: Introduction
      2. Hack #21. Banish the Scourge of Arial
        1. 3.2.1. The Code
        2. 3.2.2. Running the Hack
        3. 3.2.3. Hacking the Hack
      3. Hack #22. Add Stripes to Data Tables
        1. 3.3.1. The Code
        2. 3.3.2. Running the Hack
        3. 3.3.3. Hacking the Hack
      4. Hack #23. Straighten Smart Quotes
        1. 3.4.1. The Code
        2. 3.4.2. Running the Hack
      5. Hack #24. Convert Graphical Smileys to Text
        1. 3.5.1. The Code
        2. 3.5.2. Running the Hack
        3. 3.5.3. Hacking the Hack
      6. Hack #25. Make Amazon Product Images Larger
        1. 3.6.1. The Code
        2. 3.6.2. Running the Hack
        3. 3.6.3. Hacking the Hack
      7. Hack #26. Convert Straight Quotes
        1. 3.7.1. The Code
        2. 3.7.2. Running the Hack
      8. Hack #27. Add Dynamic Highlighting to Tables
        1. 3.8.1. The Code
        2. 3.8.2. Running the Hack
        3. 3.8.3. Hacking the Hack
      9. Hack #28. Make Pop-up Titles Prettier
        1. 3.9.1. The Code
        2. 3.9.2. Running the Hack
        3. 3.9.3. Hacking the Hack
    9. 4. Web Forms
      1. 4.1. Hacks 29–39: Introduction
      2. Hack #29. Display Form Actions in a Tool Tip
        1. 4.2.1. The Code
        2. 4.2.2. Running the Hack
        3. 4.2.3. Hacking the Hack
      3. Hack #30. Show Hidden Form Fields
        1. 4.3.1. The Code
        2. 4.3.2. Running the Hack
      4. Hack #31. Identify Password Fields
        1. 4.4.1. The Code
        2. 4.4.2. Running the Hack
        3. 4.4.3. Hacking the Hack
      5. Hack #32. Allow Password Remembering
        1. 4.5.1. The Code
        2. 4.5.2. Running the Hack
      6. Hack #33. Confirm Before Closing Modified Pages
        1. 4.6.1. The Code
        2. 4.6.2. Running the Hack
        3. 4.6.3. Hacking the Hack
      7. Hack #34. Resize Text Input Fields with the Keyboard
        1. 4.7.1. The Code
        2. 4.7.2. Running the Hack
      8. Hack #35. Enter Textile Markup in Web Forms
        1. 4.8.1. The Code
        2. 4.8.2. Running the Hack
        3. 4.8.3. Hacking the Hack
      9. Hack #36. Select Multiple Checkboxes
        1. 4.9.1. The Code
        2. 4.9.2. Running the Hack
      10. Hack #37. Keep Track of Secure Site Passwords
        1. 4.10.1. The Code
        2. 4.10.2. Running the Hack
      11. Hack #38. Automatically Log into Web Mail and Other Sites
        1. 4.11.1. The Code
        2. 4.11.2. Running the Hack
      12. Hack #39. Build Calendar Events
        1. 4.12.1. The Code
        2. 4.12.2. Running the Hack
    10. 5. Developer Tools
      1. 5.1. Hacks 40–46: Introduction
      2. Hack #40. Remove All Page Styles on Selected Sites
        1. 5.2.1. The Code
        2. 5.2.2. Running the Hack
        3. 5.2.3. Hacking the Hack
      3. Hack #41. Refresh Pages Automatically
        1. 5.3.1. The Code
        2. 5.3.2. Running the Hack
      4. Hack #42. Make External Stylesheets Clickable
        1. 5.4.1. The Code
        2. 5.4.2. Running the Hack
        3. 5.4.3. Hacking the Hack
      5. Hack #43. Show Image Information
        1. 5.5.1. The Code
        2. 5.5.2. Running the Hack
      6. Hack #44. Filter Code Examples on MSDN
        1. 5.6.1. The Code
        2. 5.6.2. Running the Hack
      7. Hack #45. Intercept and Modify Form Submissions
        1. 5.7.1. The Code
        2. 5.7.2. Running the Hack
      8. Hack #46. Trace XMLHttpRequest Activity
        1. 5.8.1. The Code
        2. 5.8.2. Running the Hack
    11. 6. Search
      1. 6.1. Hacks 47–59: Introduction
      2. Hack #47. Add a Site Search
        1. 6.2.1. The Code
        2. 6.2.2. Running the Hack
        3. 6.2.3. Hacking the Hack
      3. Hack #48. Remove Spammy Domains from Search Results
        1. 6.3.1. The Code
        2. 6.3.2. Running the Hack
        3. 6.3.3. Hacking the Hack
      4. Hack #49. Find Similar Images
        1. 6.4.1. The Code
        2. 6.4.2. Running the Hack
      5. Hack #50. Search Wikipedia with Google Site Search
        1. 6.5.1. The Code
        2. 6.5.2. Running the Hack
      6. Hack #51. Link to Other Search Engines from Google
        1. 6.6.1. The Code
        2. 6.6.2. Running the Hack
        3. 6.6.3. Hacking the Hack
      7. Hack #52. Prefetch Yahoo! Search Results
        1. 6.7.1. The Code
        2. 6.7.2. Running the Hack
        3. 6.7.3. Hacking the Hack
      8. Hack #53. Browse the Web Through Google's Cache
        1. 6.8.1. The Code
        2. 6.8.2. Running the Hack
      9. Hack #54. Add More Book Reviews to Google Print
        1. 6.9.1. The Code
        2. 6.9.2. Running the Hack
        3. 6.9.3. Hacking the Hack
      10. Hack #55. Autocomplete Search Terms as You Type
        1. 6.10.1. The Code
        2. 6.10.2. Running the Hack
      11. Hack #56. Highlight Search Terms
        1. 6.11.1. The Code
        2. 6.11.2. Running the Hack
        3. 6.11.3. Hacking the Hack
      12. Hack #57. Remember Recent Google Searches
        1. 6.12.1. The Code
        2. 6.12.2. Running the Hack
        3. 6.12.3. Hacking the Hack
      13. Hack #58. Add Keyboard Shortcuts to Google Search Results
        1. 6.13.1. The Code
        2. 6.13.2. Running the Hack
        3. 6.13.3. Hacking the Hack
      14. Hack #59. Use Recent Searches and Google SearchKeys Together
        1. 6.14.1. The Code
        2. 6.14.2. Running the Hack
    12. 7. Web Mail
      1. 7.1. Hacks 60–66: Introduction
      2. Hack #60. Force Gmail to Use a Secure Connection
        1. 7.2.1. The Code
        2. 7.2.2. Running the Hack
        3. 7.2.3. Hacking the Hack
      3. Hack #61. Warn Before Replying to Multiple Recipients in Gmail
        1. 7.3.1. The Code
        2. 7.3.2. Running the Hack
      4. Hack #62. Warn Before Sending Gmail Messages with Missing Attachments
        1. 7.4.1. The Code
        2. 7.4.2. Running the Hack
      5. Hack #63. Compose Your Mail in Gmail
        1. 7.5.1. The Code
        2. 7.5.2. Running the Hack
        3. 7.5.3. Hacking the Hack
      6. Hack #64. Add a Delete Button to Gmail
        1. 7.6.1. The Code
        2. 7.6.2. Running the Hack
      7. Hack #65. Select Your Yahoo! ID from a List
        1. 7.7.1. The Code
        2. 7.7.2. Running the Hack
        3. 7.7.3. Hacking the Hack
      8. Hack #66. Add Saved Searches to Gmail
        1. 7.8.1. The Code
        2. 7.8.2. Running the Hack
    13. 8. Accessibility
      1. 8.1. Hacks 67–76: Introduction
      2. Hack #67. Highlight Images Without Alternate Text
        1. 8.2.1. The Code
        2. 8.2.2. Running the Hack
        3. 8.2.3. Hacking the Hack
      3. Hack #68. Add an Access Bar with Keyboard Shortcuts
        1. 8.3.1. The Code
        2. 8.3.2. Running the Hack
      4. Hack #69. Remove Conflicting Keyboard Shortcuts
        1. 8.4.1. The Code
        2. 8.4.2. Running the Hack
      5. Hack #70. Make Image alt Text Visible
        1. 8.5.1. The Code
        2. 8.5.2. Running the Hack
        3. 8.5.3. Hacking the Hack
      6. Hack #71. Add a Table of Contents to Long Pages
        1. 8.6.1. The Code
        2. 8.6.2. Running the Hack
      7. Hack #72. Use Real Headers on Google Web Search
        1. 8.7.1. The Code
        2. 8.7.2. Running the Hack
      8. Hack #73. Add a Toolbar to Zoom Images Easily
        1. 8.8.1. The Code
        2. 8.8.2. Running the Hack
        3. 8.8.3. Hacking the Hack
      9. Hack #74. Make Apache Directory Listing Prettier
        1. 8.9.1. The Code
        2. 8.9.2. Running the Hack
      10. Hack #75. Add a Text-Sizing Toolbar to Web Forms
        1. 8.10.1. The Code
        2. 8.10.2. Running the Hack
      11. Hack #76. Make Google More Accessible for Low-Vision Users
        1. 8.11.1. The Code
        2. 8.11.2. Running the Hack
    14. 9. Taking Back the Browser
      1. 9.1. Hacks 77–84: Introduction
      2. Hack #77. Reenable Context Menus on Sites That Disable Them
        1. 9.2.1. The Code
        2. 9.2.2. Running the Hack
      3. Hack #78. Bypass Weight Watchers' Browser Checker
        1. 9.3.1. The Code
        2. 9.3.2. Running the Hack
      4. Hack #79. Easily Download Embedded Movies
        1. 9.4.1. The Code
        2. 9.4.2. Running the Hack
      5. Hack #80. Break Out of Frames
        1. 9.5.1. The Code
        2. 9.5.2. Running the Hack
      6. Hack #81. Disable Targets for Downloads
        1. 9.6.1. The Code
        2. 9.6.2. Running the Hack
        3. 9.6.3. Hacking the Hack
      7. Hack #82. Automatically Link to Printer-Friendly Versions
        1. 9.7.1. The Code
        2. 9.7.2. Running the Hack
      8. Hack #83. Restore Functionality in Google Print
        1. 9.8.1. The Code
        2. 9.8.2. Running the Hack
      9. Hack #84. Bypass Annoying Site Registrations
        1. 9.9.1. The Code
        2. 9.9.2. Running the Hack
    15. 10. Syndication
      1. 10.1. Hacks 85–89: Introduction
      2. Hack #85. Automatically Display Unread Items in Bloglines
        1. 10.2.1. The Code
        2. 10.2.2. Running the Hack
      3. Hack #86. Zap Ugly XML Buttons
        1. 10.3.1. The Code
        2. 10.3.2. Running the Hack
        3. 10.3.3. Hacking the Hack
      4. Hack #87. Squeeze More Feeds into the Bloglines Sidebar
        1. 10.4.1. The Code
        2. 10.4.2. Running the Hack
      5. Hack #88. Automatically Collect Syndicated Feeds
        1. 10.5.1. The Code
        2. 10.5.2. Running the Hack
      6. Hack #89. Syndicate Encrypted Content
        1. 10.6.1. The Code
        2. 10.6.2. Running the Hack
    16. 11. Site Integration
      1. 11.1. Hacks 90–94: Introduction
      2. Hack #90. Translate Any Web Page
        1. 11.2.1. The Code
        2. 11.2.2. Running the Hack
      3. Hack #91. Warn Before Buying an Album
        1. 11.3.1. The Code
        2. 11.3.2. Running the Hack
      4. Hack #91. Find Out Who's Reading What You're Reading
        1. 11.4.1. The Code
        2. 11.4.2. Running the Hack
      5. Hack #93. Add Wikipedia Links to Any Web Page
        1. 11.5.1. The Code
        2. 11.5.2. Running the Hack
      6. Hack #94. Compare Book Prices
        1. 11.6.1. The Code
        2. 11.6.2. Running the Hack
    17. 12. Those Not Included in This Classification
      1. 12.1. Hacks 95–100: Introduction
      2. Hack #95. Maximize HomestarRunner Cartoons
        1. 12.2.1. The Code
        2. 12.2.2. Running the Hack
      3. Hack #96. Refine Your Google Search
        1. 12.3.1. The Code
        2. 12.3.2. Running the Hack
      4. Hack #97. Check Whether Pages Really Validate
        1. 12.4.1. The Code
        2. 12.4.2. Running the Hack
      5. Hack #98. Animate Wikipedia History
        1. 12.5.1. The Code
        2. 12.5.2. Running the Hack
      6. Hack #99. Create Greasemonkey Scripts Automatically
        1. 12.6.1. Running the Hack
      7. Hack #100. Remember Everything You Read
        1. 12.7.1. The Code
        2. 12.7.2. Running the Hack
    18. About the Author
    19. Colophon
    20. SPECIAL OFFER: Upgrade this ebook with O’Reilly

Product information

  • Title: Greasemonkey Hacks
  • Author(s): Mark Pilgrim
  • Release date: November 2005
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9780596553579