CustomTools

CustomTools gives a method to add a button (or link) to different areas of the interface. It currently supports the following areas:
* Activity tabs (activity-tabs). The tabber at the top of Special:RecentChanges, Special:SocialActivity, Special:NewFiles and Special:Reports.
* Explore (explore). The "Explore" dropdown in the local wiki's navigation (both static and sticky).
* Global navigation (global-navigation). As a circle icon-button in the global navigation, in the same area and with the same style as the icons in there (Games, Anime, Movies, TV, Video, Wikis and Start a wiki).
* Global navigation dropdown (global-navigation-dropdown). The dropdown menu that shows up when you hover over your avatar.
* My tools (my-tools). The dropdown menu in your toolbar. If the menu doesn't exist, it will be added to the toolbar instead.
* Page actions (page-actions). Buttons next to the "" button.
* Page actions dropdown (page-actions-dropdown). Links in the dropdown list that shows next to the "" button.
* Page tools (left) (page-tools-left). Icons that float in the left side of an article, where you have a button to expand the article container and an edit button with a pencil as an icon.
* Page tools (right) (page-tools-right). The module on the right of the article that includes several links, like Special:WhatLinksHere.
* Toolbar (toolbar). Your toolbar.
* User links (user-links). The tabber in user-related pages (User:Example, User talk:Example, User blog:Example, Special:Contributions/Example).
* User stats (user-stats). The links under an user's name and tags in their profile masthead, where you already find their number of edits and posts.
* Wiki tools (wiki-tools). The icons in the right side of the local navigation, where you normally find the following buttons: Search, Discuss, Recent Changes, Change theme and a dropdown menu.
* Wiki tools dropdown (wiki-tools-dropdown). The dropdown mentioned in the previous point.
: Note: Although you can use this script site-wide to add buttons and links to certain areas, some areas are only allowed for personal use (like adding buttons to the global navigation).
== ==
== API ==
Custom tools are set up through an object with the following properties:
Property name	Description 	Type 	Required? 	Notes
classes 	The classes to add to the button or link. 	String or an array of strings	No 	
click 	A function to be called when you click the button. 	Function 	No 	
icon 	The name of an icon from WDSIcons. See also Fandom Design System. 	String 	Depending on the area.	Never specify a size, only the icon's name. For example, use clock; never use clock-small.
link 	If you want it to link somewhere, set the URL in this property. 	String 	No 	If your URL starts with http://, https:// or //, it will be used as the URL. https://google.com will lead to that URL.
If your URL starts with /, it will be added after the wiki's base URL, keeping the language if any. In w:c:community, /f will set the link to https://community.fandom.com/f; in w:c:es.genshin-impact, /f will set the link to https://genshin-impact.fandom.com/es/f.
Otherwise, it will be used as a local link. Special:RecentChanges will lead to Special:RecentChanges. The value isn't escaped, so Page?action=edit will forward you to editing that page.
placement 	Where to add the button. The valid values are in the bullet list at the beginning of this page. 	String 	Yes 	Other values are ignored.
position 	Where to add the button in the container. By default, it is added at the beginning. Negative numbers count from the end, similar to Array.at. 	Number 	No 	0 will add it at the beginning; 1 after the first item already there (if any); -1 at the end; -2 before the last item already there; and so on.
text 	What text to display. 	String 	No 	It varies depending on the location: it may be used as a button label, a tooltip or in the title attribute.
It behavior is altered by the i18n and system properties.
i18n 	If your script supports multiple languages using I18n-js, specify its name (e.g. CustomTools) so translations are fetched from the corresponding i18n JSON page.
The value of text will be used as the key.	String 	No 	
system 	If you want to use MediaWiki's system messages, set this property as true and the text value will be used to fetch instead that system message.	Boolean 	No 	system: true and text: 'group-sysop' will display in the text field the value of that system message ("Administrators" in English, "Administradores" in Spanish, and so on).
* If the area requires an icon and you don't specify one, it will use error by default.
* You don't need to import WDSIcons or I18n-js to use both icons and i18n features, since they are already imported by the script.
=== Scripts ===
The script fires a hook dev.ct that makes available for you a function to setup any buttons and links you may want to add.
The function expects either an array or a single object with the interface described at the beginning of API.
: Example: Add a single button in the page-tools-left area, at the end.
: Example: This adds a button at the end of the page-tools-left area, and another one in the explore menu.
=== Personal use ===
You can use the hook described in scripts, or set a global window.CustomTools object or array of objects with the same structure that you would use as the function's parameter.
Use this method only for personal scripts, never for scripts to be imported from dev or in your wiki's JS, since it might mess up with other user's personal custom tools.
=== User options ===
For advanced users, you can also set the configuration object through your user options:
It will be parsed and used for setup if it exists.