User:Polygnotus/Scripts/ToolsLink.js

This is the current revision of this page, as edited by Polygnotus (talk | contribs) at 14:05, 9 July 2025. The present address (URL) is a permanent link to this version.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
//This script shows how to add a link to the Tools menu

mw.hook('wikipage.content').add(function() {
    mw.loader.using(['mediawiki.util'], function() {
        
        // Only add the link if it doesn't already exist
        if (!document.getElementById('t-mycustomtool2')) {	//linkid
            mw.util.addPortletLink(
                'p-tb',										//Target portlet ID (Tools menu)
                'https://tools.wmflabs.org/',				//linkurl
                'Wikimedia Tools',							//linktext
                't-mycustomtool2',							//linkid
                'Access Wikimedia developer tools'			//tooltip
            );
        }
    });
});