WP:US redirects here. For the parent WikiProject, see Wikipedia:WikiProject JavaScript. For the United States project, see Wikipedia:WikiProject United States. For USA abbreviation guidance, see Wikipedia:Manual of Style § US.

User scripts are programs written in JavaScript, for use on Wikipedia by users. User scripts enable your user account to do many things that they otherwise couldn't. Many user scripts are available ready for you to install. Users may also write new user scripts, starting with an existing user script and modifying it, or staring from scratch.

JavaScript is the programming language used to write user scripts. For an overview of Wikipedia's coverage about JavaScript in the form of a structured topic list, see Draft:Outline of JavaScript.

Wikipedia:WikiProject JavaScript is the collaboration of editors working on improving JavaScript coverage, user script-related pages (like the one you are reading right now), and supporting user script development.

List of user scripts

If you come across or write a user script, please make sure it is added to Wikipedia:User scripts/List.

Don't see what you need? You can make a request for a new user script at Wikipedia:User scripts/Requests.

Using scripts: Frequently asked questions

Where can I find user scripts?

Try these pages:

How to install user scripts?

Simple method for scripts which are located on English Wikipedia.
  1. First, make sure you are registered and logged in. Only logged-in users can install scripts.
  2. Click here to edit your common.js file.
  3. Add the following line: {{subst:iusc|script_path}} -- replace "script_path" with the full name of the .js page that opens when a script's "(source)" link is clicked.
    • For example, to install the Sharebox script, add the following line: {{subst:iusc|User:TheDJ/sharebox.js}}
  4. Save the page and bypass your cache to make sure the changes take effect.

Automatic installer

Script Installer makes script installations fully automatic. The installer itself must first be installed manually. Afterwards, most of scripts can be installed with a single click.

Full manual instructions

  1. First, make sure you are registered and logged in. Only logged-in users can install scripts.
  2. Edit your common.js file. Alternatively, you may use your skin.js to work only your current skin.
  3. Add the following line: importScript('script_path'); -- where "script_path" is the full name of the .js page that opens when a script's "(source)" link is clicked.
    • For example, to install the Sharebox script, add the following line: importScript('User:TheDJ/sharebox.js');
    • For scripts not located on this wiki, use:
      mw.loader.load('//en.wikipedia.org/w/index.php?title=script.js&action=raw&ctype=text/javascript');
    • Consider adding a backlink by adding //[[script_path]] to the end of the line, which aids script usage statistics.
  4. Save the page and bypass your cache to make sure the changes take effect.

How to add new scripts to the scripts list

Use {{userscript}}. Include at least a code page address. Add a short description after the userscript template. For example:

*{{userscript | name= My script | code= User:Me/MyJSpage.js | doc= User:Me/MyJSdocumentationPage }} - This script does something useful.
  • Name defaults to the code page's name, without its path or ".js".
  • If a documentation page exists matching your .js page name, it will be linked automatically, without the need for a doc parameter.

Writing user scripts

Instructions for writing your own user scripts are included in Wikipedia:User scripts/Guide.

Additional script-writing resources are presented below.

Libraries

These functions can be included directly in a script but don't do anything unless called by some other code. The functions marked as deprecated have been rendered obsolete by new features added to MediaWiki, and only exist now as wrappers for compatibility with existing code.

(Template)

Documentation Summary
Add LI menu Allow "tabs" to be placed in drop-down menus (can be nested). Requires some CSS customisations
warn.js Gives a prompt to add any template (supposed to be used for warning vandals)
Get user name Gets the username corresponding to the current page
MD5 2.2-alpha Calculates the RSA Data Security, Inc. MD5 Message Digest of a string. Supports UTF-8
gui.htmlEdit A WYSIWYG HTML editing control. See documentation
edit.multiReplace Class to simplify the replacement of several different regular expressions, each with its own substitution. See documentation
morebits.js A collection of wiki-related functions (such as editing via the API and displaying Twinkle-style windows), maintained as part of Twinkle (but usable separately)
addToolbarButtons Add function-calling toolbar buttons. Both the classic and the WikiEditor toolbars are supported (but not the Visual Editor's toolbar).
Value/Selection Lets you determine the position of the cursor/selection within a text input or textarea box and change the text around it

Snippets

The following code snippets still exist under the now defunct WikiProject User scripts. Many are still in use by live scripts, and they may provide insights for current script developers.

Stylesheets

CSS code in this section is added slightly differently to JavaScript code. The code can be imported by adding {{subst:css|Page_name}} to your monobook.js, or the code can be @imported into your monobook.css. You can just paste the source code if you do not wish to receive updates to the code when it is improved.

Name and link Purpose Compatible skins
externals Replaces the external link icon with the corresponding favicon (works for some links) Chick, Monobook, Myskin, and Simple
VectorButtons Give those boring gray standard buttons a Vector-like appearance All
accesskey Display corresponding access keys besides links.
RetroLogo Replace the top-left Wikipedia logo.

Userbox

Want to advertise your user script development skills? Use {{user script developer}} userbox:

Wiki-tech-logo.svg This user develops
user scripts;