User:DannyS712/Draft re cat.js

// Install with: // // or with //  // // If forking this script, please note my contributions / give me credit $( => { const DraftReCat = {}; window.DraftReCat = DraftReCat; DraftReCat.config = {	name: 'draft re cat',	version: 1.1,	debug: false };

DraftReCat.summary = 'Restore categorization (using ' + DraftReCat.config.name + " v" + DraftReCat.config.version + ")."; DraftReCat.run = function { if ( DraftReCat.config.debug ) { console.log ( DraftReCat.summary ); }	var api = new mw.Api; api.get( {		action: 'query',		titles: mw.config.get( 'wgPageName' ),		prop: 'revisions',		rvprop: 'content',		rvslots: 'main',		formatversion: 2	} ).done(		function ( response ) {			console.log( response );			var text = response.query.pages[0].revisions[0].slots.main.content;			var newText = text				.replace( /\[\[:Category/gi, '\[\[Category' ); // Replace links with categorization

api.postWithEditToken( {				action: 'edit',				title: mw.config.get( 'wgPageName' ),				text: newText,				summary: DraftReCat.summary			} ).done(				function {					location.reload;				}			); }	); };

});

$( document ).ready( => {	if ( mw.config.get( 'wgNamespaceNumber' ) === 0 ) {		mw.loader.using( [ 'mediawiki.util' ], function { var link = mw.util.addPortletLink( 'p-cactions', '#', 'DRC', 'ca-drc', 'Draft re cats'); $( link ).click( function ( event ) {					event.preventDefault;					mw.loader.using( 'mediawiki.api', window.DraftReCat.run );				} ); }		);	} } );