Wikipedia:Wikipedia Signpost/2008-03-17/Tutorial

This week's tutorial explains how to install user scripts that increase the functionality of the encyclopedia's interface. Such tools range from rather simple scripts - for example, that replace some text with other text - to complicated behemoths that do everything from fighting vandalism to closing AFCs.

Basics
If you are using the Monobook skin (for more on skins, see WP:SKIN), your scripts page would be at this location. In general, if you use skin X, your scripts page would be at User:(your username)/X.js.

Once you have navigated to the page, you should see the following box:

'''If a message on your talk page led you here, please be wary of who left it. The code below could contain malicious content capable of compromising your account; if your account appears to be compromised, it will be blocked. If you are unsure whether the code is safe, you can ask at the appropriate village pump.'''

This means that unknowingly putting malicious scripts on your scripts page may lead to your account being compromised. One must always be careful when installing scripts.

To install a script, simply edit the page and copy-and-paste the desired script in (or, if you are familiar with Javascript and you know how to use Wikipedia's DOM, type your own). Save the page as your normally would. Generally, you will have to bypass your cache (ctrl + f5 on Firefox and Internet Explorer, simply f5 on Konqueror and command + R on Safari to see the effects of the script.

What can scripts do?
A better question would be, "What can't scripts do?" Scripts, as mentioned briefly above, can change Wikipedia's interface in drastic ways, as well as providing semi-automated ways to edit. The latter is particularly useful for vandalism fighting, though it has many diverse applications.

Some of the most well-known scripts are:
 * Twinkle, a script which gives added functionality in fighting vandalism
 * Pop-ups, which allow previews of articles when hovering over links as well as tools to deal with these articles
 * Lupin's anti-vandal tool, which provides a recent changes filter, a recent IP edits list, and other functionality.
 * Dr pda's page size tool, which adds a Page size link to the toolbox, to display  some statistics about the page and prose size.

Which tools should you install? Consider first which tools you will actually have much use for. If you spend your time voting in XfDs, vandalism reversion scripts may not be useful for you, and vice versa.

Finding scripts
WikiProject User scripts, a WikiProject devoted to scripts, maintains a list of user scripts. One can also request a script be made.

If you wish to use the same scripts as another user, there are two methods. One is to simply substitute their script page onto your own. The second is to use the importScript command, which works as follows:

importScript('OTHER USER'S SCRIPT PAGE');

A more recent feature is the "Gadgets" tab in your preferences page. If you want to use a gadget (user script or CSS modification) that is listed, you simply check a box and save your change. The list includes some of the more well-known scripts. (If you want to customize a script, you'll need to install the scripts manually.)

Other resources

 * Guide on writing user scripts from the WikiProject.
 * Ajax guide, also from the WikiProject.
 * "Piles of code"; guess where it's from.
 * The "User scripts" section of the Editor's index to Wikipedia