User:SckrTrckrBot/uncyclopedia.js

From Uncyclopedia, the content-free encyclopedia
Jump to navigation Jump to search

Note: After saving, you have to bypass your browser's cache to see the changes.

  • Internet Explorer: hold down the Ctrl key and click the Refresh or Reload button, or press Ctrl+F5.
  • Firefox: hold down the Shift key while clicking Reload; alternatively press Ctrl+F5 or Ctrl-Shift-R.
  • Opera, Konqueror and Safari users can just click the Reload button.
  • Chrome: press Ctrl+F5 or Shift+F5
//<nowiki>

// Sucker Tracker Bot v. 0.3 UBER-BETA

window.addEventListener("keypress", SelectSucker, false);

var moron = '';
var on = 0;

function SelectSucker (v) {
   if ((v.ctrlKey) && (v.which == 107))
   if (on)
   {
     on=0;
     window.clearInterval();
     window.alert('Robot inactive. Press CTRL + K again to start.');
   }
   else
   {
     moron = '';
     window.clearInterval();
     moron = window.prompt("Who should I kill?");
     if (moron == '') {
       window.alert('Invalid input. Type the user name (without the "user:") or the raw ip.');
       return;
     };
     var time = window.prompt("Select the timer(seconds) between checks\nRecommended: 30+ sec)");
     if (!time)
       time = 30;
     window.alert('Starting auto-reversions. Press CTRL + K again to stop. Welcome to MKXI');
     window.setInterval("ReviewContribs()", (time * 1000)); //review contribs each time seconds
     on=1;
     ReviewContribs(); //immediate call
   };
};

function ReviewContribs () {
   if (on)
   {
     var myWindow2 = window.open(("http://uncyclopedia.wikia.com/wiki/Special:Contributions/" + moron), "", "modal=no,chrome=yes,dependent=yes,alwaysLowered=yes");
     myWindow2.blur();
     myWindow2.setInterval("LoadContribs()", 500); //far quicker
   };
};

function TheEnd() {
  window.close();
};

function Save() {
    if (!document.getElementById("wpSave"))
       return; //still not loaded
    window.clearInterval();
    //set minor edit
    var minor = document.getElementById("wpMinoredit");
    if (minor) minor.checked = 1;
    //set summary 
    var summary = document.getElementsByName("wpSummary")[0];
    if (summary) summary.value = "That's mecha me and you are being auto-reverted. Have fun banging your head against a bot. Resistance is futile!";    
    //submit
    var btn = document.getElementById("wpSave");
    if (btn){
       btn.textContent += " (auto clicking...)";
       btn.click();
    };
    window.setTimeout("TheEnd()", 20000); //3 secs for the save be effective
};

function LoadContribs() {
  if (!document.getElementById("footer")) //still not loaded
     return;
  window.clearInterval();
  FetchPage(document);
};

function openPage(target)
{
  alert(target);
  var myWindow = window.open(target, "", "modal=no,chrome=yes,dependent=yes,alwaysLowered=yes");
  myWindow.blur();
  myWindow.setTimeout('Save()', 60000); 
  window.close();
};

function FetchPage (s) {
   var rl = s.getElementsByTagName('a');
   for(var i = 0; i < rl.length; i++)
   {
      if(rl[i].innerHTML != 'rollback')
          continue;
      openPage(rl[i].href.replace('&amp;', '&');
   }
};

function queryString(p) {
        var re = RegExp('[&?]' + p + '=([^&]*)');
        var matches;

        if (matches = re.exec(document.location)) {
            try { 
                return decodeURI(matches[1]);
            } catch (e) {
        }
    }
  
    return null;
};