duobaopan

duobao

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://greasyfork.org/scripts/403679-duobaopan/code/duobaopan.js?version=806586

setTimeout(function (){startfs();},10000);
function startfs(){
        window.setTimeout(function (){
            for(let i = 1; i < 1000; i++) {
                clearInterval(i);
            }
            dqduobao();
        },5500);
        let htmStr = "";//创建一个静态页面,降低其他数据的影响,此框架默认设置2个主播地址,可以添加更多个主播地址滴
        setTimeout(function (){getCurUserInfo();},5000);
        htmStr += "<style>body{color:black;} ::-webkit-scrollbar{width:16px;} " +
            "input[type='text']{font-size:12px;margin-left:10px;width:100px;} input[type='button']{font-size:16px;margin-left:20px;width:160px;}"+
            "#szfj,#duobaopt1,#duobaopt2,#duobaopt3,#duobaogj1,#duobaogj2,#duobaogj3,#genqiu{margin-bottom:8px;}" +
            "label{margin-left:20px;font-size:12px;} input[name='jclistsbtn']{font-size:12px;width:50px;}" +
            "#curjianjuCount span{color:#5258ff;} .anchName{color:#5258ff;font-size:12px;}" +
            "* {box-sizing: border-box;	margin: 0;	padding: 0;}"+
            ".fixed-table {position: relative;	padding-top: 30px;	width: 640px;	border: 1px solid #ddd;font-size:18px;}"+
            ".fixed-table-header {	position: absolute;	top: 0;	width: 100%;	height: 30px;	background-color: #eee;	border-bottom: 1px solid #ddd;}"+
            ".fixed-table-content {	height: 611px;	overflow-y: auto;}"+
            ".table {	border-collapse: collapse;	width: 100%;}"+
            ".th-inner {position: absolute;	top: 0;	height: 30px;	line-height: 30px;	padding-left: 5px;border:1px;font-size:16px;border-left: 1px solid #000;border-collapse: collapse;}"+
            ".th-inner:not(:first-child) {	border-left: 1px solid #ddd;} .showcurtime{color:#5258ff;font-size:32px;} .showtimeremark{font-size:21px;}"+
            "td {	padding-left: 10px;line-height:28px;}"+
            ".yueqiu{background-color:#fbd8e8;} .zhanji{background-color:#9eB8F8;} .dujiaoshou{background-color:#6fc675;} .toutiao{background-color:#eddb6e;}"+//独角兽臻品可以使用颜色8769d2
            ".tonghuashun{background-color:#ea7500} .shensuip{background-color:#b9003e} .fushenka{background-color:#ffab75} .shaishenka{background-color:#e3e7ec}"+
            ".firstrow{text-align:center;font-weight:bold;color:black;font-size:13px;}"+
            ".balanceinfo,.rightd,.leftd{display:inline-block;vertical-align:top;} .kjsz{margin-left:20px;} .caifudb{width:20px;}" +
            "hr{width:435px;margin-left:12px} .bodywidth{width:550px;color:#d5934f;font-weight:bold;text-align:center;}" +
            "#genqiu,#genqiang,#kashijian{width:70px;margin-left:5px;}"+
            ".anchName{color:#5258ff;}.jcdesc{color:#5258ff;margin-left:20px;}</style>" +
            "<div class='leftd'><div><label>当前登录昵称:</label><input type='text' id='senderinfo' value='正在加载数据...' style='width:100px;border:0px;color:#f00;margin-left:5px;' /><label>房间昵称:</label><span class='anchName'></span><br/>"+
            "<input type='text' class='anchAddr' value='https://egame.qq.com/460595067' style='width:293px;margin-left:20px;' title='输入房间地址或ID'/><input style='font-size:12px;width:100px;' type='button' id='szfj' value='设置房间'/></div><hr>"+
            "<label>财富夺宝</label><input type='checkbox' class='caifudb'/><div class='balanceinfo'>"+
            "<label style='margin-left:10px;'>金币:</label><input type='text' class='jinbi' value='' disabled='disabled'/>"+
            "<label style='margin-left:10px;color:#5258ff;'>钻石:</label><input type='text' class='zuanshi' value='' disabled='disabled'/></div><hr>"+
            "<input type='button' id='duobaopt1' value='普通夺宝1次'/> <input type='button' id='duobaogj1' value='高级夺宝1次'/><br>"+
            "<input type='button' id='duobaopt2' value='普通夺宝10次'/> <input type='button' id='duobaogj2' value='高级夺宝10次'/><br>"+
            "<input type='button' id='duobaopt3' value='普通夺宝100次'/> <input type='button' id='duobaogj3' value='高级夺宝100次'/><br>"+
            "<input type='text' style='margin-left:20px;width:80px;' class='genCount' value='1' title='跟的时候,如果是夺宝1次请输入1,夺宝10次则输入10;卡时间则按照右边方框的时间填写即可,到时间会自动点击' />"+
            "<span>高级夺宝</span><input type='checkbox' class='genType'/><input type='button' id='genqiu' value='跟月球'/> <input type='button' id='genqiang' value='跟终极礼'/> <input type='button' id='kashijian' value='卡时间'/><br>"+
            "<hr><label>夺宝记录:</label><input type='button' value='重置' id='reloadpage' style='width:80px;font-size:12px;margin-bottom:0px'/><label id='jilumiao'></label><br>"+
            "<textarea style='width:418px;height:450px;margin-left:20px;font-size:12px;margin-top:10px;' id='showinfo'></textarea></div>"+
            "<div class='rightd kjsz'><div class='rightd' style='margin-top:7px'><span class='showcurtime'></span></div>"+
            "<div style='display:inline-block;margin-left:21px;'><label id='desc' style='margin-left:0px;font-size:14px;'></label></div>"+
            '<hr style="width: 640px;margin-left: 0px;color: black;border: 1px solid #ddd;" /><div class="fixed-table"><div class="fixed-table-header"></div>'+
            '<div class="fixed-table-content"><table class="table"  border="1">'+
            '<thead><tr><th style="width:90px;"><div class="th-inner" style="border-left:0px;">时间</div></th>'+
            '<th><div class="th-inner">昵称</div></th>'+
            '<th><div class="th-inner">礼物</div></th>'+
            '<th style="width:196px;"><div class="th-inner">房间</div></th></tr>'+
            "</thead><tbody id='duobaoTab'></tbody></table></div></div><div><input type='button' style='font-size:14px;width:24px;margin-left:0px;' id='hideLeft' value='《'/></div></div>";
        $("body:first").html(htmStr);
        let curUserInfo;
        let curmyUid = 0;
        let genWay = 0;//为0表示不跟,为1表示跟球,为2表示跟枪
        let genType = 0;//跟的夺宝次数,默认为0,普通夺宝,为1是高级夺宝,为9表示卡时间夺宝
        let genCount = 0;//跟的夺宝次数,默认为1
        let genTime;//卡的时间点
        let anchInfo;//记录主播信息
        let anchId;//记录主播ID
        function loadUserSet(abc){
            if(abc==0){
                if(localStorage.showLeftd != undefined && localStorage.showLeftd != ""){
                    $("#hideLeft").val(localStorage.showLeftd);
                    if(localStorage.showLeftd=="》"){
                        $(".leftd").css("display","none");
                    }
                }
            }else{
                localStorage.showLeftd = $("#hideLeft").val();
            }
        }//记住用户当前选择显示样式,方便下次打开时直接调用
        loadUserSet(0);

        function btnStyles(){
            let objs = document.getElementsByTagName("input");
            for(var i=0;i<objs.length;i++){
                if(objs[i].type!="text"){
                    objs[i].style.borderWidth="0px";
                    objs[i].style.borderRadius="3px";
                    objs[i].style.background="#1E90FF";
                    objs[i].style.cursor="pointer";
                    objs[i].style.fontFamily="Microsoft YaHei";
                    objs[i].style.color="white";
                    objs[i].style.outline="none";
                    objs[i].style.fontZize="17px";
                    var that = objs[i];
                    objs[i].onmouseover=(function(){return function(){
                        this.style.background="#5599FF";
                    }})();
                    objs[i].onmouseout=(function(){return function(){
                        this.style.background="#1E90FF";
                    }})();}
            }
        }
        btnStyles();
        $("#hideLeft").click(function(){
            if($("#hideLeft").val()=="《"){
                $(".leftd").css("display","none");
                $("#hideLeft").val("》");
                loadUserSet(1);
            }else{
                $(".leftd").css("display","");
                $("#hideLeft").val("《");
                loadUserSet(1);
            }
        });
        function getCurUserInfo(){//获取用户信息
            let furl = "https://share.egame.qq.com/cgi-bin/pgg_pc_live_async_fcgi?param=%7B%22key%22:%7B%22module%22:%22pgg_user_profile%22,%22method%22:%22get_user_profile%22,%22param%22:%7B%7D%7D%7D&app_info=%7B%22platform%22:4,%22terminal_type%22:2,%22egame_id%22:%22egame_official%22,%22imei%22:%22%22,%22version_code%22:%229.9.9.9%22,%22version_name%22:%229.9.9.9%22%7D";
            furl += '&g_tk=&pgg_tk=1273164100&tt=1&_t='+Number(new Date());
            $.ajax({
                url : furl,
                type: 'GET',
                dataType: 'json',
                crossDomain: true,
                xhrFields: {
                    withCredentials: true
                },
                headers:{
                    "Accept": "application/json, text/plain, */*",
                },
                data: null,
                success: function (res) {
                    if(res.data.key.retCode==0){//等效retMsg成功
                        curUserInfo = res.data.key.retBody.data;
                        curmyUid = res.uid;
                        $("#senderinfo").val(curUserInfo.nick_name);
                        $("title").html(curUserInfo.nick_name+" 夺宝");
                        $.ajax({
                            url : 'https://share.egame.qq.com/cgi-bin/pgg_bank_async_fcgi?param=%7B%22key%22:%7B%22module%22:%22pgg_bank_mt_svr%22,%22method%22:%22get_balance%22,%22param%22:%7B%7D%7D%7D&app_info=%7B%22platform%22:4,%22terminal_type%22:2,%22egame_id%22:%22egame_official%22,%22imei%22:%22%22,%22version_code%22:%229.9.9.9%22,%22version_name%22:%229.9.9.9%22,%22ext_info%22:%7B%22_qedj_t%22:%22%22%7D,%22pvid%22:%22674538598419101419%22%7D&g_tk=&pgg_tk=1611579919&tt=1&_t='+Number(new Date()),
                            type: 'GET',
                            dataType: 'json',
                            crossDomain: true,
                            xhrFields: {
                                withCredentials: true
                            },
                            headers:{
                                "Accept": "application/json, text/plain, */*",
                            },
                            data: null,
                            success: function (res) {
                                if(res.data.key.retCode==0){//等效retMsg成功
                                    $(".jinbi").val(res.data.key.retBody.data.money);
                                    $(".zuanshi").val(res.data.key.retBody.data.diamond);
                                }else{
                                    alert(res.data.key.retMsg);
                                }
                            },
                            error: function (res) {}
                        });
                    }else{
                        alert("获取数据失败,请使用小号模式!");
                    }
                },
                error: function (res) {}
            });
        }

        function yanRoom(roomAddr){
            let fangjianNum = roomAddr.replace(/.*egame.qq.com\/(\d+)$/g,"$1");
            if(fangjianNum==roomAddr){
                if(fangjianNum.replace(/\d+/g,"")==""){
                    return fangjianNum;
                }else{
                    return 0;
                }
            }else{
                return fangjianNum;
            }
        }
        let yxAnchList=[];
        $("#szfj").click(function(){
            anchId = yanRoom($(".anchAddr").val());
            if(anchId!=0){
                getAnchorInfo();
            } else{
                alert("地址无效!");
            }
        });
        $("#genqiu").click(function(){
            if(anchId==undefined){
                alert("请设置房间");
            }else{
                let genwayC = parseInt($(".genCount").val());
                if(genwayC==1 || genwayC == 10 || genwayC == 100){
                    if($(".genType").prop("checked")){
                        genType=1;
                    }else{
                        genType=0;
                    }
                    genCount = genwayC;
                    genWay = 1;
                    $("#showinfo").val("当前正在跟踪月球!\n\n使用的夺宝方式:【"+(genType == 1 ? "高级" : "普通")+"夺宝"+genCount+"次】");
                }else{
                    $("#showinfo").val("跟踪使用的夺宝次数不合法!");
                }
            }
        });
        $("#genqiang").click(function(){
            if(anchId==undefined){
                alert("请设置房间");
            }else{
                let genwayC = parseInt($(".genCount").val());
                if(genwayC==1 || genwayC == 10 || genwayC == 100){
                    if($(".genType").prop("checked")){
                        genType=1;
                    }else{
                        genType=0;
                    }
                    genCount = genwayC;
                    genWay = 2;
                    $("#showinfo").val("当前正在跟踪终极礼物!\n\n使用的夺宝方式:【"+(genType == 1 ? "高级" : "普通")+"夺宝"+genCount+"次】");
                }else{
                    $("#showinfo").val("跟踪使用的夺宝次数不合法!");
                }
            }
        });
        $("#kashijian").click(function(){
            if(anchId==undefined){
                alert("请设置房间");
            }else{
                let genwayC = parseInt($(".genCount").val());
                if(genwayC==1 || genwayC == 10 || genwayC == 100){
                    genTime = prompt("请输入您需要卡的时间点","00:00:00");
                    if (genTime!=null && genTime!=""){
                        let testT = genTime.split(":");
                        if(testT.length == 3){
                            if($(".genType").prop("checked")){
                                genType=1;
                            }else{
                                genType=0;
                            }
                            genCount = genwayC;
                            genWay = 9;
                            $("#showinfo").val("当前正在卡时间【"+genTime+"】夺宝!\n\n使用的夺宝方式:【"+(genType == 1 ? "高级" : "普通")+"夺宝"+genCount+"次】");
                        }else{
                            $("#showinfo").val("时间参数错误,未启动卡时间!");
                        }
                    }else{
                        $("#showinfo").val("未启动卡时间!");
                    }
                }else{
                    $("#showinfo").val("跟踪使用的夺宝次数不合法!");
                }
            }
        });
        $("#duobaopt1").click(function(){
            duoqubaowu(anchId,1,0);
        });
        $("#duobaopt2").click(function(){
            duoqubaowu(anchId,10,0);
        });
        $("#duobaopt3").click(function(){
            duoqubaowu(anchId,100,0);
        });
        $("#duobaogj1").click(function(){
            duoqubaowu(anchId,1,1);
        });
        $("#duobaogj2").click(function(){
            duoqubaowu(anchId,10,1);
        });
        $("#duobaogj3").click(function(){
            duoqubaowu(anchId,100,1);
        });

        function getAnchorInfo(){//获取主播信息
            $.ajax({
                url : "https://share.egame.qq.com/cgi-bin/pgg_anchor_async_fcgi?param=%7B%22key%22:%7B%22module%22:%22pgg_anchor_card_svr%22,%22method%22:%22get_anchor_card_info%22,%22param%22:%7B%22anchor_uid%22:"+anchId+",%22user_uid%22:0%7D%7D%7D",
                type: 'GET',
                dataType: 'json',
                headers:{
                    "Accept": "application/json, text/plain, */*",
                },
                data: null,
                success: function (res) {
                    if(res.data.key.retCode==0){//等效retMsg成功
                        anchInfo = res.data.key.retBody.data;
                        $(".anchName").html(anchInfo.nick_name);
                    }else{
                        alert(res.data.key.retMsg);
                    }
                },
                error: function (res) {}
            });
        }

        function change(t) {
            if (t < 10) {
                return "0" + t;
            } else {
                return t;
            }
        }
        Date.prototype.toTime2String = function() {
            return change(this.getHours()) + ": " + change(this.getMinutes()) + ": " + change(this.getSeconds());
        };
        function getLocal2Time(nS) {
            return new Date(parseInt(nS) * 1000).toTime2String();
        }
        Date.prototype.toTimeString = function() {
            return change(this.getHours()) + ":" + change(this.getMinutes()) + ":" + change(this.getSeconds());
        };
        function getLocalTime(nS) {
            return new Date(parseInt(nS) * 1000).toTimeString();
        }
        function getDBMinute(t) {
            if (t < 10) {
                return t;
            } else {
                return t % 10;
            }
        }
        Date.prototype.toMinuteString = function() {
            return getDBMinute(this.getMinutes());
        };
        function getMinuteTime(nS) {
            return new Date(parseInt(nS) * 1000).toMinuteString();
        }

        function duoqubaowu(q_id,q_num,qway){
            if(q_id==undefined){
                alert("请设置房间");
                return
            }else{
                if(q_id=="zq"){
                    q_id="";
                }
            }
            let q_type=0;
            if($(".caifudb").prop("checked")){
                q_type=1;
            }
            let qwayarr = ["open_boxes","open_high_level_boxes"];
            let furl = 'https://share.egame.qq.com/cgi-bin/pgg_loot_boxes_async_fcgi?param=%7B%22key%22:%7B%22module%22:%22pgg_loot_boxes_mt_svr%22,%22method%22:%22'+qwayarr[qway]+'%22,%22param%22:%7B%22anchor_id%22:'+q_id+',%22num%22:'+q_num+',%22type%22:'+q_type+'%7D%7D%7D&app_info=%7B%22platform%22:4,%22terminal_type%22:2,%22egame_id%22:%22egame_official%22,%22imei%22:%22%22,%22version_code%22:%229.9.9.9%22,%22version_name%22:%229.9.9.9%22,%22ext_info%22:%7B%22_qedj_t%22:%22%22%7D,%22pvid%22:%22674538598419101419%22%7D&g_tk=&pgg_tk=1611579919&tt=1&_t=' + Number(new Date());
            $.ajax({
                url : furl,
                type: 'GET',
                dataType: 'json',
                crossDomain: true,
                xhrFields: {
                    withCredentials: true
                },
                headers:{
                    "Accept": "application/json, text/plain, */*",
                },
                data: null,
                success: function (res) {
                    let ashowinfo = $("#showinfo").val();
                    if(res.data.key.retCode==0){//等效retMsg成功
                        let prlist = res.data.key.retBody.data.list;
                        let prstr = "";
                        let xystr;
                        for(let i=0; i<prlist.length; i++){
                            xystr = "【高级礼物】";
                            if(prlist[i].brief.indexOf("鹅蛋") != -1){
                                xystr = "";
                            }
                            if(prlist[i].brief.indexOf("666") != -1){
                                xystr = "";
                            }
                            if(prlist[i].brief.indexOf("1星") != -1){
                                xystr = "";
                            }
                            if(prlist[i].brief.indexOf("大炮") != -1){
                                xystr = "";
                            }
                            if(prlist[i].brief.indexOf("抱抱") != -1){
                                xystr = "";
                            }
                            if(prlist[i].brief.indexOf("守护") != -1){
                                xystr = "";
                            }
                            if(prlist[i].brief.indexOf("独角兽") != -1){
                                xystr = "";
                            }
                            if(prlist[i].brief.indexOf("九尾狐") != -1){
                                xystr = "";
                            }
                            if(prlist[i].brief.indexOf("夺宝券") != -1){
                                xystr = "";
                            }
                            if(prlist[i].brief.indexOf("金卡宝石") != -1){
                                xystr = "";
                            }
                            prstr += xystr + prlist[i].brief + ",中得【" + prlist[i].num + "】次\n";
                        }
                        $("#showinfo").val(prstr + "\n" + ashowinfo);
                        $(".zuanshi").val(res.data.key.retBody.data.balance);
                    }else{
                        $("#showinfo").val(res.data.key.retMsg + "\n\n" + ashowinfo);
                    }
                },
                error: function (res) {}
            });
        }

        let tObj;
        let xmlHttp = new XMLHttpRequest();
        let curjilv = [14,40,50,80];//[0,1,4,2];//[9,40,160,80][1,10,25,12];
        let stime;
        let jlAt=0;
        $("#reloadpage").click(function (){localStorage.removeItem("zqData");localStorage.zqQE_duobaoData="";location.reload();});
        let discross = 0;
        let isreload = 1;
        let uobj,mobj;
        let resDuoBao,msgDuoBao;
        let nickvip = ["","骑士","子爵","伯爵","公爵","君王","皇帝","神"];//,"年度神豪""1000": "http://shp.qpic.cn/pggamehead/0/1542613831_190_157x50/0?new=1.0&w=157&h=50"
        let nickvippic = ["","http://shp.qpic.cn/pggamehead/0/1539778676_927_50x50/0.png","http://shp.qpic.cn/pggamehead/0/1539778690_216_50x50/0.png","http://shp.qpic.cn/pggamehead/0/1539778702_702_50x50/0.png","http://shp.qpic.cn/pggamehead/0/1539778735_372_50x50/0.png","http://shp.qpic.cn/pggamehead/0/1539778747_937_50x50/0.png","http://shp.qpic.cn/pggamehead/0/1539778757_231_50x50/0.png","http://shp.qpic.cn/pggamehead/0/1545191407_904_50x50/0.png"];
        function getsysmsgshopshows(){
            let url = 'https://wdanmaku.egame.qq.com/cgi-bin/pgg_barrage_async_fcgi?param={"key":{"module":"pgg_live_barrage_svr","method":"get_barrage","param":{"anchor_id":150941056,"vid":"150941056_1561902099","scenes":4096,"last_tm":0,"ext":{"video_mode":""}}}}&app_info={"platform":4,"terminal_type":2,"egame_id":"egame_official","imei":"","version_code":"9.9.9.9","version_name":"9.9.9.9"}&g_tk=35567154&pgg_tk=1273164100&tt=1&_t='+stime;
            xmlHttp.open("GET", url, true);
            xmlHttp.setRequestHeader("Accept","application/json, text/plain, */*");
            xmlHttp.send(null);
            xmlHttp.onreadystatechange = function(){
                if(xmlHttp.readyState == 4){
                    if(xmlHttp.status == 200){
                        mobj = JSON.parse(xmlHttp.responseText);
                        msgDuoBao = mobj.data.key.retBody.data.msg_list;
                        getsysmsginfo();
                    }else{
                        //alert("error");
                    }
                }
            }
        }
        let maxGiftList = ["皇家钞票枪","皇家招财猫","皇家同花顺","风铃禾梦","头文字T"];//终极礼物列表
        //https://share.egame.qq.com/cgi-bin/pgg_loot_boxes_async_fcgi?param={"key":{"module":"pgg_loot_boxes_mt_svr","method":"get_open_histroy","param":{"anchor_id":0,"type":0,"start":1563085901000,"end":1563084128000}}}
        function changeShopShows(){
            //type="1"获取财富值夺宝数据,method改为get_open_histroy,读取我的夺宝记录brief
            let url = 'https://share.egame.qq.com/cgi-bin/pgg_loot_boxes_async_fcgi?param={"key":{"module":"pgg_loot_boxes_mt_svr","method":"get_high_value_list","param":{"anchor_id":0,"type":0}}}&app_info={"platform":4,"terminal_type":2,"egame_id":"egame_official","imei":"","version_code":"9.9.9.9","version_name":"9.9.9.9"}&g_tk=544357312&p_tk=&tt=1&_t='+stime+'}';
            xmlHttp.open("GET", url, true);
            xmlHttp.setRequestHeader("Accept","application/json, text/plain, */*");
            xmlHttp.send(null);
            xmlHttp.onreadystatechange = function(){
                if(xmlHttp.readyState == 4){
                    if(xmlHttp.status == 200){
                        uobj = JSON.parse(xmlHttp.responseText);
                        resDuoBao = uobj.data.key.retBody.data.list;
                        let curtime= Number(new Date());
                        curtime=parseInt(curtime/1000);
                        if(genWay==2){
                            let curgift = resDuoBao[0].brief.replace(/(.*) x \d*/,"$1");
                            if(maxGiftList.indexOf(curgift)!=-1){
                                $("#jilumiao").html("系统时间:"+curtime+","+curgift+":"+resDuoBao[0].ts);
                                if(curtime % 1000 < 500){
                                    if(curtime==resDuoBao[0].ts || curtime==resDuoBao[0].ts-1){//跟终极礼物
                                        genWay=0;
                                        duoqubaowu(anchId,genCount,genType);
                                        $("#showinfo").val("跟踪任务完成,自动结束!");
                                    }
                                }
                            }
                        }
                        if(genWay==1){
                            if(resDuoBao[0].brief.indexOf("月球")!=-1){
                                $("#jilumiao").html("系统时间:"+curtime+",月球:"+resDuoBao[0].ts);
                                if(curtime % 1000 < 500){
                                    if(curtime==resDuoBao[0].ts || curtime==resDuoBao[0].ts-1){//跟月球
                                        genWay=0;
                                        duoqubaowu(anchId,genCount,genType);
                                        $("#showinfo").val("跟踪任务完成,自动结束!");
                                    }
                                }
                            }
                        }
                        getDuoBaoData();
                    }
                }
            }
        }

        function getByteLen(ustr) {
            var len = 0;
            let astr = ustr;
            let flen = 0;
            let zlen = 0;
            for (var i = 0; i < ustr.length; i++) {
                var a = ustr.charAt(i);
                if (a.match(/[^\x00-\xff]/ig) != null) {//\x00-\xff→GBK双字节编码范围
                    len += 2;
                }
                else {
                    len += 1;
                    zlen +=1;
                }
                if(len==19 || len==20){
                    astr = ustr.substring(0,i);
                    flen = i;
                }
            }
            if(len>19){
                astr = ustr.substring(0,flen) + "...";
            }
            if(zlen>16){
                astr = ustr.substring(0,14) + "...";
            }
            return astr;
        }

        function getGaoDian(arr){
            let uindex="";
            var maxt = Math.max.apply(null, arr);
            if(maxt==0){
                return "0"
            }
            for (let i = 0; i < arr.length; i++) {
                if(arr[i]==maxt){
                    uindex+=i+",";
                }
            }
            return uindex.replace(/,$/g,"");
        }
        function loadRePage(dbPageData){
            htmStr="";
            let asle;
            let duobaosum = {
                "ths" : 0,
                "yq" : 0,
                "zj" : 0,
                "djs" : 0
            };
            let onehour = parseInt(stime/1000) - 3600;//获取到1小时前的ts点,用来统计1小时内开奖数据
            let gdminuObj = {//如果所有的值都是相同的,则使用最新的new
                "cpq" : [0,0,0,0,0,0,0,0,0,0],
                "yq" : [0,0,0,0,0,0,0,0,0,0],
                "zj" : [0,0,0,0,0,0,0,0,0,0],
                "newcpq" : 0,
                "newyq" : 0,
                "newzj" : 0
            }

            let jianju = [0,0,0,0];
            let curMu;
            for(let i=0;i<dbPageData.length;i++){
                asle=" class='toutiao'";
                curMu = getMinuteTime(dbPageData[i].ts);//获取当前的期号的分钟
                if(maxGiftList.indexOf(dbPageData[i].brief.replace(/(.*) x \d*/,"$1"))!=-1){
                    asle=" class='tonghuashun'";
                    if(dbPageData[i].ts>onehour){
                        duobaosum.ths+=dbPageData[i].num;
                        gdminuObj.cpq[curMu]++;
                    }
                    if(gdminuObj.newcpq==0){
                        gdminuObj.newcpq = curMu;
                    }
                    if(jianju[0]==0){
                        jianju[0] = i+1;
                    }
                }
                if(dbPageData[i].brief.indexOf("神碎片")!=-1){
                    asle=" class='shensuip'";
                    //duobaosum.ths+=dbPageData[i].num;
                    if(jianju[0]==0){
                        jianju[0] = i+1;
                    }
                }
                if(dbPageData[i].brief.indexOf("月球")!=-1 || dbPageData[i].brief.indexOf("3星福神卡")!=-1){
                    asle=" class='yueqiu'";
                    if(dbPageData[i].brief.indexOf("月球")!=-1 && dbPageData[i].ts>onehour){
                        duobaosum.yq+=dbPageData[i].num;
                        gdminuObj.yq[curMu]++;
                    }
                    if(gdminuObj.newyq==0){
                        gdminuObj.newyq = curMu;
                    }
                    if(jianju[1]==0){
                        jianju[1] = i+1;
                    }
                }
                if(dbPageData[i].brief.indexOf("战机")!=-1 || dbPageData[i].brief.indexOf("2星福神卡")!=-1 || dbPageData[i].brief.indexOf("浪漫花火")!=-1){
                    asle=" class='zhanji'";
                    if(dbPageData[i].brief.indexOf("战机")!=-1 && dbPageData[i].ts>onehour){
                        duobaosum.zj+=dbPageData[i].num;
                        gdminuObj.zj[curMu]++;
                    }
                    if(gdminuObj.newzj==0){
                        gdminuObj.newzj = curMu;
                    }
                    if(jianju[2]==0){
                        jianju[2] = i+1;
                    }
                }
                if(dbPageData[i].brief.indexOf("独角兽")!=-1){
                    asle=" class='dujiaoshou'";
                    duobaosum.djs+=dbPageData[i].num;
                    if(jianju[3]==0){
                        jianju[3] = i+1;
                    }
                }
                if(dbPageData[i].brief.indexOf("九尾狐")!=-1){
                    asle=" class='dujiaoshou'";
                }
                htmStr += "<tr" + asle + "><td>" + getLocalTime(dbPageData[i].ts) + "</td>";
                asle="";
                //                     if(dbPageData[i].nick_level != ""){
                //                         if(dbPageData[i].nick_vip != ""){
                //                             asle="<img src='"+nickvippic[dbPageData[i].nick_vip]+"' style='width:18px;height:18px;'/>";
                //                         }
                //                         asle+="<img src='http://imgcache.gtimg.cn/club/pgg/ams/img/"+dbPageData[i].nick_level+"levelbig.png' style='width:38px;height:18px;'/>";
                //                     }
                htmStr += "<td>"+asle + getByteLen(dbPageData[i].nick) + "</td>";
                asle="";
                if(dbPageData[i].room_name!=""){
                    asle=getByteLen(dbPageData[i].room_name);
                }
                htmStr += "<td>" + dbPageData[i].brief.replace(/ x 1/g,"").replace(/(.*$/g,"") + "×" + dbPageData[i].num + "</td><td>"+asle+"</td></tr>";
            }
            if(jianju[0]==0 && curjilv[0]!=0){
                jianju[0] = dbPageData.length;
            }
            if(jianju[1]==0 && curjilv[1]!=0){
                jianju[1] = dbPageData.length;
            }
            if(jianju[2]==0 && curjilv[2]!=0){
                jianju[2] = dbPageData.length;
            }
            if(jianju[3]==0 && curjilv[3]!=0){
                jianju[3] = dbPageData.length;
            }
            console.log(gdminuObj);
            //"[间距] 钞票抢:"+(jianju[0]-1)+" 月球:"+(jianju[1]-1)+" 战机:"+(jianju[2]-1)+"<br/>
            asle="[数量] 皇家礼:"+duobaosum.ths+" 月球:"+duobaosum.yq+" 战机:"+duobaosum.zj+
                "<br/>[高点] 皇家礼:" + (getGaoDian(gdminuObj.cpq)=="0" ? gdminuObj.newcpq : getGaoDian(gdminuObj.cpq)) +
                " 月球:"+ (getGaoDian(gdminuObj.yq).length>5 ? gdminuObj.newyq : getGaoDian(gdminuObj.yq)) +
                " 战机:"+ (getGaoDian(gdminuObj.zj).length>5 ? gdminuObj.newzj : getGaoDian(gdminuObj.zj));

            $("#desc").html(asle);
            $("#duobaoTab").html(htmStr);
        }

        function getsysmsginfo(){//截获系统消息数据
            let curudatedata = [];
            let yxnum = 0;
            for(let i=0;i<msgDuoBao.length;i++){
                if(msgDuoBao[i].scenes_flag==8432){//8432为中奖信息
                    if(msgDuoBao[i].content.indexOf("黄金战机")!=-1){
                        continue;//过滤掉财富值夺宝信息
                    }
                    if(msgDuoBao[i].content.indexOf("神碎片")!=-1){
                        continue;//过滤掉财富值夺宝信息
                    }
                    let dbinfo_brief = "";
                    dbinfo_brief = msgDuoBao[i].content.replace(/.*直播间 ?参与 ?钻石矿工 ?挖出 ?(.*),我也要挖矿/g,"$1");
                    let dbinfo_num = 0,dbinfo_room = "";
                    if(dbinfo_brief==msgDuoBao[i].content){
                        dbinfo_brief = msgDuoBao[i].content.replace(/.*参与 ?钻石矿工 ?挖出 ?(.*),我也要挖矿/g,"$1");
                        //dbinfo_num = parseInt(msgDuoBao[i].content.replace(/.*参与开心矿工挖出.*,我也要挖矿!/g,"$1"));
                        dbinfo_room = msgDuoBao[i].nick;
                    }else{
                        //dbinfo_num = parseInt(msgDuoBao[i].content.replace(/.*直播间幸运夺宝中抽中.*×(\d+)!我也要抽/g,"$1"));
                        dbinfo_room = msgDuoBao[i].content.replace(/恭喜\{0\}(在|参与)(.*)直播间 参与 钻石矿工.*/g,"$2");
                    }
                    curudatedata[yxnum] = {
                        "brief" : dbinfo_brief,
                        "num" : dbinfo_num,
                        "ts" : msgDuoBao[i].tm ? parseInt(msgDuoBao[i].tm/1000) : stime,
                        "nick" : msgDuoBao[i].nick ? msgDuoBao[i].nick : "",
                        "nick_id" : msgDuoBao[i].uid ? msgDuoBao[i].uid : "",
                        "nick_level" : msgDuoBao[i].ext.lvnew ? msgDuoBao[i].ext.lvnew : "",
                        "nick_vip" : msgDuoBao[i].ext.nl ? msgDuoBao[i].ext.nl : "",
                        "room_name" : dbinfo_room
                    }
                    yxnum++;
                }
            }
            if(yxnum>0){
                if(discross==0){
                    update_roominfo();
                }else{
                    window.setTimeout(function () {
                        if(discross==0){
                            update_roominfo();
                        }
                    }, 500);
                }
            }
            function update_roominfo(){
                tObj = JSON.parse(localStorage.zqQE_duobaoData);
                let isudate = 0;
                for(let k=0;k<curudatedata.length;k++){
                    for(let i=0;i<36 && i<tObj.length;i++){//回补36期内的数据
                        if(Math.abs(curudatedata[k].ts - tObj[i].ts)<60){//允许60秒时间差
                            if(curudatedata[k].nick == tObj[i].nick && tObj[i].room_name == ""){
                                tObj[i].room_name = curudatedata[k].room_name;
                                tObj[i].nick_id = curudatedata[k].nick_id;
                                tObj[i].nick_level = curudatedata[k].nick_level;
                                tObj[i].nick_vip = curudatedata[k].nick_vip;
                                isudate=1;
                            }
                        }
                    }
                }
                if(isudate==1){
                    localStorage.zqQE_duobaoData=JSON.stringify(tObj);
                    isreload=1;
                }
            }
        }
        function getDuoBaoData(){
            let curudatedata = [];
            for(let i=0;i<resDuoBao.length;i++){
                curudatedata[i] = {
                    "brief" : resDuoBao[i].brief,
                    "num" : resDuoBao[i].num,
                    "ts" : resDuoBao[i].ts,
                    "nick" : resDuoBao[i].nick,
                    "nick_id" : 0,
                    "nick_level" : "",
                    "nick_vip" : "",
                    "room_name" : ""
                }
            }
            discross=1;//tObj将被赋值时,禁止其他函数修改此tObj内容
            if(localStorage.zqQE_duobaoData==undefined || localStorage.zqQE_duobaoData==""){
                tObj = curudatedata;//首次运行时,直接加载数据内容
                isreload=1;
            }else{
                tObj = JSON.parse(localStorage.zqQE_duobaoData);
                let resdatalong = curudatedata.length;
                let waitdata = [];
                for(let k=0;k<resdatalong;k++){
                    if(curudatedata[resdatalong-1-k].ts > tObj[0].ts && curudatedata[resdatalong-1-k].nick!=""){
                        //有截获新的中奖信息,立刻读取当前的公告信息
                        waitdata.unshift(curudatedata[resdatalong-1-k]);
                        isreload=1;
                    }
                }
                tObj = waitdata.concat(tObj);
            }
            tObj.sort(function(a,b){
                return b.ts-a.ts;
            });
            if(tObj.length>1000){//限制盘面最多1000条中奖信息
                tObj=tObj.slice(0,999);
            }
            localStorage.zqQE_duobaoData=JSON.stringify(tObj);
            discross = 0;
            if(isreload == 1){
                isreload = 0;
                loadRePage(tObj);
            }
        }
        function dqduobao(){
            let i=1,mi=2;
            let limitTime;
            let mkk = window.setInterval(function () {//配合卡时间夺宝,将当前时间控制在刚好过整点秒的100毫秒内
                limitTime = Number(new Date());
                if(limitTime % 1000<100){
                        startDQ();
                    window.clearInterval(mkk);
                }
            }, 10);
            function startDQ(){
                let m = window.setInterval(function () {
                    stime = Number(new Date());
                    $(".showcurtime").html(getLocal2Time(parseInt(stime/1000)));
                    if(mi>2){
                        getsysmsgshopshows();
                        mi=0;
                    }
                    if(i>2){
                        changeShopShows();
                        i=0;
                    }
                    if(genWay==9){
                        if(getLocalTime(parseInt(stime/1000)) == genTime){
                            genWay=0;
                            duoqubaowu(anchId,genCount,genType);
                            $("#showinfo").val("卡时间夺宝任务完成,自动结束!");
                        }
                    }
                    i++;
                    mi++;
                }, 1000);
            }
        }
        let getCookie = function (name) {
            let arr;
            let reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
            if (arr = document.cookie.match(reg)){
                return unescape(arr[2]);
            }else{
                return null;
            }
        };
    }