User:Seb35/common.js

//mw.loader.load( "/w/index.php?title=User:Magnus_Manske/wikipic.js&action=raw&ctype=text/javascript" );

/** * Add a link in the navigation column if some maintenance category has items (they should be empty). */

// List of categories to be checked (key := category name, value := Label to be displayed in the link) var categories = { 'Category:Candidates for speedy deletion': 'Speedy deletion', 'Category:Pages using deprecated source tags': 'Depr. source tags', };

mw.loader.using( 'mediawiki.api', function {	(new mw.Api).get( { 'action': 'query', 'prop': 'categoryinfo', 'titles': Object.keys( categories ).join( '|' ) } ).then( function( query ) { $.when( $.ready ).then( function {			Object.values( query.query.pages ).forEach( function( category ) { var count = category.categoryinfo.pages + category.categoryinfo.files + category.categoryinfo.subcats; if( count > 0 ) { mw.util.addPortletLink( 'p-navigation', mw.util.getUrl( category.title ), categories[category.title] + ' (' + count + ')' ); }			} );		} );	} ); } );