AutoLoginJu

Automatically submit autofilled login forms

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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);