Jump to content

User:Geremy.Hebert/vector.js

From 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.
 //
 // Edit tools for the vandal whack-a-mole game
 // [[User:Kbh3rd/whackamole.js]] - please include this line
 //
 importScript('User:Geremy.Hebert/test.js');
 importScript('User:Kbh3rd/whackamole.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");
  }
}
addOnloadHook(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;
      }
    }
  }
}