User:Nageh/rollbackSum.js

Source: 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.
/* Credits to [[User:Ilmari Karonen]] for original code
 *        ... [[User:Porchcrop]] for minor improvements (documentation at [[User:Porchcrop/Rollback Summary]])
 *        ... [[User:Alex_Smotrov]] for essentially this version (see [[Wikipedia:Village_pump_(technical)/Archive_96#Script_User:Porchcorpter.2FrollbackSum.js_working.2C_not_working.2C_working.2C_not_working...]])
 */
$(function(){
 
   var promptSummary = function () {
        var summary = prompt("Enter summary for rollback (or leave as current to use default summary):", "[[Help:Reverting|Reverted]] edits by [[Special:Contributions/$2|$2]] ([[User talk:$2|talk]]) to last version by $1");
        if (summary == null || summary == "") return false;
        if (summary == "[[Help:Reverting|Reverted]] edits by [[Special:Contributions/$2|$2]] ([[User talk:$2|talk]]) to last version by $1") return true;
        this.href = this.href.replace("?", "?summary=" + encodeURIComponent(summary) + "&"); 
    };
 
   $('.mw-rollback-link a').click( promptSummary );
 
})