Greasy Fork 支持简体中文。

咕咕镇剩余价值收割机

斗争者的小助手

目前為 2020-09-12 提交的版本,檢視 最新版本

// ==UserScript==
// @name         咕咕镇剩余价值收割机
// @namespace    https://greasyfork.org/zh-CN/users/453092
// @version      2.30
// @description  斗争者的小助手
// @author       ikarosf
// @match        https://www.guguzhen.com/fyg_pk.php
// @match        https://www.guguzhen.com/fyg_shop.php
// @require      https://greasyfork.org/scripts/411259-%E5%BC%B9%E5%87%BA%E6%97%A5%E5%8E%86%E9%80%89%E6%8B%A9%E6%97%A5%E6%9C%9F%E6%8F%92%E4%BB%B6/code/%E5%BC%B9%E5%87%BA%E6%97%A5%E5%8E%86%E9%80%89%E6%8B%A9%E6%97%A5%E6%9C%9F%E6%8F%92%E4%BB%B6.js
// @resource     dateTimecss    https://greasyfork.org/zh-CN/scripts/411258-%E5%BC%B9%E5%87%BA%E6%97%A5%E5%8E%86%E9%80%89%E6%8B%A9%E6%97%A5%E6%9C%9F%E6%8F%92%E4%BB%B6%E7%9A%84css/code
// @connect      bbs.fygal.com
// @connect      kf.miaola.info
// @grant        GM_getResourceText
// @grant        GM_xmlhttpRequest
// @grant        unsafeWindow
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_addStyle
// @require      https://greasyfork.org/scripts/409864-url-gbk-%E7%BC%96%E7%A0%81%E8%A7%A3%E7%A0%81%E5%BA%93/code/URL%20GBK%20%E7%BC%96%E7%A0%81%E8%A7%A3%E7%A0%81%E5%BA%93.js?version=840815
// ==/UserScript==

function fyg_pk_html() {
    'use strict';
    var debugmode = false;
    var goxpanel= document.createElement('div');
    var goxpanelbottom= document.createElement('div');
    var detaillogpanel = document.createElement('div');
    var mask = document.createElement('div');
    var BattleLog = {}
    if(FM_getValue("BattleLog")!=null){
        console.log("BattleLog load")
        BattleLog = FM_getValue("BattleLog");
    }
    unsafeWindow.BattleLog = BattleLog;

    if(localStorage.getItem('dataReward')==null){
        localStorage.setItem('dataReward','{"sumShell":"0","sumExp":"0"}');
    }


    var goxing = false;
    var mainHost = "https://bbs.fygal.com/"
    if(localStorage.getItem('mainHost')!==null){
        mainHost = localStorage.getItem('mainHost');
    }

    var autogox=false;

    var maxap=999;
    var maxrank=999;
    if(localStorage.getItem('maxap')!==null){
        maxap = parseInt(localStorage.getItem('maxap'));
    }
    if(localStorage.getItem('maxrank')!==null){
        maxrank = parseInt(localStorage.getItem('maxrank'));
    }

    //var audio = new Audio("https://cdnringhlt.shoujiduoduo.com/ringres/user/a24/564/9246564.aac");
    //audio.load();

    var Num = 0;
    var goxNum = 0;
    var beike=0;
    var jingyan=0;
    if(localStorage.getItem('flashtime')===null){
        localStorage.setItem('flashtime',10 );
    }
    var maxtime = 10;

    maxtime = parseInt(localStorage.getItem('flashtime'));
    var time = maxtime;
    var myrank = -100;
    var myap=-100;
    var changeLog = [];
    let autoconfig = document.createElement('div');

    let autoconfigranklabel = document.createElement('i');
    autoconfigranklabel.innerText = "进度不低于:";
    autoconfig.appendChild(autoconfigranklabel);

    let autoconfigrank = document.createElement('input');
    autoconfigrank.setAttribute('type','text');
    autoconfigrank.setAttribute('oninput',"value=value.replace(/[^\\d]/g,'')");
    autoconfigrank.setAttribute('style',"width: 40px;margin-right:15px;");
    autoconfigrank.value = maxrank;
    autoconfigrank.onchange = function(){
        maxrank = autoconfigrank.value;
        autoconfigcheckbox.checked = false;
        localStorage.setItem('maxrank',maxrank );
    };
    autoconfig.appendChild(autoconfigrank);


    let autoconfigaplabel = document.createElement('i');
    autoconfigaplabel.innerText = "体力不低于:";
    autoconfig.appendChild(autoconfigaplabel);

    let autoconfigap = document.createElement('input');
    autoconfigap.setAttribute('type','text');
    autoconfigap.setAttribute('oninput',"value=value.replace(/[^\\d]/g,'')");
    autoconfigap.setAttribute('style',"width: 40px;margin-right:15px;");
    autoconfigap.value=maxap;
    autoconfigap.onchange = function(){
        maxap = autoconfigap.value;
        autoconfigcheckbox.checked = false;
        localStorage.setItem('maxap',maxap );
    };
    autoconfig.appendChild(autoconfigap);

    var autoconfigcheckboxdiv= document.createElement('div');
    let autoconfigcheckbox = document.createElement('input');
    autoconfigcheckbox.setAttribute('type','checkbox');
    autoconfigcheckboxdiv.appendChild(autoconfigcheckbox);

    let autoconfigcheckboxtext = document.createElement('i');
    autoconfigcheckboxtext.innerText = "自动搜刮";
    autoconfigcheckboxtext.setAttribute('style',"margin-right:20px;");
    autoconfigcheckboxdiv.appendChild(autoconfigcheckboxtext);


    function setflashtime(){
        var newtime = parseInt(prompt("新的刷新间隔:(填0则禁止刷新)",maxtime));
        if(!isNaN(newtime)&&newtime>0){
            localStorage.setItem('flashtime',newtime );
            maxtime = newtime;
            time = newtime;
            return;
        }
        if(!isNaN(newtime)&&newtime<=0){
            localStorage.setItem('flashtime',newtime );
            maxtime = -1;
        }
    }


    function setmainHost(){
        var newmainHost = prompt("格式如https://bbs.fygal.com/(填0则不获取对手系数)",mainHost);
        if(newmainHost!=null&&newmainHost!=""){
            localStorage.setItem('mainHost',newmainHost );
            mainHost = newmainHost;
        }
        show_battle_log("主站域名:"+mainHost)
    }

    //document.getElementsByClassName('panel panel-primary')[1].appendChild(autoconfig);

    let progresschange = document.createElement('div');
    progresschange.setAttribute('id','progresschange');
    progresschange.setAttribute('class','panel-body');
    //document.getElementsByClassName('panel panel-primary')[1].appendChild(progresschange);


    function getNowtime(){
        var date=new Date();
        var datetext = date.getHours()+":"+date.getMinutes()+":"+date.getSeconds();
        return datetext;
    }

    function dlog(text){
        if(debugmode){console.log(text)}
    }

    function getPostData(p1,p2){
        let data = -1;
        for(let s of document.getElementsByTagName('script')){
            let func = s.innerText.match(p1)
            if(func!=null){
                data = func[0].match(p2)[0];
                break;
            }
        }
        return data
    }

    function postRequest(){
        GM_xmlhttpRequest({
            method: 'POST',
            url: `https://www.guguzhen.com/fyg_read.php`,
            headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'},
            data: 'f=12',
            onload: response => {
                Num++;
                let newrank = parseInt(response.responseText.match(/class="fyg_colpz02" style="font-size:32px;font-weight:900;">[0-9]+%</)[0].match(/[0-9]+%/)[0]);
                let newap = parseInt(response.responseText.match(/class="fyg_colpz03" style="font-size:32px;font-weight:900;">[0-9]+</)[0].match(/>[0-9]+</)[0].slice(1,-1));
                if(myrank == -100){
                    myrank = newrank;
                }
                else if(newrank != myrank){
                    document.getElementsByClassName('fyg_colpz02')[0].innerText = newrank + "%";
                    changeLog.push(getNowtime()+"  "+myrank+"%->"+newrank + "%")
                    myrank = newrank;
                    //audio.play();
                    /*var my_url = location.href;
                    var newwin = window.open(my_url, '进度变动', 'resizable=no')*/
                }
                if(myap == -100){
                    myap = newap;
                }
                else if(newap != myap){
                    document.getElementsByClassName('fyg_colpz03')[0].innerText = newap;
                    myap = newap;
                }
                if(autoconfigcheckbox.checked&&newap>=10&&newrank>=1&&newap>=maxap&&newrank>=maxrank&&goxing==false){
                    maxtime = 1;
                    time = 1;
                    goxNum++;
                    let gox_data = getPostData(/gox\(\)\{[\s\S]*\}/m,/data: ".*"/).slice(7,-1);
                    goxing = true;
                    GM_xmlhttpRequest({
                        method: 'POST',
                        url: `https://www.guguzhen.com/fyg_click.php`,
                        headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'},
                        data: gox_data,
                        onload: response => {
                            goxing = false;
                            if(response.status === 200){
                                console.log(response.responseText);
                                if(response.responseText.slice(0,2)=='获得'){
                                    let info = response.responseText.slice(0,response.responseText.indexOf('<'));
                                    let div_info = document.createElement('div');
                                    div_info.innerText = info;
                                    changeLog.push(getNowtime() + " " + info)
                                    let dataReward = JSON.parse(localStorage.getItem('dataReward'));
                                    if(info.indexOf('贝壳')!=-1){
                                        beike++;
                                        dataReward.sumShell++;
                                    }
                                    else if(info.indexOf('经验')!=-1){
                                        jingyan++;
                                        dataReward.sumExp++;
                                    }
                                    localStorage.setItem('dataReward',JSON.stringify(dataReward));
                                    document.getElementsByClassName('btn-outline-secondary')[0].parentNode.appendChild(div_info);
                                }
                                else{
                                    let div_info = document.createElement('div');
                                    div_info.innerText = '段位进度不足';
                                    changeLog.push(getNowtime() + " " + '段位进度不足,搜刮失败')
                                    document.getElementsByClassName('btn-outline-secondary')[0].parentNode.appendChild(div_info);
                                }
                            }
                            else{
                                console.log('返回状态码非200')
                                changeLog.push(getNowtime() + " " + '返回状态码非200')
                                console.log(response.responseText);
                            }
                        },
                        onerror : function(err){
                            goxing = false;
                            console.log('发送搜刮请求出错')
                            changeLog.push(getNowtime() + " " + '发送搜刮请求出错')
                            console.log(err)
                        },
                        ontimeout : function(){
                            goxing = false;
                        }
                    });
                }else{
                    maxtime = parseInt(localStorage.getItem('flashtime'));
                    time = maxtime;
                    //console.log(123)
                }
                progresschange.innerText = getChangeLogText();
                /* else{
                    document.getElementsByClassName('fyg_colpz02')[0].innerText = newrank;
                }*/
            }
        });
    }
    function read_rank(){
        if(maxtime == -1){
            $("#goxtiptext").text("无刷新");
            return;
        }
        if(--time!=0){
            $("#goxtiptext").text("刷新进度倒计时 "+time);
        }else{
            $("#goxtiptext").text("刷新进度倒计时 "+0);
            time = maxtime;
            postRequest();
        }
    }

    function getChangeLogText(){
        let LogText = "";
        LogText += "刷新次数: " +Num + "\n";
        LogText += "[搜刮次数: " +goxNum +"] [贝壳:"+beike+"] [经验:"+jingyan+ "]\n";
        if(changeLog.length == 0){
            LogText += "未出现进度变动"
        }
        else{
            for(var i = 0;i<changeLog.length;i++){
                LogText += changeLog[i] + "\n"
            }
        }
        return LogText;
    }
    postRequest();
    setInterval(read_rank,"1000");


    var get_user_theard_try_num = 0;
    function show_battle_log(text){
        $("#goxtipbottomtext").text(text);
    }

    function get_user_theard(name,enemydiv){
        var search_name = $URL.encode(name);
        dlog(mainHost+'search.php'+name)
        show_battle_log('搜素帖子中')
        GM_xmlhttpRequest({
            method: "post",
            url: mainHost+'search.php',
            data: 'step=2&method=AND&sch_area=0&s_type=forum&f_fid=all&orderway=lastpost&asc=DESC&keyword=&pwuser='+search_name,
            headers:  {
                'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
            },
            onload: function(res){
                if(res.status === 200){
                    let info = res.responseText;
                    let firstindex = info.indexOf("共搜索到");
                    if(firstindex == -1){
                        if( info.indexOf("用户不存在")!=-1){
                            show_battle_log('用户'+name+'不存在');
                            get_user_theard_try_num = 0;
                            return;
                        }
                        if( info.indexOf("你所属的用户组不能使用搜索功能")!=-1){
                            show_battle_log('主站域名错误或无权限');
                            get_user_theard_try_num = 0;
                            return;
                        }
                        console.log('搜索尝试次数:' + get_user_theard_try_num)
                        if(info.indexOf("搜索排队中")!=-1&&get_user_theard_try_num<3){
                            get_user_theard_try_num++;
                            setTimeout(get_user_theard,2000,name,enemydiv)
                        }else{
                            //console.log(info)
                            get_user_theard_try_num = 0;
                            show_battle_log('找不到'+name+'的帖子,可能他未发过主题帖')
                        }
                        return;
                    }
                    let secondindex = info.indexOf("共搜索到",firstindex+1);
                    info = info.substring(firstindex,secondindex)
                    var theards=info.match(/read\.php.+?(?=" )/g)
                    get_user_mainpage(theards,enemydiv);
                }else{
                    show_battle_log('搜索对手帖子失败')
                    console.log(res)
                }
            },
            onerror : function(err){
                show_battle_log('搜索对手帖子错误,可能域名设置格式不正确')
                console.log(err)
            }
        });
    }

    function get_user_mainpage(theards,enemydiv){
        if(theards==null||theards.length<1){
            show_battle_log('找不到对手的帖子')
            return}
        show_battle_log('进入帖子中')
        var theard = theards[0];
        dlog(mainHost+theard)
        GM_xmlhttpRequest({
            method: "get",
            url: mainHost+theard ,
            headers:  {
                'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
            },
            onload: function(res){
                if(res.status === 200){
                    let info = res.responseText;

                    let firstindex = info.indexOf("楼主");
                    let afterinfo = info.substring(0,firstindex)
                    var mainpage=afterinfo.match(/profile\.php\?action=show.+?(?=" )/g)
                    if(mainpage==null||mainpage.length==0){
                        afterinfo = info.substring(0,firstindex+100)
                        mainpage=afterinfo.match(/\/user\/uid.+(?=" )/g)
                        get_user_LV(mainpage,enemydiv);
                    }else{
                        get_user_LV(mainpage,enemydiv);}
                }else{
                    show_battle_log('获取对手主页失败')
                    console.log(res)
                }
            },
            onerror : function(err){
                show_battle_log('获取对手主页错误')
                console.log(err)
            }
        });
    }


    function get_user_LV(mainpages,enemydiv){
        dlog(mainHost+mainpages[0])
        show_battle_log('进入主页中')
        if(mainpages==null||mainpages.length<1){
            show_battle_log('找不到对手的主页')
            return}
        var mainpage = mainpages[0];
        GM_xmlhttpRequest({
            method: "get",
            url: mainHost+mainpage ,
            headers:  {
                'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
            },
            onload: function(res){
                if(res.status === 200){
                    let info = res.responseText;
                    dlog(info)
                    let afterinfo = info.replace(/\<\/strong\>/g,'');
                    dlog(afterinfo)
                    var level = afterinfo.match(/(?<=神秘系数:)\d+/g)[0]
                    enemydiv.innerHTML = enemydiv.innerHTML.replace(enemydiv.innerText, '<a target="_blank" href='+mainHost+mainpage+'>'+enemydiv.innerText + "  Lv:" + level+ '</a>')
                    show_battle_log("获取对手系数成功")
                }else{
                    show_battle_log('进入对手主页失败')
                    console.log(res)
                }
            },
            onerror : function(err){
                show_battle_log('进入对手主页错误')
                console.log(err)
            }
        });
    }

    var mycssinner = function () {
        /*
       .tc_xs{
    width:30%;
    height:60%;
    line-height:3rem;
    background:#666;
    position:fixed;
    left:50%;
    margin-left:-15%;
    bottom:30%;
    text-align:center;
    color:#fff;
    border-radius:4px;
    display:none;
    z-index:10;
    }
    #mask{
        display:none;
        width:100%;
        height:300%;
        position:absolute;
        top:0;
        left:0;
        z-index:1;
        background-color:#000;
        opacity:0.3;
        }
    #goxpanel{
    width:20%;
    height:60%;
    min-width:270px;
    line-height:3rem;
    background:#ddf3f5;
    position:fixed;
    //left:10%;
    //margin-left:-15%;
    bottom:30%;
    text-align:center;
    color:#fff;
    border-radius:4px;
        }
    .goxtip{
        width:100%;
        background-color: #3280fc;
        padding: 2px 10px;
        text-align: left;
        display: flex;
        justify-content: space-between;
    }
    .goxtip button,input,select,textarea {
    font-family: inherit;
    font-size: inherit;
    line-height:normal;
    }
    .goxtipbottom{
        position:absolute;
        bottom:5px;
    }
    #goxtipinfo{
        color:#000;
        text-align: left;
        height: 90%;
    }
    .btn-details{
        width:30%
    }
    #goxpanel a{
    color:#FFF;
    }
    .battlelose>div {
    background-color: #ffe5e0 !important;
    }
        */
    }
    function mycss(){
        GM_addStyle(mycssinner.getMultilines());
    }
    function initgoxpanel(){
        $("body")[0].appendChild(goxpanel);
        goxpanel.setAttribute('id','goxpanel');
        goxpanel.style.setProperty('max-width', (document.body.clientWidth-1300)/2+'px');
        goxpanel.innerHTML = '<div id="goxtip" class="goxtip"><a id="goxtiptext" title="设置刷新间隔"></a> </div> <div id="goxtipinfo"></div><div id="goxtipbottom" class="goxtip goxtipbottom"><a id="goxtipbottomtext" title="设置主站域名"></a><input type="text" class="btn btn-details" placeholder="战斗历史" readonly="true" id="date"></div>'
        //goxpanel.setAttribute('style','display: none;overflow-y:auto;');
        $("#goxtip").append(autoconfigcheckboxdiv)
        $("#goxtipinfo").append(autoconfig);
        $("#goxtipinfo").append(progresschange);
        progresschange.style.setProperty("overflow-y","auto");
        progresschange.style.setProperty("max-height","90%");

        $("#goxtiptext").click(setflashtime);
        show_battle_log("主站域名:"+mainHost)
        $("#goxtipbottomtext").click(setmainHost);

        $("body")[0].appendChild(mask);
        mask.setAttribute('id','mask');
        mask.addEventListener('click', function(){
            $(".tc_xs").fadeOut();
            mask.style.display = "none";
        })
        $("body")[0].appendChild(detaillogpanel);
        detaillogpanel.setAttribute('class','tc_xs');
        detaillogpanel.setAttribute('style','display: none;overflow-y:auto;');
        var now = new Date()
        $("#date").datetime({
            type: "date",
            value: [now.getFullYear(), now.getMonth()+1, now.getDate()],
            active:Object.keys(BattleLog),
            success: function (res) {
                detaillogpanelset(res)
                $(".tc_xs").fadeIn();
                mask.style.display = "block";
            }
        })
    }

    function detaillogpanelset(key){
        var text = '';
        var divtext = '<div class="detaillogitem {0}">{1}</div>'
        var item = BattleLog[key];
        if(item===undefined){
            text+=divtext.format("","无数据");
        }else{
            var len=item.length;
            for(var i=len-1;i>=0;i--){
                var thisclass = '';
                if(item[i][1]){
                    thisclass="battlewin"
                }else {
                    thisclass="battlelose"
                }
                text+=divtext.format(thisclass,item[i][0]);
            }
        }
        console.log(text)
        detaillogpanel.innerHTML = text;
    }



    let observerBody1 = new MutationObserver(()=>{
        var pkTextDiv = document.querySelector("#pk_text");
        unsafeWindow.pkTextDiv = pkTextDiv;
        var enemydivs = pkTextDiv.querySelectorAll("h3.fyg_mp0");
        if(enemydivs==null||enemydivs.length<2){return;}
        var enemyinfo = pkTextDiv.querySelectorAll("div.col-md-6")[1];
        var isbattlewin = pkTextDiv.querySelectorAll(".icon-smile").length>0;

        var enemydiv = enemydivs[1];
        var enemyname = enemydiv.innerText;
        logupdate(enemyinfo,isbattlewin);
        if(enemyname.indexOf("等级 -")!=-1){return}
        if(mainHost!="0"){
            get_user_theard(enemyname,enemydiv);
        }

    });

    function logupdate(enemyinfo,isbattlewin){
        var etext = enemyinfo.innerHTML;
        var now = new Date();
        var key = now.toLocaleDateString();
        var a = BattleLog[key]
        if(a===undefined){
            BattleLog[key]=[];
            a = BattleLog[key]
        }
        a.push([etext,isbattlewin])
        FM_setValue("BattleLog",BattleLog)
        //updatelogpanel()
    }

    //——————————————————mainfun————————————
    unsafeWindow.get_user_theard = get_user_theard;
    observerBody1.observe(document.querySelector("#pk_text"), {characterData: true,childList: true});
    mycss();
    initgoxpanel();
}

function fyg_shop_html() {
    'use strict';
    var GachaLogPanel = document.createElement('div');
    var detaillogpanel = document.createElement('div');
    var mask = document.createElement('div');
    var hisdiv = null;
    var todaydiv = null;
    var GachaLog = {}
    if(FM_getValue("GachaLog")!=null){
        console.log("GachaLog load")
        GachaLog = FM_getValue("GachaLog");
    }
    unsafeWindow.GachaLog = GachaLog;



    unsafeWindow.tzzzdjl = function(text1,text2){
        logupdate(text1,text2)
        var tzzzdjl_t='<button class="btn btn-'+text2+' fyg_tc fyg_mp3" style="width:536px;"><i class="icon icon-bell-alt"></i> '+text1+'</button>';
        $("#tzzzjl").prepend(tzzzdjl_t);
    }

    function logupdate(text1,text2){
        var type = "";
        var count = 0;
        var now = new Date();
        count = parseInt(/\d+/.exec(text1)[0])
        if(text1.indexOf("星沙")!=-1){
            type="星沙";
        }
        else if(text1.indexOf("贝壳")!=-1){
            type="贝壳";
        }
        else if(text1.indexOf("BVIP")!=-1){
            type="BVIP";
        }
        else if(text1.indexOf("SVIP")!=-1){
            type="SVIP";
        }else{
            console.log("无类型!");
            return;
        }
        var key = now.toLocaleDateString();
        var a = GachaLog[key]
        if(a===undefined){
            GachaLog[key]=[];
            a = GachaLog[key]
        }
        a.push([type,count])
        FM_setValue("GachaLog",GachaLog)
        updatelogpanel()
    }


    var GachaLogPanelinner = function () {
        /*<div class="tab-2">
    <label for="tab2-1">历史</label>
    <input id="tab2-1" name="tabs-two" type="radio" checked="checked">
    <div class="detail">
     <div id="hisdiv">
    </div>

    </div>
             <input type="text" class="btn btn-lg btn-primary btn-details" placeholder="详细" readonly="true" id="date">
  </div>
  <div class="tab-2">
    <label for="tab2-2">今日</label>
    <input id="tab2-2" name="tabs-two" type="radio">
        <div class="detail">
     <div id="todaydiv">
    </div>
    </div>
  </div>
  */
    };
    var detaillogpanelinner = function () {
        /*
        提示消息
  */
    };
    function initGachaLogPanel(){
        $("body")[0].appendChild(detaillogpanel);
        detaillogpanel.setAttribute('class','tc_xs');
        detaillogpanel.setAttribute('style','display: none;overflow-y:auto;');
        $("body")[0].appendChild(mask);
        mask.setAttribute('id','mask');
        mask.addEventListener('click', function(){
            $(".tc_xs").fadeOut();
            mask.style.display = "none";
        })
        $(".panel-primary")[0].appendChild(GachaLogPanel);
        GachaLogPanel.setAttribute('class','tabs');
        GachaLogPanel.innerHTML = GachaLogPanelinner.getMultilines();
        hisdiv = $("#hisdiv")[0];
        unsafeWindow.hisdiv = hisdiv;
        todaydiv = $("#todaydiv")[0];
        var now = new Date()
        $("#date").datetime({
            type: "date",
            value: [now.getFullYear(), now.getMonth()+1, now.getDate()],
            active:Object.keys(GachaLog),
            success: function (res) {
                detaillogpanelset(res)
                $(".tc_xs").fadeIn();
                mask.style.display = "block";
            }
        })
    }
    function detaillogpanelset(key){
        var text = '';
        var divtext = '<div class="detaillogitem {0}">{1}</div><br>'
        var item = GachaLog[key];
        if(item===undefined){
            text+=divtext.format("","无数据");
        }else{
            var len=item.length;
            for(var i=len-1;i>=0;i--){
                var thisclass = '';
                if(item[i][0]=="SVIP"){
                    thisclass="svip"
                }else if(item[i][0]=="BVIP"){
                    thisclass="bvip"
                }else if(item[i][0]=="星沙"){
                    thisclass="xingsha"
                }else if(item[i][0]=="贝壳"){
                    thisclass="beike"
                }
                text+=divtext.format(thisclass,item[i][0]+":"+item[i][1]);
            }
        }
        console.log(text)
        detaillogpanel.innerHTML = text;
    }

    var mycssinner = function () {
        /*
        input::-webkit-input-placeholder{
        color:#DCDCDC;
        }
        input:-moz-placeholder{
        color:#DCDCDC;
        }
        input::-moz-placeholder{
        color:#DCDCDC;
        }
        input:-ms-input-placeholder{
        color:#DCDCDC;
        }
        .tabs {
            position:relative;
        min-height: 300px;
  display: block;
  display: -webkit-flex;
  display: -moz-flex;
  display: flex;
  -webkit-flex-wrap: wrap;
  -moz-flex-wrap: wrap;
  flex-wrap: wrap;
  margin: 10px;
  border: 1px solid #9370db;
  overflow: hidden; }
  .tabs [class^="tab"] label,
  .tabs [class*=" tab"] label {
    cursor: pointer;
    display: block;
    font-size: 1.1em;
    font-weight: 300;
    line-height: 1em;
    padding: 2rem 0;
    text-align: center; }
  .tabs [class^="tab"] [type="radio"],
  .tabs [class*=" tab"] [type="radio"] {
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    display: block;
    width: 100%;
    -webkit-transition: all 0.3s ease-in-out;
    -moz-transition: all 0.3s ease-in-out;
    -o-transition: all 0.3s ease-in-out;
    transition: all 0.3s ease-in-out; }
    .tabs [class^="tab"] [type="radio"]:hover, .tabs [class^="tab"] [type="radio"]:focus,
    .tabs [class*=" tab"] [type="radio"]:hover,
    .tabs [class*=" tab"] [type="radio"]:focus {
      border-bottom: 1px solid #40a9ff;
}
    .tabs [class^="tab"] [type="radio"]:checked,
    .tabs [class*=" tab"] [type="radio"]:checked {
      border-bottom: 2px solid #40a9ff;
}
    .tabs [class^="tab"] [type="radio"]:checked + div,
    .tabs [class*=" tab"] [type="radio"]:checked + div{
      opacity: 1; }
    .tabs [class^="tab"] [type="radio"] + div,
    .tabs [class*=" tab"] [type="radio"] + div{
      display: block;
      opacity: 0;
      padding: 2rem 0;
      width: 90%;
      -webkit-transition: all 0.3s ease-in-out;
      -moz-transition: all 0.3s ease-in-out;
      -o-transition: all 0.3s ease-in-out;
      transition: all 0.3s ease-in-out; }
  .tabs .tab-2 {
    width: 50%; }
    .tabs .tab-2 [type="radio"] + div {
      width: 200%;
      margin-left: 200%; }
    .tabs .tab-2 [type="radio"]:checked + div {
      margin-left: 0; }
    .tabs .tab-2:last-child [type="radio"] + div {
      margin-left: 100%; }
    .tabs .tab-2:last-child [type="radio"]:checked + div {
      margin-left: -100%; }
  #hisdiv,#todaydiv {
    display: block;
    font-size: 1.3em;
    font-weight: 150;
    line-height: 1em;
    padding: 10px 10px;
    //text-align: center;
    }
    .detail{
    }
    .btn-details {
    display: block;
    width: 45%;
    position:absolute;
    bottom:5px;
    left:5px;
    }
    .tc_xs{
    width:30%;
    height:60%;
    line-height:3rem;
    background:#666;
    position:fixed;
    left:50%;
    margin-left:-15%;
    bottom:30%;
    text-align:center;
    color:#fff;
    border-radius:4px;
    display:none;
    z-index:10;
    }
    #mask{
        display:none;
        width:100%;
        height:200%;
        position:absolute;
        top:0;
        left:0;
        z-index:1;
        background-color:#000;
        opacity:0.3;
        }
    .detaillogitem{
    display:inline-block;
    padding: 10px 16px;
    width:60%;
    margin-top:5px;
    background-color:#333;
    border-radius:4px;
    }
    .svip{
    background-color:#ea644a;
    }
    .bvip{
    background-color:#0a67fb;
    }
    .xingsha{
    background-color:#26762a;
    }
    .beike{
    background-color:#333;
    }
*/
    };
    function mycss(){
        GM_addStyle(mycssinner.getMultilines());
    }

    function updatelogpanel(){
        var now = new Date();
        var hissum = {"消耗星晶":0,"星沙":0,"贝壳":0,"BVIP":0,"SVIP":0,},nowsum={"消耗星晶":0,"星沙":0,"贝壳":0,"BVIP":0,"SVIP":0,}
        for (var key in GachaLog) {
            var item = GachaLog[key];
            for(var i in item){
                hissum['消耗星晶']++;
                hissum[item[i][0]]+=item[i][1];
                if(now.toLocaleDateString()==key){
                    nowsum['消耗星晶']++;
                    nowsum[item[i][0]]+=item[i][1];
                }
            }
        }
        var histext = makedictText(hissum)
        var nowtext = makedictText(nowsum)
        hisdiv.innerText = histext;
        todaydiv.innerText = nowtext;
    }


    function makedictText(dict){
        var text = '';
        for(var key in dict) {
            var item = dict[key];
            text+=key
            text+=":"
            text+=item
            text+="\n"
        }
        return text
    }



    initGachaLogPanel();
    mycss();
    updatelogpanel()
}

function dictsort(dic){
    var res = Object.keys(dic).sort(function(a,b){return b-a;});
    for(var key in res){
        console.log("key: " + res[key] + " ,value: " + dic[res[key]].score);
    }
}

Function.prototype.getMultilines = function () {
    var lines = new String(this);
    lines = lines.substring(lines.indexOf("/*") + 2,lines.lastIndexOf("*/"));
    return lines;
}
String.format = function(src){
    if (arguments.length == 0) return null;
    var args = Array.prototype.slice.call(arguments, 1);
    return src.replace(/\{(\d+)\}/g, function(m, i){
        return args[i];
    });
};

function FM_setValue(name, value){
    var oldvalue = GM_getValue(user);
    if(oldvalue === undefined){
        oldvalue = {};}
    oldvalue[name] = value;
    GM_setValue(user,oldvalue);
}

function FM_getValue(name, defaultValue){
    var thisvalue = GM_getValue(user);
    if(thisvalue != undefined&&name in thisvalue){
        return thisvalue[name]
    }
    if(defaultValue != null){
        return defaultValue;
    }
    return null;
}

function html_encode(str)
{
    var s = "";
    if (str.length == 0) return "";
    s = str.replace(/&/g, "&amp;");
    s = s.replace(/</g, "&lt;");
    s = s.replace(/>/g, "&gt;");
    s = s.replace(/ /g, "&nbsp;");
    s = s.replace(/\'/g, "&#39;");
    s = s.replace(/\"/g, "&quot;");
    s = s.replace(/\n/g, "<br/>");
    return s;
}

function html_decode(str)
{
    var s = "";
    if (str.length == 0) return "";
    s = str.replace(/&amp;/g, "&");
    s = s.replace(/&lt;/g, "<");
    s = s.replace(/&gt;/g, ">");
    s = s.replace(/&nbsp;/g, " ");
    s = s.replace(/&#39;/g, "\'");
    s = s.replace(/&quot;/g, "\"");
    s = s.replace(/<br\/>/g, "\n");
    return s;
}

//——————————————————mainfun————————————
var user = document.getElementsByClassName('icon-user')[0].parentNode.innerText.split(' ')[1];
let dateTimecss = GM_getResourceText('dateTimecss')
var startindex = dateTimecss.indexOf("@charset")
var endindex = dateTimecss.indexOf("endmycss")-1
GM_addStyle(html_decode(dateTimecss.slice(startindex,endindex)))

var rl = window.location.href;
if(/guguzhen.com\/fyg_pk.php/.test(rl)){
    fyg_pk_html();
}
/*if(/guguzhen.com\/fyg_shop.php/.test(rl)){
    fyg_shop_html();
}*/

unsafeWindow.GM_getValue = GM_getValue