首页 >web前端 >js教程 >geasemonkey自动登陆脚本如何设置

geasemonkey自动登陆脚本如何设置

一个新手
一个新手原创
2017-09-19 11:06:191241浏览

// ==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中文网其他相关文章!

    声明:
    本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn