_ _    _ _____  ___   __                       
 __      _(_) | _(_)___ / ( _ ) / /_   ___ ___  _ __ ___  
 \ \ /\ / / | |/ / | |_ \ / _ \| '_ \ / __/ _ \| '_ ` _ \ 
  \ V  V /| |   <| |___) | (_) | (_) | (_| (_) | | | | | |
   \_/\_/ |_|_|\_\_|____/ \___/ \___(_)___\___/|_| |_| |_|

User:Prodego/Sandbox.js

In the article we present below, we will explore User:Prodego/Sandbox.js in detail, addressing different aspects that will allow us to understand its importance and relevance today. From its origins to its impact on society, through its applications and possible future implications, we will exhaustively analyze this topic. Through different perspectives and approaches, we will try to shed light on User:Prodego/Sandbox.js, with the aim of providing a complete and in-depth vision that allows the reader to acquire solid knowledge about it.
addOnloadHook(function() { 
    ttext = document.getElementById("firstHeading").firstChild.innerHTML;
    suffix = ": Difference between revisions";
    if(ttext.indexOf(suffix, ttext.length - suffix.length) !== -1) {
    mw.util.addPortletLink("p-cactions", "javascript:vandalBlock()", "Kill", "ca-vandal", "Block user");
    }
});
function vandalBlock() {
        var rcol = document.getElementById('bodyContent').getElementsByTagName('td').item(1);
        if (rcol != null)
        var user = rcol.getElementsByTagName('a').innerHTML;
        var expiry = 'indefinite';
        var others = '&autoblock=1&nocreate=1&allowusertalk=1'
        jsMsg('<div id="vandalblockinfo"></div>');
        if(user != mw.config.get('wgUserName')) {
            if(IPhandler(user) == true){
        expiry = '1%20week';
        others = '&autoblock=1&nocreate=1&allowusertalk=1';
            }
      if(!isUserBlocked(user)) {
        var token = getBlockToken(user);
        blockUser(user, token, expiry, others); 
      }
        } 
    else {
      document.getElementById('vandalblockinfo').innerHTML+= "Attempt to block self rejected. Please check your edits.<br />"; 
    }
        var rollback = getElementsByClassName(document, "span", "mw-rollback-link");
        if (rollback) {
      rollbacklink = rollback.getElementsByTagName('a').href;          
      rollbacktoken = rollbacklink.substring(rollbacklink.indexOf('&token=')+7)
      doRollback(rollbacktoken, user);
        }
        else {        
      document.getElementById('vandalblockinfo').innerHTML+= "Edit already rolled back.<br />"; 
        }
}
 
function getBlockToken(user) {
  document.getElementById('vandalblockinfo').innerHTML+= "Getting block token...<br />"; 
  var req = sajax_init_object();
  var params = "action=block&user=" + encodeURIComponent(user) + "&gettoken=1&format=json";
  req.open("POST", wgScriptPath + "/api.php?", false);
  req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  req.send(params);
  response = eval('(' + req.responseText + ')');
  token = response;
  delete req;
  return token;
}
function doRollback(rollbacktoken, user) {
  var req = sajax_init_object();
  title = wgPageName;
  var params = "action=rollback&token="+rollbacktoken+"&title="+title+"&user="+encodeURIComponent(user)+"&markbot=1&format=json";
  url = wgScriptPath + "/api.php";
  req.open("POST", url, true);
  req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  req.onreadystatechange = function() {
    if(req.readyState == 4 && req.status == 200) {
    response = eval('(' + req.responseText + ')');
    try {
      document.getElementById('vandalblockinfo').innerHTML += "Rollback on "+response+" succeeded<br />";
    } catch(err) {
      document.getElementById('vandalblockinfo').innerHTML += "Error " + response+"<br />";
    }
    delete req;
  }
  }
  req.send(params)
}

function isUserBlocked(user) {
  var req = sajax_init_object();
  var params = "action=query&format=json&list=blocks&bkusers="+encodeURIComponent(user)+"&bkprop=by";
  url = wgScriptPath + "/api.php";
  req.open("POST", url, false);
  req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  req.send(params);
  response = eval('(' + req.responseText + ')');
  try {
    document.getElementById('vandalblockinfo').innerHTML+= "User already blocked by "+ response+"<br />";
  } 
  catch(err) {
      delete req;
    return false;
  }
  delete req;
    return true;
}

function blockUser(user, token, expiry, others) {
  document.getElementById('vandalblockinfo').innerHTML+= "Blocking...<br />"; 
  var req = sajax_init_object();
  var params = "action=block&format=json&token="+encodeURIComponent(token)+"&user="+encodeURIComponent(user)+"&expiry="+expiry+"&reason=]"+others;
  url = wgScriptPath + "/api.php";
  req.open("POST", url, true);
  req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  req.onreadystatechange = function() {
    if(req.readyState == 4 && req.status == 200) {
      response = eval('(' + req.responseText + ')');
      try {
        document.getElementById('vandalblockinfo').innerHTML+= response+" has been blocked<br />";
      } 
      catch(err) {
        document.getElementById('vandalblockinfo').innerHTML+= "Error " + response + "<br />";
      }
      delete req;
    }
  }
  req.send(params)
}