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',*/      'WantedFiles': 'Wantedfiles',      'UnusedFiles': 'Unusedimages',      'UnusedCategories': 'Unusedcategories',      'UncategorizedPages': 'Uncategorizedpages',      'DeadendPages': 'Deadendpages',      'UnusedTemplates': 'Unusedtemplates',      'UncategorizedTemplates': 'Uncategorizedtemplates',      'BrokenRedirects': 'BrokenRedirects',      'DoubleRedirects': 'DoubleRedirects',      'LonelyPages': 'Lonelypages',      'UncategorizedCategories': 'Uncategorizedcategories', 'WantedCategories': 'Wantedcategories', '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 ); }       } );      }    } );  } } )( mediaWiki, jQuery );