User:Mr. Stradivarius/gadgets/CommonsUploads.js

From 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.
/* This script adds a toolbox link to a user's Commons uploads when on a page
 * relevant to them, e.g. their user page or user talk page. To use it, add

importScript('User:Mr. Stradivarius/gadgets/CommonsUploads.js'); // Linkback: [[User:Mr. Stradivarius/gadgets/CommonsUploads.js]]

 * to your common.js page.
 */

mw.loader.using( [ 'mediawiki.util' ], function () {
	"use strict";

	var username = mw.config.get( 'wgRelevantUserName' );
	if ( !username ) {
		return;
	}

	mw.util.addPortletLink(
		'p-tb',
		'https://commons.wikimedia.org/wiki/Special:ListFiles/' + mw.util.wikiUrlencode( username ),
		'Commons uploads',
		't-cuploads',
		'Files this user has uploaded on Commons',
		null,
		'#t-emailuser'
	);
} );