User:Ronhjones/anp.js

( function ( mw, $ ) {	function processResult( doAction ) {		var txt = $( '#wpTextbox1' ).val;		var summary = $( '#wpSummary' ).val;		if ( !txt ) return;		switch ( doAction ) {			case 'anp' :				txt = txt+'\n';				summary += 'Tagging page - Category:Association football player non-biographical articles';				break;			default :				alert( 'There was an error processing your request.\n\n\t\t\t\t\tPlease try again.' );				return;							}		$( '#wpTextbox1' ).val( txt );		$( '#wpSummary' ).val( summary );		$( '#editform' ).submit;// uncomment this line when you're sure it's working as intended and you won't have to hit [Save page]	}	function getEdit( doAction ) {		if ( doAction && ( mw.config.get( 'wgAction' ) === 'edit' || mw.config.get( 'wgAction' ) === 'submit' ) ) {			processResult( doAction );		} else {			location.assign( mw.util.getUrl( mw.config.get( 'wgPageName' ), { action: 'edit', runThis: doAction } ) ); }	}	if ( mw.config.get( 'wgNamespaceNumber' ) === 0 ) { var runThis = mw.util.getParamValue( 'runThis' ); if ( runThis ) { getEdit( runThis ); } else { var doanp = mw.util.addPortletLink( 'p-cactions', '#', 'anp', 'ca-anp' ); $( doanp ).click( function ( e ) {				e.preventDefault;				getEdit( 'anp' );			} ); }	} } ( mediaWiki, jQuery ) );