Help:User scripts/szl

This page is a translated version of the page Help:User scripts and the translation is 5% complete.

User scripts are short JavaScript computer programs that add extra functionality to the Wikidata user interface for an individual, logged-in, user.

Scripts can be stored on any JavaScript file wiki page (the page name ends in .js).

Each user has a special page called their common.js where they list the scripts they wish to use (for example, User:Pigsonthewing/common.js). It can be accessed via Special:Mypage/common.js, which will redirect you to your own common.js page.

You can find scripts to add that were created by the community here.

Adding a user script to your Wikidata profile

The easiest way to add user scripts to your profile is to first add the ScriptInstaller user script. This script allows you to install user scripts with the click of a button from the page of the user script. To add this script, or any other script without using ScriptInstaller, follow the instructions below.

Once you have logged in, edit your common.js, and add a line like:

mw.loader.load( '//www.wikidata.org/w/index.php?title=script_path&action=raw&ctype=text/javascript' );

where script_path is the title for the page containing the user script. Be sure to replace any spaces with underscores.

For example, in order to add the user script User:So9q/ScriptInstaller.js, you add:

mw.loader.load( '//www.wikidata.org/w/index.php?title=User:So9q/ScriptInstaller.js&action=raw&ctype=text/javascript' );

Creating a user script

To create a userscript, create a wiki page whose name ends in .js. It is recommend that you create your userscript as a subpage of your userspace. You can easily do this below:

Wikidata user scripts often utilize:

For example, an element can be added to the page using JQuery after a statement has been saved (the wikibase.statement.saved hook is fired). It is a good idea to look at others' scripts to see how this is done.

Zobŏcz tyż

For more advice on adding user scripts, see en:Wikipedia:User scripts, but remember to add Wikidata user scripts to your Wikidata user-space, not the one on Wikipedia!