User:Gryllida/js/showUserContributionsWhenBlocking.js
Note: After saving, you may have to bypass your browser's cache to see the changes. Mozilla / Firefox / Safari: hold down Shift while clicking Reload, or press Ctrl-Shift-R (Cmd-Shift-R on Apple Mac); IE: hold Ctrl while clicking Refresh, or press Ctrl-F5; Konqueror: simply click the Reload button, or press F5; Opera users may need to completely clear their cache in Tools→Preferences. — More skins
/* Author : Svetlana Tkachenko svetlana@members.fsf.org
This file is a part of showUserContributionsWhenBlocking.js.
Licence: GPLv3+
Description: [beta] shows a user contributions on the block page (sysop-only)
See also <https://en.wikinews.org/wiki/User:Gryllida/Tasks>.
*/
mw.loader.using(['mediawiki.api'], function () {
"use strict";
// == Check whether we are blocking a user ==
var thisPageTitle = mw.config.get( 'wgPageName' );
// == Retrieve and show this user's contributions ==
if (thisPageTitle.indexOf('Special:Block') === 0){
// == Create an API object ==
var api = new mw.Api();
// == Query the wiki API to get HTML of {{Special:Contributions/USERNAME}}==
api.get( {
action: 'parse',
text: '{{Special:Contributions/$1}}'.replace('$1', mw.config.get( 'wgRelevantUserName' ))
} ).done( function ( data ) {
// == Add the HTML at the end of current page ==
$('#content').append($('<h1>', {text: 'User contributions'}));
$('#content').append(data.parse.text['*']);
console.log('[showUserContributionsWhenBlocking] hi');
console.log(_addDeleteLink);
console.log('[showUserContributionsWhenBlocking] bye');
if(_addDeleteLink){
_addDeleteLink();
}
});
}
});