User:Blablubbs/rbk.js
Appearance
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
//forked from [[User:Chlod/Scripts/AjaxRollbackSummary.js]] and by extension [[User:DannyS712/AjaxRollbackSummary.js]] and [[User:Abelmoschus Esculentus/AjaxRollbackSummary.js]
// <nowiki>
jQuery(document).ready(function ($) {
$('span.mw-rollback-link a').on("click", function(e) {
e.preventDefault();
var $rblink = $(this);
var href = this.getAttribute("href");
this.innerHTML = '<img src="https://upload.wikimedia.org/wikipedia/commons/f/f8/Ajax-loader%282%29.gif" style="vertical-align: baseline;" height="15" width="15" border="0" alt="Rolling back..." />';
var summary = prompt("Enter summary (leave blank will cancel the action)", "Reverted edits by [[Special:Contributions/$2|$2]] ([[User talk:$2|talk]]) to last version by $1. ");
if (summary === null || summary === "") {
$rblink.text(function (i, val) {return val + '[rollback cancelled]';});
return;
}
$.ajax({
url: href.replace("?", "?summary=" + encodeURIComponent(summary) + "&"),
success: function() {
$rblink.text(function (i, val) {return val + '[reverted]';});
loadPageData();
},
error: function() {
$rblink.text(function (i, val) {return val + '[rollback failed]';});
loadPageData();
}
});
return false;
});
});
// </nowiki>