Tool created by Ahecht. Source available at source.php or on GitHub.
The RandomInCategory tool is a replacement for Special:RandomInCategory that actually chooses a page randomly. Includes options for filtering results by namespace and type. To use on a wiki, replace
Multiple categories can be specified by adding the
category3=, etc. parameters to the url, e.g.
By default, the script assumes the category is from en.wikipedia.org. This can be overridden by adding the
server= parameters to the url, e.g.
&server=commons.wikimedia.org. Do not include "https://" in the site name. The server must at one of the following Wikimedia-owned domains:
Results can be filtered by namespace and type by adding the
type= parameters to the url, e.g.
&namespace=2|118&type=page. These parameters are documented as
cmtype at https://www.mediawiki.org/wiki/API:Categorymembers, but the "|" between namespaces can optionally be replaced with a ";" or "!" for compatibility with wikilinks.
For performance reasons, the list of items is cached for 10 minutes. To manually refresh the cache, set the
purge= parameter to any value.
returntype= parameter to
subject to return the associated subject page if the randomly chosen page is a talk page. Similarly,
returntype=talk will return the associated talk page if the randomly chosen page is a subject page. If the associated page does not exist, the original randomly chosen page will be returned.
The script will return the URL of the article and other debugging data instead of actually performing the redirect if the
debug= parameter is set to any value.
Any other parameters in the URL will be passed on to the target page.
The MIT License
Copyright © 2020-2022 Ahecht
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.