/* Makes [rollback] links for edits excecute without an additional page load. Including self-closing bookmarklet option. * Based on [[meta:User:Krinkle/Scripts/AjaxPatrolLinks.js]] * See https://bugzilla.wikimedia.org/show_bug.cgi?id=31270 */ function ajaxRollback() { var $rollbackLinks = $('.mw-rollback-link a'); if ( $rollbackLinks.length > 0 ) { $rollbackLinks.click( function(e) { e.preventDefault(); var $this = $(this); var href = $this.attr( 'href' ); $this.text('Rolling back...'); $rollbackLinks = $this.parent(); // FIXME: Use MediaWiki API $.get( href, null, function( data, status, request ) { if ( status == 'success' ) { $this.html('Rolled back'); } else { $this.html('Rollback failed');// MediaWiki:Rollbackfailed } } ); }); } } $(ajaxRollback);