User:Kopcap94/cu.js

(function( $, mw ) {   'use strict';    if ( mw.config.get( 'wgCanonicalSpecialPageName' ) !== 'CheckUser' ) {        return;    }

var msg, type = 'spammer\'s';

function set_reason( t ) { switch ( t ) { case 'subedits': msg = 'edits'; break; case 'subipusers': msg = 'IP'; break; case 'subuserips': msg = 'socks'; break; }

$( '#checkreason' ).val( 'To get ' + type + ' ' + msg ); }

set_reason( $( '.checkuserradios input:checked' ).attr( 'id' ) ); $( ' ', {       'data-type': 'vandalism',        type: 'button',        style: 'margin: 0 2px; padding: 0 3px;',        text: 'V'    }) .insertAfter( '#checkreason' ) .on( 'click', function {       if ( $( this ).attr( 'data-type' ) === 'vandalism' ) {            type = 'vandal\'s';            $( this )                .attr( 'data-type', 'spam' )                .text( 'S' );        } else {            type = 'spammer\'s';            $( this )                .attr( 'data-type', 'vandalism' )                .text( 'V' );        }

set_reason( $( '.checkuserradios input:checked' ).attr( 'id' ) ); });

$( '.checkuserradios input' ).on( 'change', function {       set_reason( $( this ).attr( 'id' ) );    }); })( this.jQuery, this.mediaWiki );