User:Guycn2/GlobalRightsLink.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
/*
Adds some useful links to [[Special:UserRights]]:
* Meta user rights log (for documentation of changes to local
high-level permissions, such as CheckUser and Oversight).
* Global user rights log (for documentation of changes to
global permissions, such as Global Rollbacker).
* Global account info (for viewing all wikis the account is
attached to, as well as documentation of global (un)locks).
Written by: [[User:Guycn2]]
*/
( () => {
'use strict';
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) !== 'Userrights' ) {
return;
}
const username = mw.config.get( 'wgRelevantUserName' );
if ( !username ) {
return;
}
let messages;
switch ( mw.config.get( 'wgUserLanguage' ) ) {
case 'he':
messages = {
rightsLog: 'יומן הרשאות במטא־ויקי',
gblRightsLog: 'יומן הרשאות גלובליות',
centralAuth: 'מידע על החשבון הגלובלי'
};
break;
default:
messages = {
rightsLog: 'Meta user rights log',
gblRightsLog: 'Global rights log',
centralAuth: 'Global account info'
};
break;
}
function i18n( key ) {
return messages[ key ] || key;
}
function addLinks() {
const wikiId = mw.config.get( 'wgWikiID' );
const rightsLogUrl = mw.util.getUrl( 'm:Special:Log', {
type: 'rights',
page: `User:${ username }${ wikiId === 'metawiki' ? '' : `@${ wikiId }` }`
} );
const gblRightsLogUrl = mw.util.getUrl( 'm:Special:Log', {
type: 'gblrights',
page: `User:${ username }`
} );
const centralAuthUrl = mw.util.getUrl( `m:Special:CentralAuth/${ username }` );
const $rightsLogLink =
$( '<a>' ).attr( 'href', rightsLogUrl ).text( i18n( 'rightsLog' ) );
const $gblRightsLogLink =
$( '<a>' ).attr( 'href', gblRightsLogUrl ).text( i18n( 'gblRightsLog' ) );
const $centralAuthLink =
$( '<a>' ).attr( 'href', centralAuthUrl ).text( i18n( 'centralAuth' ) );
const $linksContainer = $( '<p>' ).append(
'(',
$rightsLogLink,
' | ',
$gblRightsLogLink,
' | ',
$centralAuthLink,
')'
);
$( '#mw-userrights-form2 > fieldset > .mw-usertoollinks' )
.after( $linksContainer );
}
$.when( mw.loader.using( 'mediawiki.util' ), $.ready ).then( addLinks );
} )();