Yahoo Auto Login

By JoeSimmons Last update May 30, 2009 — Installed 1,494 times.

There are 14 previous versions of this script.

// ==UserScript==
// @name           Yahoo Auto Login
// @namespace      http://userscripts.org/users/23652
// @description    Automatically logs into yahoo for you
// @include        http://login.yahoo.com/*
// @include        https://login.yahoo.com/*
// @copyright      JoeSimmons
// @version        1.0.2
// @license        Creative Commons Attribution-Noncommercial 3.0 United States License
// ==/UserScript==

var username = GM_getValue('y_un', ''),
	password = GM_getValue('y_pw', '');

function main() {
if(!/^https?:\/\/login\.yahoo\.com/.test(window.location.href)) {return;}
if(username=='' || password=='') options();
else {
var f = window.document.evaluate("//form[@name='login_form']",document,null,9,null).singleNodeValue,
	n = window.document.evaluate("//input[@id='login' or @id='username']",document,null,9,null).singleNodeValue,
	p = window.document.evaluate("//input[@id='password' or @id='passwd']",document,null,9,null).singleNodeValue;
if(f&&n&&p) {
n.value = username;
p.value = password;
f.submit();
}
}
}

function options() {
var y_un = prompt('Username to remember'),
	y_pw = prompt('Password to remember');
if(y_un && y_pw && y_un!='' && y_pw!='') {
GM_setValue('y_un', y_un);
GM_setValue('y_pw', y_pw);
if(confirm('Reload to apply changes?')) window.location.reload();
} else if(confim('Invalid username or password.\nEnter again?')) options();
}

// Nuller by JoeSimmons. Nulls out all the elements you put as the arguments.
// Syntax: nuller(someElement,anotherElement,moreElements);
function nuller() {
	for(x in arguments)
		if(x) {
			x=null;
			delete x;
		}
}

function leakAvoider() {
nuller(username,password,n,p,f,y_un,y_pw);
window.removeEventListener('load', main, false);
document.removeEventListener('unload', leakAvoider, false);
}

window.addEventListener('load', main, false);
window.addEventListener('unload', leakAvoider, false);
GM_registerMenuCommand('Yahoo Auto Login Options', options);