|
Free Open Book
Sams Teach Yourself JavaScript in 24 Hours |
Working with User ScriptsUser scripts are a whole new way of working with JavaScriptrather than uploading them for use on your website, you install them in the browser for your own personal use. The following sections show you how to find useful scripts, and install and manage them. Finding ScriptsAnyone can write user scripts, and many people have. Greasemonkey sponsors a directory of user scripts at http://userscripts.org/. There you can browse or search for scripts, or submit scripts you've written. The script archive has thousands of scripts available. Along with general-purpose scripts, many of the scripts are designed to add features toor remove annoying features fromparticular sites. Installing a ScriptAfter you've found a script you wish to install, you can install it from the Web:
You can also install a script from a local file. You'll use this technique to install your own script later this hour. Managing ScriptsAfter you've installed one or more scripts with Greasemonkey, you can manage them by selecting Tools, Manage User Scripts from the Firefox menu. The Manage User Scripts dialog is shown in Figure 18.2. Figure 18.2. Managing user scripts in Greasemonkey.
The user scripts you have available are listed in the left column. Click on a script name to manage it:
Turnabout for IE has a similar dialog. To access it, click the Reify button in the Turnabout toolbar and select Options. The dialog is similar to Greasemonkey's dialog, except that each script has a separate check box to enable or disable it. There is also an Install Feature button that prompts you for a new script to install. The Turnabout Options dialog is shown in Figure 18.3. Figure 18.3. The Turnabout Options dialog.
Testing User ScriptsIf you have a script enabled, it will be activated as soon as you load a page that matches one of the Included Pages specified for the script. (The script is run after the page is loaded, but before the onLoad event.) If you want to make sure Greasemonkey is running, either try one of the scripts available for download, or type in the simple script in the next section. Activating and Deactivating Greasemonkey or TurnaboutSometimes you'll want to turn off Greasemonkey altogether, especially if one of the scripts you've installed is causing an error. To do this, right-click on the monkey icon in the lower-right corner of the browser window and select the Enabled option to deselect it. The monkey icon changes to a gray sad-faced monkey, and no user scripts will be run at all. You can re-enable it at any time using the same option. With Turnabout for Internet Explorer, the procedure is similar: Click the Reify button in the Turnabout toolbar, and select the Enable Turnabout option. The icon changes to indicate that Turnabout is disabled. Choose Enable Turnabout again to re-enable it. |
Main Menu |
| 500 Juegos Gratis | 500 Giochi Gratis | 500 Jeux Gratuits | 500 Jogos Gratis | 500 Kostenlose Spiele |