MediaWiki:Gadget-botRollback.js

Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
/**
 * This is an on-site JS hack to add a button marking a rollback as a bot edit.
 * and visit a page history.
 * @author MarkTraceur, 2014
 */

( function ( $, mw ) {
	var $rollbackLinks = $( '.mw-rollback-link' ),
		isHistory = $( 'body' ).hasClass( 'action-history' );

	$rollbackLinks.each( function ( i, link ) {
		var $span = $( link ),
			$link = $span.find( 'a' ),
			$botLink = $( '<a>' )
				.prop( 'href', $link.prop( 'href' ) + '&bot=1' )
				.prop( 'title', 'Rollback and mark as bot' )
				.text( 'br' ),
			$botSpan = $( '<span>' )
				.addClass( 'mw-bot-rollback-link' )
				.append( $botLink );

		$span.after( $botSpan );

		if ( isHistory ) {
			$span.after( ' | ' );
		} else {
			$span.after( ' ' );
			$botSpan.prepend( '[' );
			$botSpan.append( ']' );
		}
	} );
}( jQuery, mediaWiki ) );