Jump to content

User:Anna Frodesiak/deletedcontribs.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 adds a "Deleted contributions" link to the Tools menu.
 * It only works for admins, and only in the user or user talk namespaces.
 * To install it, add the following code to your common.js:

importScript('User:Anna Frodesiak/deletedcontribs.js'); // Linkback: [[User:Anna Frodesiak/deletedcontribs.js]]

 */

$( document ).ready( function() {
	var username;
	var config = mw.config.get( [ 'wgUserGroups', 'wgNamespaceNumber', 'wgTitle' ] );
	if (
			config.wgUserGroups.toString().indexOf( 'sysop' ) !== -1 && // Restrict to admins
			( config.wgNamespaceNumber === 2 || config.wgNamespaceNumber === 3 )
	) {
		username = config.wgTitle.split( '/' )[ 0 ];
		mw.util.addPortletLink(
			'p-tb',
			mw.util.getUrl( 'Special:DeletedContributions/' + username ),
			'Deleted contributions',
			't-deleted',
			'Deleted contributions of this user',
			null,
			'#t-log'
		);
	}
} );