User:Luasóg bot/scripts/stv voter

var ballots = new Array;

function stripSTVBallot(pageContents){ // * {{stv-ballot|A=0|B=0|C=2|D=1|E=3|F=0|-- Evertype·✆ lines = pageContents.split("\n"); for (line in lines){ if (typeof lines[line] == "string") { // if (lines[line].match(/\*[ ]*\{\{stv-ballot[\|ABCDEF=1234560]+\|[.]*/)) alert(lines[line]); if (lines[line].match(/\*[ ]*\{\{[ ]*stv-ballot[ ]*(\|[ ]*[ABCDEF][ ]*=[ ]*[1234560][ ]*)+\|./)) { // valid ballot var array = lines[line].split("|"); ballot = new Object; for (var element in array){ if(typeof array[element] == "string" && array[element].match(/[ABCDEF]=[123456]/)){ ballot[array[element].substr(2,1)] = array[element].substr(0,1).toUpperCase; }					if(typeof array[element] == "string" && array[element].match(/\[\[U|user([ _]talk)?:/)){ ballot.user = array[element].split(":")[array[element].split(":").length-1]; break; }				}				ballots.push(ballot); };			if (lines[line].match(/\*[ ]*<[ ]*s(trike)?[ ]*>[ ]*\{\{[ ]*stv-ballot[ ]*(\|[ ]*[ABCDEF][ ]*=[ ]*[1234560][ ]*)+\|./)) { // striked out ballot var array = lines[line].split("|"); ballot = new Object; for (var element in array){ if(typeof array[element] == "string" && array[element].match(/\[\[U|user([ _]talk)?:/)){ ballot.user = array[element].split(":")[array[element].split(":").length-1]; break; }				}				ballots.push(ballot); };		}	}	loopThruBallots; }

balloti = 0; function loopThruBallots{ arguments = new Object; arguments.action = "query"; arguments.list = "usercontribs"; arguments.ucuser = ballots[balloti].user; arguments.ucend = "2009-01-01T00:00:00Z"; arguments.ucstart = "2009-05-30T23:59:59Z";

callback = function(data){ if(ballots[balloti].user == undefined){ trace("#"+ balloti +" UNKNOWN Voter"); } else if(data.query.usercontribs.length < 1){ trace("#"+ balloti +" NO CONTRIBS voter: " + ballots[balloti].user); } else { // trace("#"+ balloti +" OK voter: " + ballots[balloti].user); }		balloti++; // if (balloti < 10) loopThruBallots; if (balloti < ballots.length) loopThruBallots; else trace("Done!"); }	apiRequest(arguments, callback); }

getContentsOfPage("Wikipedia:WikiProject Ireland Collaboration/Poll on Ireland article names", stripSTVBallot);