// ==UserScript==
// @name Apple's iTunes 1 billion contest helper
// @namespace http://www.chrisdolan.net
// @description Prefill some data in a contest entry form
// @include https://phobos.apple.com/WebObjects/MZFinance.woa/wa/billionSongAlternateEntryForm*
// @include http://www.apple.com/itunes/1billion/entryform/
// ==/UserScript==
var focus_field = "7.1.49";
var data = {};
data["7.1.5.3"] = "Chris";
data["7.1.5.7"] = "Dolan";
data["7.1.9"] = "1234 Main St";
data["7.1.17"] = "Madison";
data["7.1.19.0.3"] = "WI";
data["7.1.21.0.3"] = "537XX";
data["7.1.25"] = "United States";
data["7.1.29"] = "608";
data["7.1.31"] = "555-1212";
data["7.1.35"] = "January";
data["7.1.36"] = "1";
data["7.1.37"] = "1970";
data["7.1.41"] = "chris@example.com";
data["7.1.45"] = "chris@example.com";
var form = document.forms[0];
for (var i=0; i<form.elements.length; i++) {
var e = form.elements[i];
if (e.name == focus_field)
e.focus();
var val = data[e.name];
if (val == null)
continue;
if (e.type == "text") {
e.value = val;
} else if (e.type.indexOf("select") == 0) {
for (var j=0; j<e.options.length; j++)
if (e.options[j].text == val) {
e.selectedIndex = j;
break;
}
} else
alert("failed to set "+e.name+" = "+val);
}