:rocket: A guided tour that helps users learn about userscripts and how they are created using ResourceLoader, MediaWiki Action API, and OOUI.
Student | Devyansh Chawla |
---|---|
Organisation | Wikimedia Foundation |
Project | Develop a Userscript/Gadget tutorial on mediaWiki.org |
Userscripts are the JavaScript programs that provide Wikimedia users the ability to customize and change the behavior of their user accounts. This project is a guided adventure tour on mediawiki.org
to give users insight on How to create a userscript on Wikimedia projects?
The Userscript Tour facilitates users to learn about userscripts and how they are created using ResourceLoader, MediaWiki Action API, and Object-Oriented User Interface, consistently. The workflow is carried out using four missions:
Mission 1 (Let’s begin the journey)
The users will gain practical knowledge of what userscripts/gadgets are and how the existing userscripts are loaded in common.js. They will be made to write a basic yet interesting userscript and import it into their common.js page.
Userscripts involved:
Invert.js: Adds an Invert link to the top toolbar. It allows inverting the page color and the color of images.
zoom.js: Adds two buttons (to zoom-in and zoom-out) on the right of the page heading.
Mission 2 (Developing with ResourceLoader)
In this mission, the users will gain practical knowledge of ResourceLoader and the core modules available.
Userscripts involved:
toggleFontColor.js: Adds a link to the p-personal portlet area, which when clicked toggles the font color of the content. It is created to depict the use of mediawiki.util module.
userEditCount.js: Shows the count of edits made by the logged-in user on the current wiki beside the username.
Mission 3 (Strengths of the Action API)
In this mission, the users will gain practical knowledge of MediaWiki Action API, endpoints, modules, submodules, parameters, and API Sandbox.
Userscripts involved:
basicPageInfo.js: Shows the basic information about the current page (number of bytes/characters) at the top of the content area. This userscript is written to help users get started with making API calls to the Wikimedia servers.
quickChangeLog.js: Adds a link to the Toolbox portlet area, that when clicked shows the 25 most recent changes on MediaWiki in the form of a jQuery dialog box.
Mission 4 (Novelty of OOUI)
In the final mission, the users will gain practical knowledge of Object-Oriented User Interface (OOUI), OOUI elements, widgets, dialogs, custom user interface, etc.
Userscripts involved:
showAlertBox.js: Appends an OOUI button to the portlet area that when clicked, shows an OOUI Message Dialog (a simple alert box).
guessRandomNumber.js: One of the cool userscripts which makes use of custom widgets. It prepends a tiny random game at the top of the wiki page. The OOUI widgets used are: MessageWidget, LabelWidget, TextInputWidget, ButtonWidget and Simple Message Dialog Box.
NOTE: The missions are constructed such that each one of them builds on the concepts introduced in the preceding missions.
Other highlights
Code Example: Create a guider
tour.step( {
name: '3',
title: 'Put title here',
description: 'Put description here',
onShow: gt.parseDescription,
overlay: true,
closeOnClickOutside: false,
buttons: [ {
name: 'Button 1',
action: 'externalLink',
url: mw.util.getUrl( 'TUT/1/Start' ) + '?tour=tut1&step=2'
}, {
name: 'Button 2',
action: 'next',
} ],
allowAutomaticOkay: false
} )
.next( '4' );
Benefit of The Userscript Tour
The project primarily focuses on newbie developers and existing Wikimedia community members who have a little bit of JavaScript knowledge. If someone does outreach then every participant would go in the same flow.
Prerequisites:
I used the MediaWiki-Docker for setting up my development environment.
$wgAllowUserJs = true;
to the LocalSettings.php file.Templates
directory and the wiki pages present in respective directories - mission-1
, mission-2
, mission-3
, and mission-4
.-
(hyphen) delimiter with /
(slash). For example, the template TUT-Background-1 should be named TUT/Background/1 on your local installation of MediaWiki.userscripts
directory of the respective missions./The_Userscript_Tour
on your MediaWiki.LIMITATIONS:
Feel free to open an issue if you find any bug.
Feel free to open an issue to request any additional features you might need for your use case.
Distributed under the GPL-3.0 License. See LICENSE
for more information.
All of my blog posts related to the project can be found here.
This project is created as part of Google Summer of Code 2021 with my mentoring organization being Wikimedia Foundation. Once deployed on mediawiki.org, I’ll update the deployed link in the repository.