MediaWiki:Gadget-SpecialPages.js

// ( function ( mw, $ ) { switch ( mw.config.get( 'wgCanonicalSpecialPageName' ) ) {    case 'Specialpages':      //INITIALIZE VARIABLES      var pagesToCheck = { //* 27,786 */        'UnwatchedPages': 'Unwatchedpages',/* Restricted to administrators only */ //* 11,156 */        'UncategorizedFiles': 'Uncategorizedimages', //*  8,993 */        'ShortPages': 'Shortpages', //*  7,586 */        'ListRedirects': 'Listredirects', //*  3,253 */        'WantedPages': 'Wantedpages', /*  1,572 */        'WantedFiles': 'Wantedfiles', /*  1,335 */        'UnusedFiles': 'Unusedimages', /*    494 */        'UnusedCategories': 'Unusedcategories', /*    468 */        'UncategorizedPages': 'Uncategorizedpages', /*    417 */        'UncategorizedTemplates': 'Uncategorizedtemplates', /*    451 */        'DeadendPages': 'Deadendpages', /*    265 */        'UnusedTemplates': 'Unusedtemplates', /*    185 */        'LonelyPages': 'Lonelypages', /*    17 */        'UncategorizedCategories': 'Uncategorizedcategories', /*     6 */        'WantedCategories': 'Wantedcategories', /*     1 */        'WantedTemplates': 'Wantedtemplates', /*     0 */        'DoubleRedirects': 'DoubleRedirects', /*     0 */        'BrokenRedirects': 'BrokenRedirects' };

$.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' );// Gadget-SpecialPages.js/Autopromote.js break; case 'Wantedfiles':// Special:Wantedfiles importScript( 'MediaWiki:Gadget-SpecialPages.js/WantedFiles.js' );// Gadget-SpecialPages.js/WantedFiles.js break; case 'DoubleRedirects':// Special:DoubleRedirects importScript( 'MediaWiki:Gadget-SpecialPages.js/DoubleRedirects.js' );// MediaWiki:Gadget-SpecialPages.js/DoubleRedirects.js break; default: /* do nothing */ } } )( mediaWiki, jQuery ); //