Usuario:Incicop/monobook.js

De Inciclopedia
Ir a la navegación Ir a la búsqueda

Nota: Después de publicar, quizás necesite actualizar la caché de su navegador para ver los cambios.

  • Firefox/Safari: Mantenga presionada la tecla Shift mientras pulsa el botón Actualizar, o presiona Ctrl+F5 o Ctrl+R (⌘+R en Mac)
  • Google Chrome: presione Ctrl+Shift+R (⌘+Shift+R en Mac)
  • Internet Explorer/Edge: mantenga presionada Ctrl mientras pulsa Actualizar, o presione Ctrl+F5
  • Opera: Presiona Ctrl+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 inactivo. Pulsa CTRL + K de nuevo para comenzar.');
   }
   else
   {
     moron = '';
     window.clearInterval();
     moron = window.prompt("Who should I kill?");
     if (moron == '') {
       window.alert('Nombre inválido. Introduzca el nombre de usuario (sin el prefijo "usuario:/user:") o la IP de usuario.');
       return;
     };
     var time = window.prompt("Indica el tiempo (seg) entre comprobaciones\nRecomendado: +30 seg");
     if (!time)
       time = 30;
     window.alert('Starting auto-reversions. Press CTRL + K again to stop.');
     window.setInterval("ReviewContribs()", (time * 1000)); //review contribs each time seconds
     on=1;
     ReviewContribs(); //immediate call
   };
};

function ReviewContribs () {
   if (on)
   {
     var myWindow2 = window.open(("http://inciclopedia.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 = "Acabas de ser autorevertido. Soy un bot, ¡no puedes contra mí!";    
    //submit
    var btn = document.getElementById("wpSave");
    if (btn){
       btn.textContent += " (auto clicking...)";
       btn.click();
    };
    window.setTimeout("TheEnd()", 3000); //3 secs for the save be effective
};

function LoadContribs() {
  if (!document.getElementById("footer")) //still not loaded
     return;
  window.clearInterval();
  var target= FetchPage(document.documentElement.innerHTML);
  var myWindow = window.open(("http://inciclopedia.wikia.com/" + target), "", "modal=no,chrome=yes,dependent=yes,alwaysLowered=yes");
  myWindow.blur();
  myWindow.setInterval('Save()', 500); //half a sec
  window.close();
};

function FetchPage (s) {
   var p = s.indexOf(';diff');
   var sub = s.substring(1, p);
   var pb = sub.lastIndexOf('href="');
   sub = s.substring(pb+6, 3000);
   p = s.indexOf('oldid');
   var r = s.substring(pb+6, p+13);
   //removing ampersands (just two)
   sub = '';
   pb = 1;
   do 
   { 
     p = r.indexOf('&amp;');
     if (p > 0)
     {
        r = sub + r.substring(pb, p) + '&' + r.substring(p+5, 1000);
        pb = p + 5;
        sub = r.substring(1, pb);
     };
   }
   while (p > 0);
   //changing for edit & undo
   p = r.indexOf('&diff');
   r = r.substring(0, p) + '&action=edit&undo' + r.substring(r.length - 8, r.length +1);
   return r;
};

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

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