// ==UserScript== // @name Yahoo! User Persitance Thing // @namespace http://www.rhyley.org/gm/ // @description Add a drop-down box with your yahoo ID's to the Yahoo login form. // @include http://*.yahoo.com* // @moreinfo: http://www.rhyley.org/posts/938 // ==/UserScript== (function() { function gm_xpath(what,where) { return document.evaluate(what,where,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null); } // ** Add your user ID's to this array names = new Array("Put","Your","User","ID","Here"); var i,k; window.myLogin = null; unsafeWindow.myPassw = null; opts = new Array(); myLogin = gm_xpath("//input[@name='login']",document); myLogin = (myLogin)? myLogin.snapshotItem(0) : null; myPassw = gm_xpath("//input[@name='passwd']",document); myPassw = (myPassw)? myPassw.snapshotItem(0) : null; function buildLoginThing() { 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("id","username"); theSelect.setAttribute("name","login"); theSelect.setAttribute("class","yreg_ipt"); theSelect.setAttribute("onchange","if (this.selectedIndex == this.options.length-1) killLoginThing(this); else myPassw.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); theSelect.setAttribute("id","p"); } unsafeWindow.killLoginThing = function(elm) { var theText = document.createElement("input"); theText.setAttribute("type","text"); theText.setAttribute("id","username"); theText.setAttribute("name","login"); theText.setAttribute("class","yreg_ipt"); elm.parentNode.replaceChild(theText, elm); theText.focus(); } if (myLogin && myPassw){ buildLoginThing(); setTimeout(function (){myPassw.focus()},1000); } })();