Jump to content

User:Mr.Z-man/movereverttest.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.
function moverevertclick() {
  for (var i=0; i<document.links.length; i++) {
    if (document.links[i].href.indexOf('&wpOldTitle') != -1)  {
      f=document.createElement("IFRAME");
      f.src=document.links[i].href + "&printable=yes&moveclick=true";
      f.style.display = 'none';
      document.body.appendChild(f);
      page = document.links[i].href.toString().replace(/http:\/\/en\.wikipedia\.org\/w\/index\.php\?title=Special:MovePage\&wpOldTitle=(.*?)\&wpNewTitle=.*/, "$1");
      deleteurl = "http://en.wikipedia.org/w/index.php?title=" + page + "&action=delete&wpReason=pagemove%20vandalism%20cleanup&deleteclick=true";
      g=document.createElement("IFRAME");
      g.src = deleteurl;
      g.style.display = 'none';
      document.body.appendChild(g);
    }
  }
}

function moverevertlink() {
  if (document.getElementsByTagName('h1')[0].innerHTML == "Move log") {
    addPortletLink('p-cactions', 'javascript:moverevertclick()', "revert all", "ca-moverevert", "Revert");
  }
  if (document.URL.indexOf('moveclick=true') != -1) {
    document.getElementById('movepage').submit();
  }
  if (document.URL.indexOf('deleteclick=true') != -1) {
    setTimeout("confirmdelete()", 10000);
  }
}

function confirmdelete() {
  if (document.getElementById('mw-historywarning') == null && document.getElementById('deleteconfirm')) {
    document.getElementById('deleteconfirm').submit();
  } else if (wgArticleId != 0)  { document.location.reload(); }
}
addOnloadHook(moverevertlink);