Jump to content

User:Jim Carter/rollback.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/* Warning! Global gadget file! */
jQuery(document).ready( function($) {
	$( '.mw-rollback-link a' ).click( function(e) {
		e.preventDefault();
		var $el = $(this);
		$.ajax({
			url: $el.attr('href'),
			success: function() {	
				var user = mw.util.getParamValue( 'from', $el.attr('href') ).replace(/\+/g, '_'); // [[bugzilla:27606|bug 27606]]
				location.href = mw.util.getUrl( 'Special:Contributions/' + user );
				},
			error: function(){
				$el.text(function( i, val ) {
					return val + ' [failed]';
				} );		
			}
		});
	} );
});