// ==UserScript== // @name 自动填写用户名和密码 // @namespace AutoLogin // @version 1 // @include https://XXX.XXX.XXX.XXX/login/requireLogin // @include https://XXX.XXX.XXX.XXX/login/requireLogin // @include https://XXX.XXX.XXX.XXX/accounts/login* // @grant none // ==/UserScript== var globalConfig = { 'siteList': [ { targetUrlRegex : new RegExp("^https:\/\/XXX.XXX.XXX.XXX\/login\/requireLogin$"), attributeName: 'id', usernameKey: 'username', usernameVal: '****', passwordKey: 'password', passwordVal: '****', }, { targetUrlRegex : new RegExp("^https:\/\/XXX.XXX.XXX.XXX\/accounts\/login.*\/$"), attributeName: 'id', usernameKey: 'username', usernameVal: '****', passwordKey: 'password', passwordVal: '****', }, { targetUrlRegex : new RegExp("^https:\/\/XXX.XXX.XXX.XXX\/(index\.php)?$"), attributeName: 'id', usernameKey: 'UserName', usernameVal: '****', passwordKey: 'UserPasswd', passwordVal: '****', }, { targetUrlRegex : new RegExp("^https:\/\/XXX.XXX.XXX.XXX\/SignIn.screen$"), attributeName: 'id', usernameKey: 'username', usernameVal: '****', passwordKey: 'password', passwordVal: '****', }, ] }; window.autologin = function() { var sitelist = globalConfig.siteList; if (!sitelist.length) { return; } //; var cur_url = window.location; //; for (var indx in sitelist) { var test = sitelist[indx].targetUrlRegex.test(cur_url); if (!test) { continue; } var inputs = document.body.getElementsByTagName('input'); // for (var i in inputs) { var input = inputs[i]; if (input[sitelist[indx].attributeName] == sitelist[indx].usernameKey) { input.value = sitelist[indx].usernameVal; } else if (input[sitelist[indx].attributeName] == sitelist[indx].passwordKey) { input.value = sitelist[indx].passwordVal; } } document.getElementsByTagName("form")[0].submit(); } } window.setTimeout("autologin()",1000);
以上是geasemonkey自动登陆脚本如何设置的详细内容。更多信息请关注PHP中文网其他相关文章!