User:Waggers/aaiv.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
This user script seems to have a documentation page at User:Waggers/aaiv. |
if (document.URL == 'http://en.wikipedia.org/wiki/User:Waggers/aaiv') {
addOnloadHook(func_aaiv);
}
function func_aaiv (){
var op = "<p>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!</p>";
//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('<span class="mw-headline">Bot-reported</span>');
var userpointer = aivcode.indexOf('<span class="mw-headline">User-reported</span>');
//bot reported
var listpointer = aivcode.indexOf('<ul>', botpointer);
if (userpointer > listpointer) {
//start table
op = op + "<h2>Bot reported</h2>";
op = op + "<table border=2>";
op = op + "<tr>";
op = op + "<td>Alleged vandal</td>";
op = op + "<td>Reported by</td>";
op = op + "<td>Last edit</td>";
op = op + "<td>Last talk page edit</td>";
op = op + "<td>Time reported</td>";
op = op + "</tr>";
while (listpointer < userpointer && listpointer > 0) {
listpointer = aivcode.indexOf('<span class=',listpointer+4);
var vandal = aaivgetvandal (aivcode, listpointer);
op = op + "<tr><td>" + vandal + "</td></tr>";
} // end of while loop
//end of table
op = op + "</table>";
} else {
op = op + "<p>There are currently no bot-reported vandals.</p>";
} // end if
//user reported
listpointer = aivcode.indexOf('<ul>', userpointer);
botpointer = aivcode.indexOf('<div class="printfooter">',userpointer);
if (listpointer < botpointer) {
//start table
op = op + "<h2>User reported</h2>";
op = op + "<table border=2>";
op = op + "<tr>";
op = op + "<td>Alleged vandal</td>";
op = op + "<td>Reported by</td>";
op = op + "<td>Last edit</td>";
op = op + "<td>Last talk page edit</td>";
op = op + "<td>Time reported</td>";
op = op + "</tr>";
while (listpointer < botpointer && listpointer > 0) {
listpointer = aivcode.indexOf('<span class=',listpointer+4);
var vandal = aaivgetvandal (aivcode, listpointer);
op = op + "<tr><td>" + vandal + "</td></tr>";
} // end of while loop
//end of table
op = op + "</table>";
} else {
op = op + "<p>There are currently no user-reported vandals.</p>";
} // 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("&action");
var v = s.substr(11,q-11);
return v;
}