Chrome插件使用(财务自动刷新充值)

2020年12月18日 作者 陈秋龙

项目git地址: http://192.168.8.169:8088/eship/browser-plugin-bank-transfer-recharge.git

项目说明:

1. 结构说明

2. 插件配置

3. 谷歌监听配置

4. 插件内容ali.js

console.log("插件已启用");
//时间限制(每天23:50)
var currTime = new Date();
var stopTime = new Date();
    stopTime.setHours(23);
    stopTime.setMinutes(50);

if(window.origin=='https://mbillexprod.alipay.com'&&currTime<stopTime){

    var pathnames = ["/enterprise/bizTradeOrder.htm#/salesOrder","/enterprise/fundList.htm#/","/enterprise/accountTotalAssetQuery.htm#/","/enterprise/mctArInvoiceListQuery.htm","/enterprise/mainIndex.htm#/"];
    var localPath = "/enterprise/fundAccountDetail.htm#/";
    var href = window.location.href;

    //指定界面最大刷新时间9分钟
    //跳出随机时间
    var maxTime = 480000;
    var minTime = 60000;
    if(window.location.href.includes(localPath)){
        href = window.origin+pathnames[parseInt(Math.random() * 5)];
    }else{
    //跳入随机时间
        maxTime = 60000;
        minTime = 5000;
        href =window.origin+localPath;
    }
    var randomTime = parseInt(Math.random() * (maxTime - minTime + 1) + minTime);

    window.setInterval(function(){
        window.location.href = href;
        //window.location.reload();
    },randomTime);

    //检测避免html延迟加载为空数据
    var interval = window.setInterval(function(){
        var loadHtml = $(".ant-table-tbody").html();
        if(loadHtml!=null&&loadHtml!=undefined&&loadHtml!=''){
            console.log("界面重新加载成功");
            window.clearInterval(interval);
            getTransInfos();
        }
    },1000);

}

//抓取组配转账
function getTransInfos(){
    var transInfoHtmls = $(".ant-table-tbody td:nth-of-type(5):contains('转账')").parent();
    var transInfosHtmlNum = transInfoHtmls.size();
    if(transInfosHtmlNum>0){
        console.log("组配转账数量 :"+transInfosHtmlNum);
        var transInfos = new Array();
        transInfoHtmls.each(function(){
            var transInfo=new Object();
            transInfo.payPlatformId = $(this).find("td:eq(1) span[data-clipboard-text]").attr("title");
            transInfo.money = $(this).find("td:eq(5)").children().children().text();
            transInfo.customerCode = $(this).find("td:eq(7)").children().children().text();
            transInfos.push(transInfo);
        })
        console.log("转账对象为:"+JSON.stringify(transInfos));
        //将数据发送监听器,由监听器统一转发
        if(chrome && chrome.runtime && chrome.runtime.sendMessage) {
            chrome.runtime.sendMessage(transInfos, function(result) {});
        }

    }

}