auto login addon /extention.

Posted on 2011-10-14
Medium Priority
Last Modified: 2012-06-27
Hello ,

I am looking for a chrome or firefox addon that would take a config file which has website name, user and passwod detials and when every time i enter the website logs me in automatically based on the login credentials dont bother me again and again. I just want to toggle on/ off this perticular addon so it doesnt bother me all the time.
As i see it different website have different login pages and we need to write extention/ add on that caters to the websites that we want to have login automated. Is there an easy way to do this? Watir/ selenium may be... My mind is all over

Please help.

Question by:icylin
  • 2
  • 2
LVL 20

Expert Comment

ID: 36971276
I've done things like this for specific cases and private use:
One can let the addon check if the current URL belongs to the desired protected site.
If so, check if the logoin form is shown (a look at the page source will allow you to find suitable criteria for this, e.g. the presence of a form with a spcific id - which is of course site dependant, to say the least)
Then do some DOM manipulation to replace the <input id="id_of_username_input" type="text" /> with <input id="id_of_username_input" type="hidden" value="the stored username" /> and similarly for the password.
In my case, I chose not to try to push the login button automatically, but rather change the style of the relevant form elements such that the form with input fields and a small login button gets replaced by a single big login butteon - in other word, pushingthis button is all it takes to login)
However, for wider use I do not think this is a recommended method.
For example, you need to store username and password in cleartext or in an easily decodable manner.
If you want to take this approach in general, this may be quite hard as not every site is so friendly to use a standard form, let alone one that can be recognized by its id.

Author Comment

ID: 36971468
thanks thehagman for your comments.
I have around 10-15 sites that i need to auto login to and want to get credentials for each site which will be in clear text. Please let me know the easiest way to do it? I am thinking of writing a chrome addon with javascript to insert values into the input elements and push button automatically instead of dom manipulation. But i dont want to get into javascript. Is there any other easy way to get this done?

LVL 20

Accepted Solution

thehagman earned 1500 total points
ID: 36976817
It should be doable (here in FireFox parlance - I'm not sure if your "chrome" refers to the XUL chrome of Firefox or to Google's browser named Chrome):
Use gBrowser.addEventListener to add a listener to the DOMContentLoaded event
In the listener, first check whether this is one of the auto login sites, next check if the login form is present (where the id etc. may depend on the site)
if the form is present, set the values of the corrsponding username and password fields appropriately using document.getElementById('Id of input field').setAttribute("value",yourDesiredInput) and finally call document.getElementById('ID of the submit button').click()
If some of your sites do not add IDs to all inputs in question, it may be possible to use the array returned from theLoginForm.getElementsByTagName("input") with appropriate indexing. As an inspiration, I myself used essentially  the  code snippet below in my listener routine, which I just adapted slicghtly to meet your requirements

I'd suggest to place much of the data into configuration (for each site the hostname, form id, username input field if, password input field id, submit button id, user name and password) though it may be easier for a start to put things as constants into the addon in a quick-and-dirty ad-hoc manner

If this were for a "production system" one should add one more precaution: Just in case you have a typo in user credentials (or did not update the data after a password change), the above methods might cause an infinite loop where the same wrong credentials are tried again and again.

// site-specific credentials
             // should of course be filled on a per site basis
              Merke["name of username field"] = "myusername";
              Merke["name of password field"] = "T0p_s3cr3t";

               var Form = doc.getElementById("Form_Login"); // Form_Login happens to be the id of the login form (depends on site)
                if (Form) {
                        var Inputs = Form.getElementsByTagName("input");
                        var suc = 0;
                        var okbutton = -1;
                        for (var j=0; j<Inputs.length; j++) {
                                if (Inputs[j].type == "submit") {
                                     okbutton = j;
                                if ( this.Merke[Inputs[j].name] && this.Merke[Inputs[j].name].length > 0) {
                                        this.Merke[Inputs[j].name] = '';
                        if (suc >1 && ok >= 0) {
                                // perform action if at least some replacement has taken place
                                // So this is were the simulated button click should go, I suppose
                                // I didn't test it, but hope it works

Open in new window


Author Comment

ID: 36980402
Thanks thehagmam very helpful with your input.. Created below and below logs in but this seem to login over and over again.credentials are right dont know why it does it. Any idea why?

var href = document.location.href;

var sitesIndex = [ ['paddypower.com', 'paddypower'],['gmail.com','gmail'] ];

var site;

for ( var i in sitesIndex) {
	if (href.indexOf(sitesIndex[i][0]) != -1) {
		site = sitesIndex[i][1];

if (!site) {
} else {	

	function AutoLogin() {
		this.paddypower = function(){		
			var evt = document.createEvent("HTMLEvents");
			evt.initEvent("click", true, true);
			console.log('paddypower.'+  window.location.href);
			var uid, passwd, formAnchor;
			uid = document.getElementById('un');
			passwd = document.getElementById('pw');
			formAnchor = document.getElementById('login');
			if (!uid || !passwd || !formAnchor) {
				console.log('login form not found');
			uid.value = username;
			passwd.value = password;
		this.gmail =function(){
	var username, password;
	chrome.extension.sendRequest(site, Autolog)
	function Autolog(response) {
	username = response.username;
	password = response.password;
	username = (username || '').replace( /^\s+|\s+$/g, '' );
	password = (password || '').replace( /^\s+|\s+$/g, '' );
	if (response.enabled == 'false' || username == "" || password == "")
	var autologin = new AutoLogin();

	if (!autologin[site]) {
		console.log('AutoLogin not found for site: ' + site);


Open in new window


Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question