User:Zzuuzz/scripts/protectionreasons.js

if ( 'protect' === mw.config.get( 'wgAction' ) || 'unprotect' === mw.config.get( 'wgAction' ) ) {

$.when( mw.loader.using( 'oojs-ui-core' ), $.ready ).then( function {

var reasons = [ 'disruption', 'vandalism', 'Talk page abuse', 'User request', 'Edit warring', 'Excessive sockpuppetry', 'Excessive spamming', 'BLP violations', 'Persistent addition of unsourced or poorly sourced content', 'High risk module', 'High risk template', 'Requested at RFPP', 'Hopefully protection is no longer necessary' ];

var dropdown = new OO.ui.DropdownWidget( { label: 'Custom reasons' } ); dropdown.menu.addItems( reasons.map( function ( optionText ) { return new OO.ui.MenuOptionWidget( { label: optionText } ); } ) );

dropdown.menu.on( 'select', function( option ) {  $('input[name="mwProtect-reason"]').val( option.label ).trigger( 'change' );  } );

$( '#mwProtect-reason' ).before( dropdown.$element );

} );

}