抖音网页版优化

抖音网页版推荐、直播优化,网页全屏,全黑,自动按浏览器窗口调整大小

// ==UserScript==
// @name 抖音网页版优化
// @description 抖音网页版推荐、直播优化,网页全屏,全黑,自动按浏览器窗口调整大小
// @namespace https://space.bilibili.com/482343
// @author 古海沉舟
// @license 古海沉舟
// @version 1.14.11
// @match https://www.douyin.com/*
// @include https://*.douyin.com/*
// @require https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/3.6.0/jquery.min.js
// @require https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/howler/2.2.3/howler.min.js
// @run-at document-end
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_addValueChangeListener
// @noframes
// ==/UserScript==
var zz = new Array("","","","","","","","");
var zzb = new Array("","","","","","","","");
var lastindex=0,livecount=0,h="",h0="",sortdone=0,wt=0,wt2=0,ct=0,bs;
var islog=1;
var toObj = function( arr ){ var obj = {}; for(var temp in arr){ obj[arr[temp]] = true; } return obj;};
var toArr = function( obj ){ var arr = []; for(var temp in obj){ arr.push(temp); } return arr;};
var together = function( a,b ){ for(var temp=0;temp<b.length;temp++)if(b[temp]!=null && b[temp]!="" && b[temp]!="null" && b[temp].length<40){ a.push(b[temp].toLowerCase()); }};
var getUniq = function(arr){ return toArr( toObj(arr) );};
var zzx = GM_getValue("zz",new Array());
var zzy = GM_getValue("zzb",new Array());
var ispayhide=0,ismirror=0;
setTimeout(()=>{
    zzx = zzx.filter((itemA) => !zzb.some((itemB) => itemA === itemB));
    zzy = zzy.filter((itemA) => !zz.some((itemB) => itemA === itemB));
    together(zzx,zz);
    zzx =getUniq(zzx);
    zz = new Array();
    together(zz,zzx);
    GM_setValue("zz", zz);
    together(zzy,zzb);
    zzy =getUniq(zzy);
    zzb = new Array();
    together(zzb,zzy);
    zzb = zzb.filter((itemA) => !zz.some((itemB) => itemA === itemB));
    GM_setValue("zzb", zzb);
    const colors = {
        reset: "\x1b[0m",
        red: "\x1b[31m",
        green: "\x1b[32m",
        yellow: "\x1b[33m",
        blue: "\x1b[34m",
        magenta: "\x1b[35m",
        cyan: "\x1b[36m",
        white: "\x1b[37m"
    };

    // 打印彩色文本的函数
    function cc(color, ...args) {
        let total = "";
        for (const arg of args) {
            total += arg;
        }
        console.log(colors[color] + total + colors.reset);
    }

    /*
function cc(color, message) {
  console.log(colors[color] + message + colors.reset);
}
*/
    function keydown(event) {
        //cc("white",event.keyCode);
        if(event.keyCode == 109 || event.keyCode == 189){ // 按-或者小键盘-
            pagefullscreen();
        }
        if(event.keyCode == 187 || event.keyCode == 106){ // 按=或者小键盘*
            payhide();
        }
        if(event.keyCode == 111 || event.keyCode == 191){ // 按/或者小键盘/
            videomirror();
        }
    }
    document.addEventListener('keydown', keydown, false);

    var haspagefullscreen=0;
    if (location.href.indexOf("douyin.com/follow")>-1){
        haspagefullscreen=1;
        let livestyle = document.createElement('style');
        livestyle.classList.add("live");
        livestyle.innerHTML = `
        .semi-avatar-additionalBorder{border:none!important}
.QecmPpxX .RUVTDzAp,._dJyrFnU .gsOyYJvT,.semi-avatar-circle{ border-radius: 0% !important;  }
.Jt6LO5RK .qOwBZHet .trexWhDY,.yP48EXrf .NvKO9tgN .jnhlhsXZ,.QecmPpxX .RUVTDzAp,._dJyrFnU .gsOyYJvT{ animation: none; }
.MqFz1fuL .YI8dpeaX,.semi-avatar-animated{animation:none !important}
.Jt6LO5RK .qOwBZHet .y5X4PaKT, .Jt6LO5RK .qOwBZHet .o4w20gFP, div.XcEg0PrM,div.Lo8QPz5R,div.QecmPpxX.TrKWAgc9>svg,div.QecmPpxX.TrKWAgc9 > div.X0v0tibw,div.QecmPpxX.TrKWAgc9 > div.XQ9v_nAP,ul > li > a > div > svg,ul > li > a > div > div.WDUuX4lo,ul > li > a > div > div.SDfWCx4A,#douyin-right-container > div.parent-route-container.route-scroll-container > div > div > div > div.eHY_F2xy.rc3osMc2{ display: none !important }
div[class="iLXEZpcn Wza3QO3S"],div.zhL4qBq2,.yP48EXrf .NvKO9tgN .Pj8z3gc4,div.WQmhtggS,div[data-e2e="recommend-guide-mask"],div.WDUuX4lo,div.SDfWCx4A,#douyin-right-container > div.jRsgdw_0 > div > div.Cts4MhxF > ul > li > div > div.frvzAIi8 > a > div > span > div > span:nth-child(2),#douyin-right-container > div.jRsgdw_0 > div > div.Cts4MhxF > ul > li > div > div.frvzAIi8 > a > div > span > div > span:nth-child(3){display: none!important}

`
    document.body.appendChild(livestyle);
        cc("blue","直播");
        var liveheight=setInterval(livesort,500);

    }
    function livesort(){
        var livea=`#douyin-right-container > div.parent-route-container.route-scroll-container.LhqxgEn_ > div.tR7Ulcih > div > div.e3ffUpdr > ul.HK1P5LMm.NpyoaYHH`
        $(`#douyin-right-container > div.parent-route-container.route-scroll-container > div > div > div > ul`,livea+` >li`).each(function(){
            if ($(this).text().indexOf(`个作品未看`)>-1){
                //cc("white",$(this)[0]);
                $(this).hide();
            }
        })
        $(`#douyin-right-container > div.parent-route-container.route-scroll-container > div > div > div > div`).each(function(){
            if ($(this).text().indexOf(`精选关注人`)>-1){
                //cc("white",$(this)[0]);
                $(this).hide();
            }
        })
        $(`#douyin-right-container > div.parent-route-container.route-scroll-container.LhqxgEn_ > div.tR7Ulcih > div > div.e3ffUpdr > ul._AiUZgKi`).each(function(){
            cc("blue","删除非直播");
            cc("blue",$(this)[0]);
            $(this).remove();
        })
        //直播个数
        var lul=`#douyin-right-container > div.jRsgdw_0 > div > div.Cts4MhxF > ul`;
        if ($(lul).length <1){
            lul=`#douyin-right-container > div.parent-route-container.route-scroll-container > div > div > div > ul`;
        }
        if ($(lul).html()==h || sortdone==1){return;}
        livecount=$(lul+` > li`).length;
        if(livecount>0){
            cc("blue","当前直播个数:",livecount);
            cc("blue","排序次数:",sortdone);

            var h1="";
            var h2="";
            var h3="";
            var h4="";
            var ho="";
            $(lul+` > li:not([fi])`).each(function(){

                //cc("white","T ",$(this)[0]);
                $(this).attr('fi', '1');
                let find=0;
                let fl = $(this).find("a").attr("href");
                let oh = $(this)[0].outerHTML;
                if (typeof fl !== "undefined"){
                }else{
                    fl = $(this).children("div.frvzAIi8").children("a").attr("href");
                    if (typeof fl !== "undefined"){
                    }else{
                        return
                    }
                }
                //cc("white","判断 ",fl)
                for (let x=0;x<zz.length;x++){
                    if(zz[x] != ""){
                        if (fl.indexOf(zz[x])>-1){
                            find=1;
                            break;
                        }
                    }
                }
                if (find){
                    h1=h1+oh;
                    //cc("white","加1 ",fl)
                    return
                }

                for (let x=0;x<zzb.length;x++){
                    if(zzb[x] != ""){
                        if (fl.indexOf(zzb[x])>-1){
                            find=1;
                            break;
                        }
                    }
                }
                if (find){
                    h2=h2+oh;
                    //cc("white","加2 ",fl)
                    return
                }
                if (oh.indexOf("福袋")>0){
                    h3=h3+oh;
                    //cc("white","加2 ",fl)
                    return
                }
                if (oh.indexOf("红包")>0){
                    h4=h4+oh;
                    //cc("white","加2 ",fl)
                    return
                }
                ho=ho+oh;
                //cc("white","加3 ",fl)
            })
            h=h1+h2+h3+h4+ho;
            if (h!=""){
                cc("blue","重新排序后");
                cc("blue",h);
                sortdone=1;
                $(lul).html(h);
            }
        }else{
            if (h0!=""){
                $(`#douyin-right-container`).html(h0);
                return
            }
        }
        livecount=$(lul+` > li`).length;
        if (livecount>0 && lastindex==0){
            h0=$(`#douyin-right-container`).html();
            cc("blue","直播个数",livecount);
            clearInterval(liveheight);
            lastindex=1;
            liveheight=setInterval(livesort,5000);
        }

    }

    function videomirror(){
        //视频镜像
        ismirror = 1-ismirror;
        if (ismirror){
            cc("red","开启垂直镜像");
            let wdstyle = document.createElement('style');
            wdstyle.classList.add("videomirror");
            wdstyle.innerHTML = `
            video{
    transform: rotateY(180deg) !important;
    -webkit-transform:rotateY(180deg) !important; /* Safari and Chrome */
    -moz-transform:rotateY(180deg) !important; /* Firefox */
}
                `
            document.body.appendChild(wdstyle);
        } else {
            cc("green","关闭垂直镜像");
            $(`style.videomirror`).remove();
        }
    }
    function payhide(){
        ispayhide = 1-ispayhide;
        if (ispayhide){
            cc("red","隐藏支付");
            let wdstyle = document.createElement('style');
            wdstyle.classList.add("payhide");
            wdstyle.innerHTML = `
                div.aqK_4_5U{display:none !important}
                `
            document.body.appendChild(wdstyle);
        } else {
            cc("green","显示支付");
            $(`style.payhide`).remove();
        }
    }
    function pagefullscreen(){
        var is=0;
        //$(`#slidelist > div > div.swiper-wrapper > div.swiper-slide-active xg-icon.xgplayer-page-full-screen > div.xgplayer-icon`).click();
        $(`#sliderVideo xg-icon.xgplayer-page-full-screen > div.xgplayer-icon`).each(function(){
            haspagefullscreen=1;
            $(this).click();
            is=1;
            if (is){return}
            cc("blue","非推荐");
            $(`xg-controls xg-icon>div > div:nth-child(2)`).each(function(){
                if ($(this).parent().text().indexOf("网页全屏")<0)return;
                //cc("white","判断:",$(this).text(),"  ",$(this)[0]);
                haspagefullscreen=1;
                $(this).click();
            })
        })
        if (is){return}
        $(`div[data-e2e="living-container"] xg-icon>div>div`).each(function(){
            if ($(this).parent().text().indexOf("网页全屏")<0)return;
            //cc("white","判断:",$(this).text(),"  ",$(this)[0]);
            haspagefullscreen=1;
            $(this).click();
        })

    }
    var firstfullscreen=setInterval(function(){
        if (haspagefullscreen){
            clearInterval(firstfullscreen);
            return;
        }
        pagefullscreen();
    },1000);

    setInterval(function(){
        filtergift();
    },1000);

    function filtergift(){ //过滤直播礼物
        $(`div.webcast-chatroom___item.webcast-chatroom___enter-done:not([fi]),xg-danmu>div:not([fi])`).each(function(){
            $(this).attr('fi', '1');
            var currentDate = new Date();
            var currentTime = currentDate.toLocaleString();
            if ($(this).text().indexOf("送出")>-1 || $(this).text().indexOf("送给")>-1 || $(this).text().indexOf("为主播加了")>-1){

                cc("white",$(this).text().replace(/\n/g, " ").replace(/\s\s/g, " ")+" "+currentTime);
                $(this).hide();
            }
            if ($(this).text().indexOf("想听")>-1 ||$(this).text().indexOf("刚刚升级至")>-1 ||   $(this).text().indexOf("成为在线观众TOP")>-1 || $(this).text().indexOf("推荐直播给")>-1 || $(this).text().indexOf("成功冠名了")>-1 || $(this).text().indexOf("恭喜主播成功点亮了")>-1){
                $(this).hide();
            }
        })
    }

    function addCSS(){
        let wdstyle = document.createElement('style');
        wdstyle.classList.add("optimize");
        wdstyle.innerHTML = `
div.gNyVUu_s, .OaNxZqFU img, .iRX47Q8q img,.Ng_nLvWy img,#sliderVideo > div.Mtz1OJlG.v0tRQvoe,div > div.eVtiBTlw > img,#slideMode > div.Mtz1OJlG.v0tRQvoe > img,.Mtz1OJlG img,.DEZPWI4G img,img[alt="LiveIcon"],#sliderVideo > div > img,#dark > div.iDduYXAc{ display: none!important }
.gKxBg4JL{box-shadow: none !important}
.yP48EXrf .PzYA0Lei,._fmQtZIm .TWYv_EXn .I7uTRbqE{text-overflow: clip !important;}
.qdcce5kG .VFMR0HAe,:root[update-header="2"] .qlkbkha_,div.search-horizontal-new-layout,#search-content-area div.GwBBBRKQ,#douyin-right-container,#chatroom > div.c6LJxjPr.unset-border > div.kz8VfOyK.Qsns7NdQ > div.Mv2estbj,.L76SgT5E .cYSl9Ppa,html[dark] .zmXfkTZ9, #dark .zmXfkTZ9{ background: #0000 !important }
.vLt8mbfQ .y8iJbHin .mMOxHVzv, .vLt8mbfQ .y8iJbHin .rrKCA47Q, div.webcast-chatroom, .BasEuG5Q ._QjzkgP3, .OaNxZqFU,.basicPlayer.xgplayer,div.aqK_4_5U,.iSgCRqVf,.aEzDlumt .KhphjUgd.lG3F75Kf.anFLc8TW,.D9gH9oLs,html[dark] .lfsfx_uh .GE_yTyVX,.Pw3CDvJ,.aEzDlumt .xKQnHfmH.anFLc8TW,.Pw3CDvJg,#search-content-area > div{background: #000 !important }
body,.Npz7CPXj, div.webcast-chatroom .webcast-chatroom___input-container .webcast-chatroom___textarea, .CgAB9miy, .JTIGfG2P, .NQ38Bc0h .XcEg0PrM, .N_HNXA04:not(.dUiu6B8O) .iViO9oMI, .UKFpY5tW, .SxCiQ8ip .EDvjMGPs,.SxCiQ8ip .A0ewbQCI,.fpRIB_wC,div.tgMCqIjJ, div.tgMCqIjJ.isDark,.sELpHy0M.metro .lgs6xhy7 .slot-item:hover,.sELpHy0M.metro .B9p3ney8:hover,.sELpHy0M.metro .UjStUCgW ._BSUxMOF:hover,.SxCiQ8ip.V6Va18Np,.qlkbkha_,.SxMeCeGo.UdVKTDud .gjQTl671,.h9wtZ0fY.metro .wtNw_CDe:hover,.h9wtZ0fY.metro .Pg8ernIx .slot-item:hover,.h9wtZ0fY.metro .fIHFYwJt .Y4MTL_BH:hover,.SxMeCeGo .DFH1PTN6,.gjQTl671,.EexPxRCK.cc1_mSqr.Bhtzbjo2,.aEzDlumt .jscIDlNp,.aEzDlumt .jscIDlNp.anFLc8TW,#slidelist,.X5syc51M.yWR42jR6,.EexPxRCK .Rr56zkD1,.gjQTl671 .c6LJxjPr,#island_e62be > div,.Qsns7NdQ,.NhEuGG6P,.eJDcoWZ2 .nUArm8od,.Q8fbHDm7.Q3NoUU1P,.gvxFUQjb,.iDduYXAc,#dark{ background: #111 !important }
.N_HNXA04:not(.dUiu6B8O) .kQ2JnIMK .n9PPTk22, .N_HNXA04 .kQ2JnIMK, .iwzpXgQ3 .oJArD0aS, .xWPMYXKp .gOSlkVoB, .Exz5X5r1,.R5ITbXfy .k5cuEeRD,.sELpHy0M.metro .lgs6xhy7 .slot-item,.sELpHy0M.metro .B9p3ney8,.sELpHy0M.metro .UjStUCgW ._BSUxMOF,.N_HNXA04 .kQ2JnIMK .YrFhKzRI,.kuew7rkS .HaiBJL6n,.h9wtZ0fY.metro .wtNw_CDe,.h9wtZ0fY.metro .Pg8ernIx .slot-item,.h9wtZ0fY.metro .fIHFYwJt .Y4MTL_BH,._0QL2JpzH,#component-navigation,.J6zKCgYE,.Z0XYsCxp .d8cD2XWD,.MBk4_p5s .GbSnpgWT{ background: #222 !important }
:root[dark]{--floating-screen-wrapper-bg:linear-gradient(180deg,#000000 68.75%,rgba(37,38,50,0) 100%);}
div.JwGiJkkI, div.xgplayer-dynamic-bg, div.umOY7cDY, div.ruqvqPsH,footer,:root[dark] .B6M32uoI,:root[dark] .KHZgK2KB,:root[dark] .YpFJLpHw,#douyin-right-container > div.parent-route-container.route-scroll-container.LhqxgEn_ > div.tR7Ulcih > div > div.e3ffUpdr > ul > li > div > div.Ib3gyySI > a.kpteEEN8.rPSHi9Pq > div > div > img{display: none !important }
.L8o4Hyg1,.L8o4Hyg1 .LFbb1oon,.L8o4Hyg1 .R6NHkCAw .i4vdvOF5{ box-shadow: none !important; border-bottom: none !important; border-right: none !important; }
.N_HNXA04:not(.JVPLvXh3) .iViO9oMI,.N_HNXA04 .HQwsRJFy,.lXuWkeYW, .lXuWkeYW .oJArD0aS{height:60px !important}
.pgQgzInF.hqONwptG .Jf1GlewW.Ox89VrU5, .ckEyweZa.AmXnh1GR .QICHGW7r.RosH2lNv, .SxCiQ8ip.V6Va18Np .EDvjMGPs.FKQqfehj { height: 100% !important; }
:root[update-header="1"] .JTIGfG2P, :root[update-header="2"] .JTIGfG2P, :root[update-header="3"] .JTIGfG2P{padding: 0 0 0 0;}
.SxCiQ8ip .EDvjMGPs .nUwhpww3.E2QLXZIv,.SxMeCeGo .DFH1PTN6 ._uuQkdQj._J11W6D7{padding-top: 0px !important;}
div.immersive-player-switch-on-hide-interaction-area, #video-info-wrap, xg-inner-controls.xg-inner-controls { opacity: 0.6 !important }
.xgplayer-playswitch .xgplayer-playswitch-tab { opacity: 0 !important }
div.xgplayer-playswitch-tab:hover, div.immersive-player-switch-on-hide-interaction-area:hover, #video-info-wrap:hover, xg-inner-controls.xg-inner-controls:hover { opacity: 1 !important }
.mUQC4JAd .LU6dHmmD{color:#bbb}
`
    document.body.appendChild(wdstyle);
    }
    addCSS();
    ispayhide=0;
    payhide();

    //为直播页面时 尝试设置为最高清晰度
    var setdefinition=setInterval(function(){
        var curdefinition="",highestdefinition="",find=0;
        if (location.href.indexOf("https://live.douyin.com/")>-1){
            //直播页面
            $(`#_douyin_live_scroll_container_ xg-controls div[data-e2e="quality"]`).each(function(){
                curdefinition=$(this).text();
            })
            $(`#_douyin_live_scroll_container_ xg-controls div[data-e2e="quality-selector"] > div`).each(function(){
                highestdefinition=$(this).text();
                if ((highestdefinition.indexOf("登录即享")>-1 && highestdefinition.indexOf("高清")<0) || find>0){
                    return
                }
                if (highestdefinition!=""){
                    cc("white","当前清晰度 ",curdefinition," 可选最高",highestdefinition);
                    if(highestdefinition.indexOf(curdefinition)<0){
                        console.log("点击 ",$(this)[0]);
                        $(this).click();
                    }else{
                        clearInterval(setdefinition);
                    }
                    find = 1;
                }
            })
        }else{
            //视频页面
            $(`xg-controls xg-icon.xgplayer-playclarity-setting > div > div.btn`).each(function(){
                curdefinition=$(this).text();
            })
            $(`xg-controls xg-icon.xgplayer-playclarity-setting > div > div.virtual >div`).each(function(){
                highestdefinition=$(this).text();
                if ((highestdefinition.indexOf("登录即享")>-1 && highestdefinition.indexOf("清晰")<0) || find>0){
                    return
                }
                if (highestdefinition!=""){
                    cc("white","当前清晰度 ",curdefinition," 可选最高",highestdefinition);
                    if(highestdefinition.indexOf(curdefinition)<0){
                        console.log("点击 ",$(this)[0]);
                        $(this).click();
                    }else{
                        clearInterval(setdefinition);
                    }
                    find = 1;
                }
            })
        }
    },1000)

    var lingjiang;
    if (location.href.indexOf("live.douyin.com/")>-1){
        performance_trick();
        lingjiang=setInterval(function(){
            var lofind=0;
            var currentDate = new Date();
            var currentTime = currentDate.toLocaleString();
            var currentms = new Date().getTime();
            //ct 上次点击时间 wt福袋预计等待时间 wt2红包预计等待时间

            $(`body > div > div > div > div.elw1KV8O > div.JL05k7eS.OG51D9OO`).each(function(){
                if ($(this).text().indexOf("继续播放")>-1){
                    console.log("点击继续播放  ",$(this).text(),currentTime);
                    console.log($(this)[0]);
                    $(this).click();
                    ct=currentms;
                }
            })
            $(`#login-pannel > div.login-pannel__header > div`).each(function(){
                //登陆窗口
                if ($(this).text().indexOf("登录即可抢红包")>-1){
                    console.log("未登陆暂停红包  ",$(this).text(),currentTime);
                    console.log($(this)[0]);
                    islog=0;
                }else{
                    islog=1;
                }
            })
            if (!islog){
                return
            }
            $(` #short_touch_land_redpacket_land`).each(function(){
                let tt=$(this).text();
                if (tt.indexOf("一键送出")>-1) {
                    cc("green","抢到红包 ",currentTime);
                    $(this).find(`div > div.Le1F9H3f.wzo_eGOx > div.xXBYooJe.MsPOwasn > div`).each(function(){
                        console.log($(this)[0]);
                        $(this).click();
                    })
                }

                if (tt.indexOf("下次抓住")<0) {
                    let ix=tt.match(/[0-9]{1,2}分[0-9]{1,2}秒后/g);
                    if (ix!= null){
                        ix=ix[0].split("分");
                        ix=ix[0]*60+ix[1].split("秒后")[0]*1;
                        if (ix>0){
                            console.log("红包等待 ",ix," 秒",currentTime);
                            wt2=currentms+ix*1000-1000;
                            console.log("至",timestampToDatetime(wt2));
                        }
                        return
                    }
                    cc("yellow","尝试抢红包 ",currentTime);
                    $(this).find(`div > div.Le1F9H3f.wzo_eGOx > div.n_SHjkN2.LQcnZAyL > div > div.LyXHvflO.cNg0AbVM`).each(function(){
                        console.log($(this)[0]);
                        $(this).click();
                    })
                }else{
                    cc("red","没抢到红包 ",currentTime);
                    $(this).find(`div > div.Le1F9H3f.wzo_eGOx > div.xXBYooJe.MsPOwasn > div`).each(function(){
                        console.log($(this)[0]);
                        $(this).click();
                    })
                }
            })
            $(`#lottery_close_cotainer`).each(function(){
                var tt=$(this).text();
                $(this).attr('fi', '1');
                lofind=1;
                //console.log("判断  ",tt);
                if (tt.indexOf("没抽中福袋")>-1){
                    cc("red","没抽中福袋 ",currentTime);
                    $(this).find(`div[role="button"]`).each(function(){
                        if (tt.indexOf("知道了")>-1){
                            console.log("点击知道  ",tt,currentTime);
                            console.log($(this)[0]);
                            $(this).click();
                            ct=currentms;
                        }
                    })
                    return
                }
                //console.log("1 : ",currentms," ",ct," ",wt);
                if (currentms>ct+200 && currentms>wt+2000){
                    //console.log("2 : ",currentms," ",ct," ",wt);
                    wt=currentms;
                    let ix=tt.match(/[0-9]{1,2}:[0-9]{1,2}/g);
                    if (ix!= null){
                        ix=ix[0].split(":");
                        ix=ix[0]*60+ix[1]*1;
                        if (ix>0){
                            console.log("福袋等待 ",ix," 秒",currentTime);
                            wt+=ix*1000-1000;
                            console.log("至",timestampToDatetime(wt));
                        }
                    }
                    //console.log("tt ",tt);
                    if (tt.indexOf("已参与")>-1){

                    } else if (tt.indexOf("倒计时")>-1 || tt.indexOf("加载中")>-1 || tt.indexOf("一键发评论参与福袋")>-1){
                        let canl=0;
                        $(this).find(`div[role="button"]`).each(function(){
                            if (tt.indexOf("一键发评论参与福袋")>-1){
                                console.log("点击发评论参与福袋 ",tt);
                                console.log($(this)[0]);
                                $(this).click();
                                ct=currentms;
                                canl=1;
                            }
                            if (tt.indexOf("已参与")>-1){
                                canl=2;
                            }
                        })
                        if (canl==0){
                            console.log("该福袋需要消费,不自动领取");
                        }
                        return
                    }else if (tt.indexOf("恭喜你")>-1){
                        cc("green",tt," ",currentTime);
                        $(this).find(`div > div > div.YnybGvCL`).last().each(function(){
                            if ($(this).text().length<3){
                                $(this).click();
                                console.log("点击关闭按钮 ",tt,currentTime);
                                console.log($(this)[0]);
                                ct=currentms;
                            }
                        })
                    }else if (tt.indexOf("加入")<0 && tt.indexOf("提升")<0){
                        cc("yellow",tt," ",currentTime);
                        $(this).find(`div > div > div.YnybGvCL`).last().each(function(){
                            if ($(this).text().length<3){
                                $(this).click();
                                console.log("点击关闭按钮 ",tt,currentTime);
                                console.log($(this)[0]);
                                ct=currentms;
                            }
                        })
                    }else{
                        console.log("该福袋需要新加入粉丝团或提升等级,不自动领取");
                    }
                }
            })
            if (lofind==0){
                //未找到礼物窗口,寻找左上角福袋按钮
                //ct 上次点击时间 wt预计等待时间

                $(`div.ShortTouchContainer div.i7fQOuPe>pace-island>div>div`).each(function(){
                    let ttx=$(this).text()
                    //福袋
                    if (ttx.indexOf(":")>-1 && ttx.indexOf("00:00")<0){
                        if (currentms-wt>0 && currentms-ct>9000){
                            console.log("点击福袋  ",ttx,currentTime);
                            console.log($(this)[0]);
                            $(this).click();
                            ct=currentms;

                        }
                    }else if (ttx.length==0){
                        //红包
                        console.log("点击红包  ",ttx,currentTime);
                        console.log($(this)[0]);
                        $(this).click();
                        ct=currentms;

                    }
                })
                //console.log(currentDate,wt);

            }
        },1000)

    }

},1)

function performance_trick()
{
    //利用后台播放低音量声音让页面JS全速运行
    if(typeof bs !== "undefined") return bs.play();
    bs = new Howl({
        src: ['http://adventure.land/sounds/loops/empty_loop_for_js_performance.ogg','http://adventure.land/sounds/loops/empty_loop_for_js_performance.wav'],
        volume:0.5,
        autoplay: true, loop: true,
    });
}
function timestampToDatetime(timestamp) {
    const dateObj = new Date(timestamp);

    const year = dateObj.getFullYear();
    const month = dateObj.getMonth() + 1;
    const day = dateObj.getDate();
    const hours = dateObj.getHours();
    const minutes = dateObj.getMinutes();
    const seconds = dateObj.getSeconds();

    return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds;
}