User:DannyS712 test/PC.js

// $(function { var PC_config = {	name: 'Polluted categories.js',	version: 1.0,	debug: true }; var PC_summary = 'SUMMARY with ' + PC_config.name + ' (version ' + PC_config.version + ')'; var scriptUrl = mw.config.get( 'wgScriptPath' ) + '/api.php';

mw.loader.using( 'mediawiki.util', function {	importScript( 'User:DannyS712 test/page.js' );	if ( mw.config.get( 'wgPageName' ) === "Wikipedia:Database_reports/Polluted_categories") {	    $(document).ready( function  { mw.util.addPortletLink ( 'p-cactions', 'javascript:void(0)', 'Polluted categories', 'ca-polluted', 'TOOLTIP'); $('#ca-polluted').on('click', function {	       	Polluted_categories;	    	} ); } );	} } ); function Polluted_categories{ var content1 = get_page( mw.config.get( 'wgPageName' ) ); if (PC_config.debug) console.log( content1 ); var content2 = content1.replace( /\|-\n\| (\d*)\n\| /g, '"$2",'); if (PC_config.debug) console.log( content2 ); var content3 = content2.replace( /(.*\n)*! Category\n/i, '{\n"Pages": ['); if (PC_config.debug) console.log( content3 ); var content4 = content3.replace ( /,\n\|}/, "\n] }"); if (PC_config.debug) console.log( content3 ); var content5 = content4.replace ( /_/g, " "); if (PC_config.debug) console.log( content5 ); var as_JSON = JSON.parse( content5 ); if (PC_config.debug) console.log( as_JSON ); var array = as_JSON.Pages; console.log( array ); var page = ""; for (var iii = 0; iii < array.length; iii++){ page = array[iii]; if (/AfC submissions.*/.test(page)) console.log( "Skip: AfC" ); else { console.log( page ); }	} } }); //