Welcome to the gadget kitchen. This is intended to become a space where developers far and wide can coordinate their work on user scripts and gadgets to the benefit of the MediaWiki community far and wide. Right now, it's a quick tutorial to get you started.
What are user scripts and gadgets?[edit | edit source]
One of MediaWiki's coolest features is that it enables anyone to immediately write enhancements to the software, and to share those enhancements with other users.
- Gadgets are user scripts which have been promoted to become available in the user preferences of all users.
If you're running your own copy of MediaWiki, $wgAllowUserJs needs to be enabled for user scripts to work, and the Gadgets extension needs to be installed to make it possible to promote individual scripts to gadget status. Both are enabled for all Wikimedia Foundation sites, including Wikipedia.
I want to try![edit | edit source]
- Ensure you are logged in, then visit Special:MyPage/common.js.
- Create this page with the following text:
- Save. You should now have a link in the toolbox section called "Quick changelog" which shows you a subset of recent changes in a quick pop-up.
I want to do more![edit | edit source]
- For a nicer (experimental!) development experience, go to your gadget preferences and enable the "Code Editor" gadget
- Now, copy and paste the contents of MediaWiki:Tutorial-QuickRC.js into your Special:MyPage/common.js.
The result should be the same as above, but now you can modify the script, play with it, and replace it with something else entirely.
Note: Clicking "Preview" (or using the keyboard shortcut, typically
Shift+Alt+P) in the editor will also execute the latest version of the script. This is a good way to iterate without saving the page. But remember, nothing is saved until you press "Save page".
Are there additional tutorial scripts?[edit | edit source]
Please contribute additional tutorial scripts in this section:
- MediaWiki:Tutorial-QuickRC.js - mw.loader, mw.util, mw.html, API usage, jQuery UI dialog, mw.user, jQuery AJAX, jQuery event binding
What's this ResourceLoader thing?[edit | edit source]
- Developing with ResourceLoader — A list of useful practices, like enabling the debug mode.
Note: The upcoming version of ResourceLoader comes with a lot of features related to gadgets, that will make managing gadgets even simpler.
What should I work on?[edit | edit source]
- If you want to write features that directly help Wikimedia project contributors, there are some pages that are used to coordinate requests. On the English Wikipedia, there is Wikipedia:WikiProject User scripts/Requests.
- We're also collecting requests here: Gadget Kitchen/Requests
How do I use my script on other wikis?[edit | edit source]
Let's say you want to run the script on English Wikipedia instead of MediaWiki.org. Visit your common.js there and add the following:
Of course, you could also load the user script you just created using the same mechanism by changing
MediaWiki:Tutorial-QuickRC.js in the URI above to
User:YourName/YourScript.js. Ta-da! It's really that easy to customize your site experience on one of the largest sites on the planet.
Note: If your gadget uses the MediaWiki API, add the "
?callback=?" parameter to the API URL if you are trying to make an API request that would violate the same-origin policy (e.g. making a request to the Commons API from Wikipedia). This triggers the use of JSONP and enforces certain restrictions.
Got any tips for writing or debugging JS?[edit | edit source]
- Read the Google Chrome developer tools documentation or Firebug documentation for getting the most out of the powerful debugging tools built into your browser.
- If you're experiencing issues with cached versions of scripts, it can be helpful to disable all caching. This can be accomplished by clicking the settings (gears) icon in the Chrome developer console and selecting "Disable cache", or "Disable Browser Cache" in the Net panel in Firebug.
Where can I find more docs?[edit | edit source]
These are key resources:
- WikiProject User Scripts on the English Wikipedia and its alternatives in other languages are the primary hubs for user script and gadget development in Wikipedia. The guide has tons of useful information to get you started.
- the MediaWiki web service API documentation will also be very useful
- Wikipedia:Gadget page on English Wikipedia
- A written resource as backup for in-person training sessions