MySpace Auto Login

By JoeSimmons Last update Jun 25, 2009 — Installed 1,649 times. Daily Installs: 1, 2, 3, 3, 4, 3, 2, 6, 5, 4, 1, 7, 2, 4, 2, 5, 4, 2, 3, 3, 2, 1, 1, 4, 0, 2, 2, 1, 3, 7, 4, 2

There are 4 previous versions of this script.

// ==UserScript==
// @name           MySpace Auto Login
// @namespace      http://userscripts.org/users/23652
// @description    Automatically logs into myspace for you if firefox remembers your password, counts down, and has the ability to cancel auto-login
// @include        http://*.myspace.com/*
// @copyright      JoeSimmons
// @version        1.0.1
// @license        Creative Commons Attribution-Noncommercial 3.0 United States License
// ==/UserScript==

// Get ID
function $(ID) {return document.getElementById(ID);}

// center by JoeSimmons
// Instructions: Supply an id string or node element as a first argument
function center() {
var node = $('timer_box');
if(!window || !node || !node.style || node.style.display=='none') {return;}
var style = node.style;
style.display = 'block';
style.top = Math.floor((window.innerHeight/2)-(node.offsetHeight/2)) + 'px';
style.left = Math.floor((window.innerWidth/2)-(node.offsetWidth/2)) + 'px';
style.opacity = '1';
}

// Create by avg, modified by JoeSimmons
function create(a,b) {
	var ret=document.createElement(a);
	if(b) for(var prop in b) {
		if(prop.indexOf('on')==0) ret.addEventListener(prop.substring(2),b[prop],false);
		else if(prop=="kids" && (prop=b[prop])) {
			for(var i=0;i<prop.length;i++) ret.appendChild(prop[i]);
		}
		else if('style,accesskey,id,name,src,href'.indexOf(prop)!=-1) ret.setAttribute(prop, b[prop]);
		else ret[prop]=b[prop];
	}  return ret;
}

var f = $('LoginForm'),
	n = $('ctl00_ctl00_cpMain_cpMain_LoginBox_Email_Textbox'),
	p = $('ctl00_ctl00_cpMain_cpMain_LoginBox_Password_Textbox');
if(!f || !n || !p) return;

document.body.appendChild(create('div', {id:'timer_box',style:'border:2px solid #008ED2; background:#EAEAEA; color: #464646; font:18px tahoma; padding:20px; -moz-border-radius:6px; position:fixed; opacity:0; top:0; left:0; width:50%; height:20%; display:block; z-index:9999999;',kids:new Array(
create('span', {id:'timer_span',textContent:'Logging on in: 3...',style:'display:block;'}),
create('input', {type:'button',value:'Cancel',style:'border:1px solid #464646;color:#464646;background:#EAEAEA;-moz-border-radius:4px;margin:6px;',onclick:function(){
	clearInterval(si);
	$('timer_box').style.display='none';
	}})
)}));
center();

	
function login() {
if(f && n && p) f.submit();
}

function wait() {
if(!waited && n.value.length>0 && p.value.length>0) {
clearInterval(si);
waited=true;
wait();
si = setInterval(wait, 1000);
} else if(waited) {
if(i>0) {
$('timer_span').textContent = 'Logging on in: '+i+'...';
i--;
} else {
clearInterval(si);
$('timer_span').textContent = "Logging in now!";
login();
}
}
}

var si = setInterval(wait, 100), waited=false, i=3;
window.addEventListener('resize', center, false);