greasemonkey

Greasemonkey Hacks/Getting Started

< Greasemonkey Hacks

Greasemonkey Hacks

Foreword

Credits

Preface

Chapter 1: Getting Started

Chapter 2: Linkmania!

Chapter 3: Beautifying the Web

Chapter 4: Web Forms

Chapter 5: Developer Tools

Chapter 6: Search

Chapter 7: Web Mail

Chapter 8: Accessibility

Chapter 9: Taking Back the Browser

Chapter 10: Syndication

Chapter 11: Site Integration

Chapter 12: Those Not Included in This Classification

Colophon

 

Contents [hide]

1 Hacks 1–12: Introduction

2 Install a User Script

2.1 Installing from the Context Menu

2.2 Installing from the Tools Menu

2.3 Editing Greasemonkey's Configuration Files

3 Provide a Default Configuration

3.1 The Code

3.2 Wrapper

3.3 Name

3.4 Namespace

3.5 Description

3.6 URL Directives

4 Master the @include and @exclude Directives

4.1 Matching with or Without the www. Prefix

4.2 Matching All Subdomains of a Site

4.3 Matching Different Top-Level Domains of a Site

4.4 Deciding Between * and http://*

5 Prevent a User Script from Executing

5.1 Disabling a User Script Without Uninstalling It

5.2 Disabling All User Scripts

5.3 Disabling a User Script by Removing All Included Pages

5.4 Disabling a User Script by Excluding All Pages

5.5 Disabling a User Script by Editing config.xml

5.6 Uninstalling a User Script

6 Configure a User Script

6.1 Inline

6.2 During Installation

6.3 After Installation

6.4 Editing Configuration Files

7 Add or Remove Content on a Page

7.1 Adding an Element

7.2 Removing an Element

7.3 Inserting an Element

7.4 Replacing an Element

7.5 Modifying an Element's Attributes

8 Alter a Page's Style

8.1 Adding a Global Style

8.2 Inserting or Removing a Single Style

8.3 Modifying an Element's Style

9 Master XPath Expressions

9.1 Basic Syntax

9.2 Examples

10 Develop a User Script "Live"

10.1 Setting Up File Associations

10.1.1 On Mac OS X.

10.1.2 On Windows.

10.2 The "Live Editing" Development Cycle

11 Debug a User Script

11.1 Check Error Messages

11.2 Log Errors

11.3 Find Page Elements

11.4 Test JavaScript Code Interactively

12 Embed Graphics in a User Script

12.1 The Code

12.2 Running the Hack

13 Avoid Common Pitfalls

13.1 Security Hole #1: Source Code Leakage

13.2 Security Hole #2: API Leakage

13.3 Security Hole #3: Local File Access

13.4 Redesigning from the Ground Up

13.5 Going Deeper

13.6 Pitfall #1: Auto-eval Strings

13.7 Pitfall #2: Event Handlers

13.8 Pitfall #3: Named Forms and Form Elements

13.9 Pitfall #4: Custom Properties

13.10 Pitfall #5: Iterating Collections

13.11 Pitfall #6: scrollIntoView

13.12 Pitfall #7: location

13.13 Pitfall #8: Calling Remote Page Scripts

13.14 Pitfall #9: watch

13.15 Pitfall #10: style

13.16 Conclusion

Hacks 1–12: Introduction

 

The first thing you need to do to get started with Greasemonkey is install it. Open Firefox and go to http://greasemonkey.mozdev.org. Click the Install Greasemonkey link. Firefox will warn you that it prevented this site from installing software, as shown in Figure 1-1.

Figure 1-1. Firefox, requiring you to whitelist sites to install extensions

 

Click the Edit Options button to bring up the Allowed Sites dialog, as shown in Figure 1-2.

Figure 1-2. Allowed Sites dialog

 

Click the Allow button to add the Greasemonkey site to your list of allowed sites; then click OK to dismiss the dialog. Now, click the Install Greasemonkey link again, and Firefox will pop up the Software Installation dialog, as shown in Figure 1-3.

Figure 1-3. Software Installation dialog

 

Click Install Now to begin the installation process. After it downloads, quit Firefox and relaunch it to finish installing Greasemonkey.

Now that that's out of the way, let's get right to it.

Install a User Script

 

Greasemonkey won't do anything until you start installing user scripts to customize specific web pages.

A Greasemonkey user script is a single file, written in JavaScript, that customizes one or more web pages. So, before Greasemonkey can start working for you, you need to install a user script.

Tip

Many user scripts are available at the Greasemo

posted @ 2015-01-13 13:55  aprial  阅读(526)  评论(0编辑  收藏  举报