Firefox and greasemonkey are two things that everybody in the Internet loves. I have already given you a start on greasemonkey, and also a few other sample codes, to play with the greasemonkey.

Today, i have another greasemonkey script to give you - a script that will fill up your email or user name in a form or a page. It is up to the user to identify new pages and new fields, and customize the code for the same. If you find a utility and need help to code, ask the coder.

You may need help on how to get started with the greasemonkey, or to see some sample greasemonkey code for google search.

If you are an intermediate or expert programmer, you can skip the above. You can download greasemonkey from the download page.

Lets get started with the task. We have seen google tool bar doing a auto fill, but the problem is you cannot have multiple email ids and does not customizable fields. greasemonkey to the rescue.

Lets code the first part by filling up the user name in google.com home page.

var url = “” + document.location;

var gmail_id = your_gmail_id_goes_here ;

// gmail or orkut or blogger..
if ( url.match (”www.google.com”) != null )
{
document.getElementById (”Email”).value = gmail_id;
document.getElementById (”Passwd”).focus();
}

First we get the url of the page(obtained as document.location) as a string, in a variable (url).

The match method in javascript searches for the presence of a string and returns a portion of the string. Hence the method will return null if the string is not found.

Next we get the specific field names by using the firebug tool. It must take only seconds to do so.

We fill in the email id field and also set focus in the password field for easy access.

This feature may not be useful if you are using “remember my password” in firefox.

Similarly you can use the same code, a bit optimized of course, in other websites also.

// yahoo

var yahoo_id = your_yahoo_id_goes_here ;

if ( url.match (”login.yahoo.com”) != null )
{
//alert (’Welcome to yahoo..’);
document.getElementById (’username’).value = yahoo_id ;
document.getElementById (’passwd’).focus();
}

// blogger
if (url.match ( “blogger.com “) != null)
{
//alert (’welcome to blogger’);
document.getElementById (’f-username’).value = gmail_id;
document.getElementById (’f-password’).focus();
}

Feel free to expand this feature and use it as you like in your websites. I also wrote another script, which will fill up your email, name , and website, making it easy for you to comment in websites running wordpress. I ll post the same later.