MediaWiki:Gadget-SpecialPages.js

( function ( mw, $ ) { if( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Specialpages' ) {    //INITIALIZE VARIABLES    var pagesToCheck = { //* 26,882 */      'UnwatchedPages': 'Unwatchedpages',/* Restricted to administrators only */ //* 10,897 */      'UncategorizedFiles': 'Uncategorizedimages', //*  8,649 */      'ShortPages': 'Shortpages', //*  7,535 */      'ListRedirects': 'Listredirects', //*  3,120 */      'WantedPages': 'Wantedpages', /*  1,581 */      'WantedFiles': 'Wantedfiles', /*  1,310 */      'UnusedFiles': 'Unusedimages', /*    465 */      'UnusedCategories': 'Unusedcategories', /*    454 */      'UncategorizedPages': 'Uncategorizedpages', /*    445 */      'UncategorizedTemplates': 'Uncategorizedtemplates', /*    288 */      'UnusedTemplates': 'Unusedtemplates', /*    282 */      'DeadendPages': 'Deadendpages', /*    172 */      'LonelyPages': 'Lonelypages', /*     16 */      'UncategorizedCategories': 'Uncategorizedcategories', /*     0 */      'DoubleRedirects': 'DoubleRedirects', /*     0 */      'BrokenRedirects': 'BrokenRedirects', /*     0 */      'WantedCategories': 'Wantedcategories', /*     0 */      'WantedTemplates': 'Wantedtemplates' };

$.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 ); }       } );      }    } );    importScript( 'MediaWiki:Gadget-SpecialPages.js/Autopromote.js' );// MediaWiki:Gadget-SpecialPages.js/Autopromote.js } } )( mediaWiki, jQuery );