Dive Into Greasemonkey Table of Contents Dive Into Greasemonkey
Total Page:16
File Type:pdf, Size:1020Kb
Dive Into Greasemonkey Table of Contents Dive Into Greasemonkey.................................................................................................................................................1 Chapter 1. Getting Started..............................................................................................................................................2 1.1. What is Greasemonkey?................................................................................................................................2 1.2. Installing Greasemonkey...............................................................................................................................3 1.3. Installing a user script....................................................................................................................................4 1.4. Managing your user scripts............................................................................................................................5 Chapter 2. Your First User Script..................................................................................................................................7 2.1. Hello World...................................................................................................................................................7 2.2. Describing your user script with metadata.....................................................................................................8 2.3. Coding your user script................................................................................................................................10 2.4. Editing your user script................................................................................................................................12 Chapter 3. Debugging User Scripts..............................................................................................................................13 3.1. Tracking crashes with JavaScript Console..................................................................................................13 3.2. Logging with GM_log.................................................................................................................................14 3.3. Inspecting elements with DOM Inspector...................................................................................................15 3.4. Evaluating expressions with Javascript Shell..............................................................................................17 3.5. Other debugging tools..................................................................................................................................19 Chapter 4. Common Patterns.......................................................................................................................................20 4.1. Executing a user script on a domain and all its subdomains........................................................................20 4.2. Testing whether a Greasemonkey function is available..............................................................................21 4.3. Testing whether a page includes an HTML element...................................................................................22 4.4. Doing something for every HTML element................................................................................................23 4.5. Doing something for every instance of a specific HTML element..............................................................24 4.6. Doing something for every element with a certain attribute........................................................................25 4.7. Inserting content before an element.............................................................................................................28 4.8. Inserting content after an element................................................................................................................29 4.9. Removing an element..................................................................................................................................30 4.10. Replacing an element with new content....................................................................................................31 4.11. Inserting complex HTML quickly.............................................................................................................32 4.12. Adding images without hitting a central server.........................................................................................33 4.13. Adding CSS styles.....................................................................................................................................34 4.14. Getting an element's style..........................................................................................................................35 4.15. Setting an element's style...........................................................................................................................36 4.16. Post−processing a page after it renders......................................................................................................37 4.17. Matching case−insensitive attribute values...............................................................................................38 4.18. Getting the current domain name...............................................................................................................39 4.19. Rewriting links...........................................................................................................................................40 4.20. Redirecting pages.......................................................................................................................................41 4.21. Intercepting user clicks..............................................................................................................................42 4.22. Overriding a built−in Javascript method....................................................................................................43 4.23. Parsing XML..............................................................................................................................................44 Chapter 5. Case Studies.................................................................................................................................................46 5.1. Case study: GMail Secure............................................................................................................................46 5.2. Case study: Bloglines Autoload...................................................................................................................47 5.3. Case study: Ain't It Readable.......................................................................................................................48 Dive Into Greasemonkey i Table of Contents Chapter 5. Case Studies 5.4. Case study: Offsite Blank............................................................................................................................50 5.5. Case study: Dumb Quotes............................................................................................................................52 5.6. Case study: Frownies...................................................................................................................................55 5.7. Case study: Zoom Textarea.........................................................................................................................58 5.8. Case study: Access Bar................................................................................................................................64 Chapter 6. Advanced Topics.........................................................................................................................................70 6.1. Storing and retrieving persistent data..........................................................................................................70 6.2. Adding items to the menubar.......................................................................................................................71 6.3. Integrating data from other sites..................................................................................................................72 6.4. Compiling your user script into an extension..............................................................................................73 Greasemonkey API Reference......................................................................................................................................75 Name...................................................................................................................................................................75 Synopsis..............................................................................................................................................................75 Description..........................................................................................................................................................75 History.................................................................................................................................................................75 Name...................................................................................................................................................................75 Synopsis..............................................................................................................................................................75