目录
chrome书签JavaScript自动登录脚本
/      

chrome书签JavaScript自动登录脚本

javascript:
(function() {
    var url = location.host;
    var open_url = '';
    if (url != '') {
        window.open(open_url, '_blank');
    }

    //如果是登录页面,则自动登录
    if (location.href.indexOf('baidu.com/login.html') != -1) {
        var nativeInput = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value').set;
        // 定义事件
        var evt = new Event("input", {bubbles: true});
        var inputs = document.getElementsByTagName('input');
        nativeInput.call(inputs[0], 'admin');
        inputs[0].dispatchEvent(evt);
        nativeInput.call(inputs[1], '123456');
        inputs[1].dispatchEvent(evt);

        // 提交
        document.querySelector('button[type="submit"]').click();
      
        // 等待500毫秒,点击弹窗的关闭按钮; 根据实际情况
        setTimeout(() => {
            document.getElementsByTagName('button')[4].click();
        }, 500);

    }
})();

压缩后的代码:

javascript:(function(){var url=location.host;var open_url="";if(url!=""){window.open(open_url,"_blank")}if(location.href.indexOf("baidu.com/login.html")!=-1){var nativeInput=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value").set;var evt=new Event("input",{bubbles:true});var inputs=document.getElementsByTagName("input");nativeInput.call(inputs[0],"admin");inputs[0].dispatchEvent(evt);nativeInput.call(inputs[1],"123456");inputs[1].dispatchEvent(evt);document.querySelector('button[type="submit"]').click();setTimeout(()=>{document.getElementsByTagName("button")[4].click()},500)}})();

标题:chrome书签JavaScript自动登录脚本
作者:gitsilence
地址:http://blog.lacknb.cn/articles/2022/07/19/1658215635493.html