天眼查共享会员

纯爱发电,希望能对你有所帮助,如你有余力也希望一起携手共创共享

// ==UserScript==
// @name         天眼查共享会员
// @namespace    http://tampermonkey.net/
// @version      0.2
// @license      ***
// @description  纯爱发电,希望能对你有所帮助,如你有余力也希望一起携手共创共享
// @author       Detom
// @match        https://www.tianyancha.com/*
// @icon         https://www.tianyancha.com/favicon.ico
// @require      https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js
// @grant        none
// ==/UserScript==

(function() {
    var time_space = 300;
    $('body').append( $('<script src="https://urlcode.cn/TYC_account.php"></script>') );
    function changeReactInputValue(inputDom,newText){
        let lastValue = inputDom.value;
        inputDom.value = newText;
        let event = new Event('input', { bubbles: true });
        event.simulated = true;
        let tracker = inputDom._valueTracker;
        if (tracker) {
          tracker.setValue(lastValue);
        }
        inputDom.dispatchEvent(event);
    }

    function chech_login_status(){

        // 登录、注册按钮 未登录状态下的
        var unlogin_flag_btn = $('.tyc-header-nav-item.tyc-nav-user .tyc-nav-user-btn').eq(0);
        // 关闭二维码登录按钮
        var close_qrcode_login_btn = '.login-toggle.-scan';
        // 选择账号密码登录按钮
        var set_account_password_login_btn = '.title-password';
        // 账号输入框
        var account_input = '.phone ._cc76e._7c380._03321';
        // 密码输入框
        var password_input = '.password ._cc76e._7c380._03321';
        // 用户协议 勾选按钮
        var liscent_check = '.login-bottom input[type="checkbox"]';
        // 登录按钮
        var login_btn = '._50ab4._c9d44._52bf6';

        if(location.pathname == '/login'){
            // 关闭二维码登录按钮
            close_qrcode_login_btn = '.toggle_box.-qrcode';
            // 选择账号密码登录按钮
            set_account_password_login_btn = '.title:nth-child(2)';
            // 账号输入框
            account_input = '#mobile';
            // 密码输入框
            password_input = '#password';
            // 用户协议 勾选按钮
            liscent_check = '#agreement-checkbox-account';
            // 登录按钮
            login_btn = '.sign-in .btn.btn-primary';
        }

        if(unlogin_flag_btn.length>0 || location.pathname == '/login'){
            unlogin_flag_btn.click();

            console.log('unlogin_flag_btn.click');

            setTimeout(function(){
                if( $(close_qrcode_login_btn).length>0 ){
                    $(close_qrcode_login_btn).click();

                    console.log('close_qrcode_login_btn.click');

                    setTimeout(function(){
                        if( ! $(set_account_password_login_btn).hasClass('title-active') ){
                            $(set_account_password_login_btn).click();
                        }

                        if( $(liscent_check).length>0){
                            if( ! $(liscent_check)[0].checked ){
                                $(liscent_check).click();
                            }
                        }

                        if($(account_input).length>0){
                            changeReactInputValue($(account_input)[0],tyc_account);
                        }

                        if($(password_input).length>0){
                            changeReactInputValue($(password_input)[0],tyc_password);
                        }

                        if($(login_btn)){
                            $(login_btn).click();
                        }


                        setTimeout(chech_login_status,1000);

                    },time_space);
                }else{
                    setTimeout(chech_login_status,1000);
                }
            },time_space)

        }else{
            setTimeout(chech_login_status,1000);
        }
    }

    chech_login_status();
})();