User:DannyS712 test/PC.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
Documentation for this user script can be added at User:DannyS712 test/PC. |
//<nowiki>
$(function (){
var PC_config = {
name: '[[User:DannyS712/Polluted categories|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\| {{dbr link\|1=(.*)}}/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 );
}
}
}
});
//</nowiki>