MediaWiki:Gadget-SpecialPages.js

( function ( mw, $ ) { if( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Specialpages' ) {    //INITIALIZE VARIABLES    var pagesToCheck = {      'BrokenRedirects': 'BrokenRedirects',      'DeadendPages': 'Deadendpages',      'DoubleRedirects': 'DoubleRedirects',      'ListRedirects': 'Listredirects',      'LonelyPages': 'Lonelypages',      'ShortPages': 'Shortpages',      'UncategorizedCategories': 'Uncategorizedcategories',      'UncategorizedPages': 'Uncategorizedpages',      'UncategorizedFiles': 'Uncategorizedimages',      'UncategorizedTemplates': 'Uncategorizedtemplates',      'UnusedCategories': 'Unusedcategories',      'UnusedFiles': 'Unusedimages',      'WantedCategories': 'Wantedcategories',      'WantedFiles': 'Wantedfiles',      'WantedPages': 'Wantedpages',      'WantedTemplates': 'Wantedtemplates',      'UnwatchedPages': 'Unwatchedpages',/* Restricted */      'UnusedTemplates': 'Unusedtemplates' };

$.each( pagesToCheck, function( title, qppage ){     var qpoffset = 0;      while( qpoffset !== -1 ){        $.ajax( { url: 'http://ddowiki.com/api.php?action=query&format=json&list=querypage&qplimit=max&qpoffset=' + qpoffset + '&qppage=' + encodeURIComponent( qppage ), dataType: 'json', async: false,//* REALLY DON'T LIKE THIS!!! IT WILL FAIL IN THE FUTURE!!! */         success: function( successData ){ if ( successData['query-continue'] !== undefined ){ qpoffset = successData['query-continue'].querypage.qpoffset; } else { var membersInGroup = qpoffset + successData.query.querypage.results.length; qpoffset = -1; $( 'a[title="Special:' + title + '"]' ).after( ' (' + membersInGroup.toLocaleString + ')' ); }         },          fail: function( failureData ){ alert( 'Sorry, failed to retrieve page counts for workable pages.\nPlease check the console for more details if available.' ); console.error( '%O', failureData ); }       } );      }    } );  } } )( mediaWiki, jQuery );