AutoLoginJu

Automatically submit autofilled login forms

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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);