User:NguoiDungKhongDinhDanh/AjaxRollback.js

// // // For attribution: // * User:BenjaminWillJS/AjaxRollback.js // * User:Abelmoschus Esculentus/AjaxRollback.js // * User:DannyS712/AjaxRollback.js

$(function {	if (!$('.mw-rollback-link').length) {		return;	}	mw.loader.addStyleTag(` @keyframes loader { 0%, 100% {				content: '••• '; }			25% {				content: ' •••'; }			50% {				content: '• ••'; }			75% {				content: '•• •'; }		}		.loader::after { content: ''; font-family: monospace, monospace; font-size: 0.6em; white-space: pre; animation: loader 0.5s infinite; }	`);	var api = new mw.Api;	mw.hook('wikipage.content').add(function { $('.mw-rollback-link > a').click(function(e) {			e.preventDefault;			var $span = $(this).parent;			var href = new mw.Uri($(this).attr('href'));			$span.html( $(' ').addClass('loader') );			api.postWithToken('rollback', { action: 'rollback', title: href.query.title, user: href.query.from, format: 'json' }).done(function { $span.text('✓'); }).fail(function { $span.text('✗'); }).always(function { $span.find('.loader').remove; });		});	}); });

//