Google User Persitance Thing

By Jason Rhyley Last update Jun 19, 2005 — Installed 2,573 times. Daily Installs: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
// ==UserScript==
// @name		Google User Persitance Thing
// @namespace		http://www.rhyley.org/gm/
// @description		Add a drop-down box with your google ID's to the google login form.
// @include		http://*.google.co*
// @include		https://*.google.co*
// ==/UserScript==

// ** Add your user ID's to this array
names = new Array("Put","Your","User","ID","Here");
var i,k;
window.myLogin = null;
window.myPassw = null;
opts = new Array();


function gm_xpath(what,where) {
	return document.evaluate(what,where,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);
}

myLogin = gm_xpath("//input[@name='Email']",document);
myLogin = (myLogin)? myLogin.snapshotItem(0) : null;
myPassw = gm_xpath("//input[@name='Passwd']",document);
myPassw = (myPassw)? myPassw.snapshotItem(0) : null;


window.buildLoginThing = function() {
	if (names[0] == 'Put'){
		alert('You must configure the script before it will \nwork propery. Go to \"Manage User Scripts\" and\nuse the \"Edit\" button to change the script.');
		return;
	}
	
	var theSelect = document.createElement("select");
	theSelect.setAttribute("name","Email");
	theSelect.setAttribute("style","width:10em");
	theSelect.setAttribute("onchange","if (this.selectedIndex == this.options.length-1) killLoginThing(this); else password.focus()");
	
	for (var i in names) {
		opts[i] = document.createElement("option")
		opts[i].setAttribute("value",names[i]);
		opts[i].innerHTML = names[i];
		theSelect.appendChild(opts[i]);
	}
	opts[i] = document.createElement("option")
	opts[i].innerHTML = "Other...";
	theSelect.appendChild(opts[i]);
	myLogin.parentNode.replaceChild(theSelect, myLogin);
}

window.killLoginThing = function(elm) {
	var theText = document.createElement("input");
	theText.setAttribute("type","text");
	theText.setAttribute("name","Email");
	theText.setAttribute("style","width:10em");	
	elm.parentNode.replaceChild(theText, elm);
	theText.focus();
}


if (myLogin && myPassw){ 
	buildLoginThing();
	myPassw.setAttribute("style","width:10em");
	setTimeout("myPassw.focus()",100);
}