User:The Voidwalker/latestContribs.js

// Script designed to find the most recent contributions by a large set of users. // To activate, go to Special:LatestContributions

if( mw.config.get('wgNamespaceNumber') === -1 && /Special:[Ll]atest[Cc]ontrib(s|utions)/.test(mw.config.get('wgPageName')) ) { mw.loader.using( ['oojs-ui', 'mediawiki.util', 'jquery.tablesorter'] ).then( function {   createLCInterface;  } ); }

function createLCInterface { $('#firstHeading').text( mw.config.get('wgPageName') ); text = $('#mw-content-text'); text.html(''); // Blank slate text.append(' Enter a list of usernames in the box below, or add them from a category (any "User:" prefix is stripped when submitted). Default limit is 50. '); var groupInput = new OO.ui.ActionFieldLayout( new OO.ui.TextInputWidget({ placeholder: 'Enter a usergroup' }), new OO.ui.ButtonWidget({ label: 'Add' }), { align: 'top' } ), // align top so button is attached to input widget nameInput = new OO.ui.MultilineTextInputWidget({ placeholder: 'Enter a list of usernames separated by a newline', autosize: true }), limitSelect = new OO.ui.FieldLayout( new OO.ui.DropdownInputWidget({ options: [{ data: 10, label: '10' }, {data: 25, label: '25'}, {data: 50, label: '50'}, {data: 100, label: '100'}, {data: 250, label: '250'}, {data: 500, label: '500'}, {data: 0, label: 'all'}], value: 50 }), { label: 'Limit:', align: 'right' } ); submit = new OO.ui.ButtonWidget({ label: 'Submit' }); groupInput.$button.click(function {   if(groupInput.getField.value.length === 0)      return alert("Please enter a usergroup");    addGroup;  }); nameInput.$element.css('margin-top', '1em'); // spacing text.append(groupInput.$element); text.append(nameInput.$element.css('margin-top', '1 em')); text.append(limitSelect.$element); text.append(submit.$element.click(function{submit.setDisabled(true); makeList;})); function addGroup(cont) { var val = groupInput.getField.value; var query = { action: 'query', format: 'json', list: 'allusers', augroup: val, aulimit: 500, };   if(cont){ query.continue = cont.continue; query.aufrom = cont.aufrom; }   $.getJSON(mw.util.wikiScript('api'), query).done(function(data) {      var users = data.query.allusers;      for(var i = 0; i < users.length; i++) {        nameInput.setValue(nameInput.value + (nameInput.value.length === 0 ?  : '\n') + users[i].name);      }      if(data.continue) {        addGroup(data.continue);      } else {        alert('Added users from group ' + val);        groupInput.getField.setValue();      }    }); } function makeList(users, limit) { if( !users ) { if( limitSelect.getField.value === '0' && !confirm("You have set the limit to all. Do you wish to procede? (This could take very long time)") ) return submit.setDisabled(false); users = nameInput.value.split('\n'); users.reverse; limit = limitSelect.getField.value === '0' ? Infinity : limitSelect.getField.value; text.html('Fetching list, please be patient (this may take a while). '); }   var query = { action: 'query', format: 'json', list: 'usercontribs', uclimit: 1, ucprop: 'title|ids|timestamp', ucuser: users.pop, };   $.getJSON( mw.util.wikiScript('api'), query).done(function(data) {      var tribs = data.query.usercontribs;      if(tribs[0]) {        appendRev(tribs[0]);        limit--;      }      if( limit > 0 && users.length > 0 ) {        makeList(users, limit);      } else {      	$('#patience-plz').remove;        $('table').tablesorter;      }    } ); } function appendRev(revision) { var text = ' ' + revision.title + '  ' + revision.timestamp + ' (prev) ' + revision.user + ' (talk | contribs)  '; $('#ca-list').append(text); } }