AutoLoginJu

Automatically submit autofilled login forms

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
			
// @name AutoLoginJu
			
// @description Automatically submit autofilled login forms
			
// @version 1
			
// @include *
			

		
// @namespace https://greasyfork.org/users/4568
// ==/UserScript==		

			function submitFirstPasswordForm() {
				for (var elmForm, i=0; elmForm=document.forms[i]; ++i) {
				var numPasswordElements = 0;
				for (var j=0; elmFormElement=elmForm.elements[j]; ++j)
				if (elmFormElement.type == "password" &&
					elmFormElement.value &&
					elmFormElement.value.toLowerCase() != "password") {
				++numPasswordElements;
				}
				if (numPasswordElements != 1) { continue; }
				/*
				 * The obvious way to submit a login form is form.submit().
				 * However, this doesn't work with some forms, such as
				 * the Google AdWords login, because they do stuff
				 * in the onclick handler of the submit button. So we
				 * need to find the submit button and simulate a click.
				 */
				var elmSubmit = document.evaluate(".//input[@type='image']",
				elmForm, null, XPathResult.FIRST_ORDERED_NODE_TYPE,
				null).singleNodeValue;
				if (!elmSubmit) {
				elmSubmit = document.evaluate(".//input[@type='submit']",
				elmForm, null, XPathResult.FIRST_ORDERED_NODE_TYPE,
				null).singleNodeValue;
				   }
				   if (!elmSubmit) { continue; }
				   /*
				* Give a visual indication that we're auto-submitting the
				* form, then simulate a click on the submit button.
				*/
				   elmSubmit.focus();
				   elmSubmit.style.MozOutline = "2px solid purple";
				   elmSubmit.click();
				}
			}

			window.addEventListener("load", function() {
				/*
				 * Using setTimeout to give Firefox's password manager a chance
				 * to autofill the form.
				 */
				setTimeout(submitFirstPasswordForm, 0);
			}, false);