User:The Voidwalker/centralAuthLink.js

Source: Wikipedia, the free encyclopedia.
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.
/*
 * Creates a link to the Central Auth of any user in the tools part of the sidebar from anywhere in their userspace or from their contributions page.
 * Import using:
 importScript('User:The Voidwalker/centralAuthLink.js');
 * in your common.js
 */
mw.loader.using(['mediawiki.util']).done(function(){
	var user = mw.config.get( 'wgRelevantUserName' );
	if( user !== null && !mw.util.isIPAddress(user) ){
		mw.util.addPortletLink(
			'p-tb',
			mw.util.getUrl('m:Special:CentralAuth/' + user),
			'Central Auth',
			't-centralauth',
			'View global account information'
		);
	}
});