Greasy Fork is available in English.

初音的青葱Onedrive微云自动填充密码并点击

仅适用于特定网站

您查看的为 2020-06-19 13:30:12 UTC 提交的版本。查看 最新版本

// ==UserScript==
// @name         初音的青葱Onedrive微云自动填充密码并点击
// @namespace    http://tampermonkey.net/
// @version      2.0.1
// @description  仅适用于特定网站
// @author       aotmd
// @match        https://mkgal-my.sharepoint.com/*
// @match        https://www.mkgal.com/*
// @match		 https://share.weiyun.com/*
// @icon         https://www.mkgal.com/static/images/login.jpg
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_deleteValue
// ==/UserScript==

(function() {
	var setting = {
		//取不到值的默认密码
		"Onedrive默认密码": "MKFX",
		//过低将无法填充密码
		"微云延时": 500,
		//设置填充密码仅在www.mkgal.com点击链接时执行
		"网页限定": true,
	};
	window.onload = function() {
		var url = window.location.href;
		var str = /https:\/\/www\.mkgal\.com\/.+/i;
		var str2 = /https:\/\/mkgal-my\.sharepoint\.com\/.+/i;
		var str3 = /https:\/\/share\.weiyun\.com\/.+/i;
		if (str.test(url)) {
			var Onedrive = document.getElementsByClassName("pan")[0].getElementsByTagName("span")[0].innerText;
			var weiyun = document.getElementsByClassName("pan")[1].getElementsByTagName("span")[0].innerText;
			GM_setValue("Onedrive", Onedrive);
			GM_setValue("weiyun", weiyun);
		} else if (str2.test(url)) {
			if (str.test(document.referrer) == false && setting.前网页限定) {
				return;
			}
			if (GM_getValue('Onedrive') == null) {
				document.getElementById("txtPassword").value = setting.默认密码;
			} else {
				document.getElementById("txtPassword").value = GM_getValue('Onedrive');
				GM_deleteValue('Onedrive');
			}
			document.getElementById("btnSubmitPassword").click();
		} else if (str3.test(url)) {
			if (str.test(document.referrer) == false && setting.前网页限定) {
				return;
			}
			if (GM_getValue('weiyun') != null) {
				setTimeout(function() {
					/*自定义方法触发事件*/
					window.inputValue = function(dom, st) {
						var evt = new InputEvent('input', {
							inputType: 'insertText',
							data: st,
							dataTransfer: null,
							isComposing: false
						});
						dom.value = st;
						dom.dispatchEvent(evt);
					};
					var iput = document.getElementsByClassName("input-txt")[0];
					window.inputValue(iput, GM_getValue('weiyun'));
					GM_deleteValue('weiyun');
					document.getElementsByClassName("btn btn-l btn-main")[0].click();
				}, setting.微云延时);
			}
		}
	};
})();