Skip to content

Instantly share code, notes, and snippets.

@raphaelrk
Last active August 29, 2015 14:06
Show Gist options
  • Save raphaelrk/ecffdf091fd2ac287602 to your computer and use it in GitHub Desktop.
Save raphaelrk/ecffdf091fd2ac287602 to your computer and use it in GitHub Desktop.
scrapes names of seniors off the homecoming voting list and lets you see some stats on them if you check out the vars in the console. It's got some rough edges but it doesn't really matter
var peopleLists = document.getElementsByClassName('ss-choices');
var girlNames = [];
var guyNames = [];
for(var list = 0; list < peopleLists.length; list++) {
var peopleHTML = peopleLists[list].children;
for(var person = 0; person < peopleHTML.length; person++) {
var arr = list === 0 ? girlNames : guyNames;
arr[person] = peopleHTML[person].innerText.slice(1).toLowerCase();
}
}
var all_names = girlNames.concat(guyNames);
var abcs = "abcdefghijklmnopqrstuvwxyz";
var first_initial_abcs = [];
var last_initial_abcs = [];
for(var i = 0; i < 26; i++) {
first_initial_abcs[i] = 0;
last_initial_abcs[i] = 0;
}
for(var i = 0; i < all_names.length; i++) {
var first_initial = all_names[i][0];
var abc_location = abcs.indexOf(first_initial);
first_initial_abcs[abc_location]++;
var last_initial = all_names[i].split(" ")[1][0]; // doesn't handle middle names
abc_location = abcs.indexOf(last_initial);
last_initial_abcs[abc_location]++;
}
var girl_first_names = [];
var guy_first_names = [];
var last_names = [];
for(var i = 0; i < girlNames.length; i++) {
var girl_name = girlNames[i].split(" ");
girl_first_names.push(girl_name[0]);
last_names[i] = girl_name[1];
}
for(var i = 0; i < guyNames.length; i++) {
var guy_name = guyNames[i].split(" ");
guy_first_names[i] = guy_name[0];
last_names[last_names.length] = guy_name[1];
}
girl_first_names.sort();
guy_first_names.sort();
last_names.sort();
var gfn_counts = {};
for(var i = 0; i< girl_first_names.length; i++) {
var name = girl_first_names[i];
gfn_counts[name] = gfn_counts[name] ? gfn_counts[name]+1 : 1;
}
var gfn_see_counts = [];
for(var i = 0; i < girl_first_names.length; i++) {
var name = girl_first_names[i];
var count = gfn_counts[name];
gfn_see_counts[count] = gfn_see_counts[count] ? gfn_see_counts[count]+name : count + name;
}
var bfn_counts = {};
for(var i = 0; i< guy_first_names.length; i++) {
var name = guy_first_names[i];
bfn_counts[name] = bfn_counts[name] ? bfn_counts[name]+1 : 1;
}
var bfn_see_counts = [];
for(var i = 0; i < guy_first_names.length; i++) {
var name = guy_first_names[i];
var count = bfn_counts[name];
bfn_see_counts[count] = bfn_see_counts[count] ? bfn_see_counts[count]+name : count + name;
}
var last_counts = {};
for(var i = 0; i< last_names.length; i++) {
var name = last_names[i];
last_counts[name] = last_counts[name] ? last_counts[name]+1 : 1;
}
var last_see_counts = [];
for(var i = 0; i < last_names.length; i++) {
var name = last_names[i];
var count = last_counts[name];
last_see_counts[count] = last_see_counts[count] ? last_see_counts[count]+name : count + name;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment