Skip to content

Instantly share code, notes, and snippets.

@fatimaburke
Last active December 20, 2019 19:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fatimaburke/f76b1171ae8c5b01c1b84e3d83103768 to your computer and use it in GitHub Desktop.
Save fatimaburke/f76b1171ae8c5b01c1b84e3d83103768 to your computer and use it in GitHub Desktop.
Auto Voting for Balloteer
var voteData;
var votes;
// grab all category tables
var allCats = document.querySelectorAll('.bposcandidates')
//loop through all categories, grab the Rows
var allTableRowsNew = [];
for (var i=0; i < 28; i++) {
var allTableRows = Array.from(allCats[i].children[0].children)
// then push data into new array
allTableRowsNew.push(allTableRows)
}
// console.log(allTableRowsNew);
//Remove rows without input field
for (var i=0; i < allTableRowsNew.length; i++) {
var eachRow = allTableRowsNew[i];
for (var j = 1; j <= eachRow.length; j += 1) {
eachRow.splice(j,1)
}
}
// Begin Selecting my options from modified array
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function makeSelections() {
voteData = [
[0,3],[1,5],[2,4],[3,6],[4,2],[5,8],[6,8],
[7,2],[8,3],[9,1],[10,1],[11,2],[12,3],[13,4],
[14,3],[15,6],[16,1],[17,5],[18,2],[19,1],[20,1],
[21,1],[22,5],[23,6],[24,9],[25,4],[26,8],[27,6],
]
for (var i=0; i < voteData.length; i++) {
votes = allTableRowsNew[voteData[i][0]][voteData[i][1]];
var curVote = votes.children[0].children[0].children[0]
curVote.scrollIntoView({
behavior: "smooth",
block: "center",
inline: "nearest"
});
curVote.click();
console.log('Selecting Candidate for Category ' + (i+1));
await sleep(2000);
console.log('Box Checked for:' + votes.innerText );
}
alert('Selections Complete. Please Click "Cast Your Vote" button at the bottom of the page');
}
makeSelections();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment