User:Special Cases/rollbackSummary.js

// For description, see User:Mr.Z-man/rollbackSummary

function rollbackSummary { var hasRollback = getElementsByClassName(document, "span", "mw-rollback-link"); if (hasRollback[0]) { mw.util.addPortletLink('p-cactions', 'javascript:setRollbackSummary', "rollback summary", "ca-rollbacksummary", "Set rollback link edit summary"); } } $(rollbackSummary); function setRollbackSummary { summary = prompt("Change the default rollback summary for rollback links on this page to:", ""); if (!summary) { for (var i in document.links) { if (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=" + encodeURIComponent(summary); for (var i in document.links) { if (document.links[i].href.indexOf('action=rollback') != -1) { document.links[i].href += summary; }   }  } }