// For description, see [[User:Mr.Z-man/rollbackSummary]]
function setRollbackSummary() {
	summary = prompt("Cambia il messaggio di default per ogni link di rollback di questa pagina in:", "");
	if (!summary) {
		for (var i in document.links) {
			if (document.links[i].href && document.links[i].href.indexOf('summary=') != -1) {
				document.links[i].href = document.links[i].href.substring(0, document.links[i].href.indexOf('summary=')-1);
			}
		}
	}
	else {
		summary = "&summary=%5B%5BAiuto%3ARollback%7CRollback%5D%5D%3A+" + encodeURIComponent(summary);
		for (var j in document.links) {
			if (document.links[j].href && document.links[j].href.indexOf('action=rollback') != -1) {
				document.links[j].href += summary;
			}
		}
	}
}
function rollbackSummary() {
	var $hasRollback = $( '.mw-rollback-link');
 
	if ( $hasRollback.length == 1) {
		var portletLink = mw.util.addPortletLink( 'p-cactions', '#', "Rollback summary", "ca-rollbacksummary", "Modifica il messaggio di revert per questa pagina");
		$( portletLink ).click( function ( e ) {
			e.preventDefault();
			setRollbackSummary();
		} );
	}
}
$(rollbackSummary);