User:Anomie/rollback-prompt.js

/* This script modifies all "rollback" links to prompt for an edit summary (and prevent accidental rollbacks). */ $(document).ready(function{   var rollbackPrompt=function(ev){        var summary = prompt("Enter rollback summary:", " ");        if(summary == null || summary == "") {            ev=ev || window.event;            if(ev.preventDefault) ev.preventDefault;            if(ev.stopPropagation) ev.stopPropagation;            ev.returnValue = false;            ev.cancelBubble = true;            return false;        }        if(summary != " ")            this.href = this.href.replace("?", "?summary=" + encodeURIComponent(summary) + "&");        return true;    };

var links=document.getElementById('content').getElementsByTagName('a'); for(var i=links.length-1; i>=0; i--){ if(/[?&]action=rollback([&#]|$)/.test(links[i].href)) links[i].onclick=rollbackPrompt; }

});