User:Waggers/aaiv.js

if (document.URL == 'http://en.wikipedia.org/wiki/User:Waggers/aaiv') { addOnloadHook(func_aaiv);

}

function func_aaiv { var op = " The tool is active; the current vandal alerts should appear below. If the page has finished loading and there are no reports listed, then there are currently no reports at AIV! ";

//get html code of AIV page a=sajax_init_object; a.open("GET", wgServer + "/wiki/Wikipedia:Administrator_intervention_against_vandalism", true); a.onreadystatechange = function {     if(a.readyState != 4) return; //    alert("[" + a.status + ":" + a.statusText + "]\n" + a.responseText); aivcode = a.responseText;

var botpointer = aivcode.indexOf(' Bot-reported '); var userpointer = aivcode.indexOf(' User-reported ');

//bot reported var listpointer = aivcode.indexOf('', botpointer); if (userpointer > listpointer) {

//start table op = op + " Bot reported "; op = op + " "; } else { op = op + " There are currently no bot-reported vandals. "; } // end if

//user reported listpointer = aivcode.indexOf('', userpointer); botpointer = aivcode.indexOf(' ',userpointer); if (listpointer < botpointer) {

//start table op = op + " User reported "; op = op + " "; } else { op = op + " There are currently no user-reported vandals. "; } // end if

//test output //op = op + a.responseText; //op = op + aivcode; document.getElementById('bodyContent').innerHTML = document.getElementById('bodyContent').innerHTML + op;

}; a.send(null);

}

function aaivgetvandal (aivcode, listpointer) { var p = aivcode.indexOf("title=User:", listpointer); var s = aivcode.substr(p); var q = s.indexOf("&amp;action"); var v = s.substr(11,q-11); return v; }

function aaivgetvandaltemplate (aivcode, listpointer) { var q = aivcode.indexOf(" ",listpointer); var s = aivcode.substr(listpointer, q+7-listpointer); return s; }