首頁  >  文章  >  web前端  >  geasemonkey自動登陸腳本如何設定

geasemonkey自動登陸腳本如何設定

一个新手
一个新手原創
2017-09-19 11:06:191228瀏覽

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