// ==UserScript== // @name 抖音网页版优化 // @description 抖音网页版推荐、直播优化,网页全屏,全黑,自动按浏览器窗口调整大小 // @namespace https://space.bilibili.com/482343 // @author 古海沉舟 // @license 古海沉舟 // @version 1.10.1 // @match https://www.douyin.com/* // @include https://www.douyin.com/recommend // @include https://www.douyin.com/* // @include https://www.douyin.com/?* // @include https://www.douyin.com/follow // @include https://live.douyin.com/* // @require https://cdn.staticfile.org/jquery/1.12.4/jquery.min.js // @run-at document-end // @grant GM_setValue // @grant GM_getValue // @grant GM_addValueChangeListener // @noframes // @downloadURL none // ==/UserScript== //setTimeout(()=>{ var zz = new Array("","","","","","",""); var lastindex=0,livecount=0,livewidth=0,onelinecount,livelinecount,hovercount; 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-1){ let livestyle2 = document.createElement('style'); livestyle2.classList.add("live2"); livestyle2.innerHTML = ` .Sqr0gG2o { display: flex; flex-wrap: wrap; flex: 1 1 auto; overflow-y: scroll; height: auto !important; max-height: 550px !important; } .YwClj8rK:hover{ flex: 1 1; } ` document.body.appendChild(livestyle2); haspagefullscreen=1; let livestyle = document.createElement('style'); livestyle.classList.add("live"); livestyle.innerHTML = ` .NQ38Bc0h .nvzm0QdP .X5RsU67Q,._Mlk4r_C .zHQRjhOm{ display: flex; flex-wrap: wrap; flex: 1 1 auto; overflow-y: scroll; } div.X5RsU67Q,._Mlk4r_C .zHQRjhOm .g3fyxxF8.HMMSXs78,._Mlk4r_C .zHQRjhOm{ width: 100%; overflow: auto; margin: auto; } div.X5RsU67Q,._Mlk4r_C .zHQRjhOm .g3fyxxF8.HMMSXs78,._Mlk4r_C .zHQRjhOm{ left: 10px !important; right: 0 !important; bottom: 0 !important; top: 0 !important; position: absolute !important; margin: auto !important; transform: none !important; } .NQ38Bc0h,.Sqr0gG2o.aSKksRfh,._Mlk4r_C{height:100%} .yP48EXrf .PzYA0Lei{text-overflow: clip;} .JTIGfG2P.aSKksRfh,div.g3fyxxF8 { display: flex; flex-wrap: wrap; flex: 6 1 auto; overflow-y: scroll; height: auto !important; max-height: 550px !important; } .YwClj8rK:hover{ flex: 12 1; } .YwClj8rK { min-height: 20px !important; } .NQ38Bc0h .nvzm0QdP .X5RsU67Q .o3pEYU7M,._Mlk4r_C .zHQRjhOm .g3fyxxF8 .Wza3QO3S,.yP48EXrf,._Mlk4r_C .zHQRjhOm >a{ height: 80px !important; margin-left: 5px !important; margin-right: 5px !important; } .Jt6LO5RK .qOwBZHet .trexWhDY,.yP48EXrf .NvKO9tgN .jnhlhsXZ,.yP48EXrf .NvKO9tgN{ border-radius: 0%; height: 48px; width: 48px; } .Jt6LO5RK .qOwBZHet .trexWhDY,.yP48EXrf .NvKO9tgN .jnhlhsXZ{ animation: none; } .Jt6LO5RK .qOwBZHet,.yP48EXrf .NvKO9tgN{ margin-top: 13px; margin-bottom: 2px; } .Jt6LO5RK .qOwBZHet .y5X4PaKT, .Jt6LO5RK .qOwBZHet .o4w20gFP, div.XcEg0PrM,div.Lo8QPz5R{ display: none !important } .lXuWkeYW, .lXuWkeYW .oJArD0aS{ height: 60px !important; } div[class="iLXEZpcn Wza3QO3S"],div.zhL4qBq2,.yP48EXrf .NvKO9tgN .Pj8z3gc4,div.WQmhtggS,div[data-e2e="recommend-guide-mask"]{display: none!important} ` document.body.appendChild(livestyle); var liveheight=setInterval(function(){ //直播个数 livecount=$(`div[class="g3fyxxF8 HMMSXs78"] > a`).length; if(livecount>0){ $(`div[class="iLXEZpcn Wza3QO3S"]`).each(function(){ $(this).remove(); }) var h=""; $(`div[class="g3fyxxF8 HMMSXs78"] > a`).each(function(){ let find=0; for (let x=0;x-1){ find=1; break; } } } if (find){ h=$(this)[0].outerHTML+h; }else{ h=h+$(this)[0].outerHTML; } }) if (h!=""){ console.log(h); $(`div[class="g3fyxxF8 HMMSXs78"]`).before(h); $(`div[class="g3fyxxF8 HMMSXs78"]`).remove(); } } livecount=$(`div.zHQRjhOm > a`).length; //移位后数量 if (livecount<1){ livestyle2 = ` .Sqr0gG2o { display: flex; flex-wrap: wrap; flex: 1 1 auto; overflow-y: scroll; height: auto !important; max-height: 550px !important; } .YwClj8rK:hover{ flex: 1 1; } ` $(`style.live2`).html(livestyle2); return } console.log("直播个数",livecount); livewidth=$(`div.zHQRjhOm`).width(); console.log("宽度",livewidth); //每行多少列 onelinecount=Math.trunc(livewidth/90); console.log("每行多少列",onelinecount); //多少行 livelinecount=Math.ceil(livecount/onelinecount); console.log("多少行",livelinecount); //显示部分多高 livecount=$(`#douyin-right-container`).height()-60; if (livecount<80){livecount=80;} console.log("显示部分多高",livecount); //最大比例 livewidth=Math.trunc(livecount/80)-1; console.log("最大比例",livewidth); //当前数量比例 onelinecount=(livelinecount*80)/(livecount-(livelinecount*80)) console.log("全部显示比例",onelinecount); //应该显示比例 if( onelinecount<0) { livelinecount=livewidth; }else{ livelinecount=Math.min(livewidth,onelinecount); } console.log("应该显示比例",livelinecount); //悬停显示比例 hovercount=(livecount/80-1)*livelinecount; console.log("悬停显示比例",hovercount); if (isNaN(livelinecount) || livelinecount==null){ return } clearInterval(liveheight); livestyle2 =` .Sqr0gG2o { display: flex; flex-wrap: wrap; flex: `+livelinecount+` 1 auto; overflow-y: scroll; height: auto !important; max-height: 550px !important; } .YwClj8rK:hover{ flex: `+hovercount +` 1; } ` $(`style.live2`).html(livestyle2); },500); } 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} console.log("非推荐"); $(`xg-controls xg-icon>div > div:nth-child(2)`).each(function(){ if ($(this).parent().text().indexOf("网页全屏")<0)return; console.log("判断:",$(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; console.log("判断:",$(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`).each(function(){ 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){ console.log($(this).text().replace(/\n/g, " ").replace(/\s\s/g, " ")); $(this).hide(); } }) } function addCSS(){ let wdstyle = document.createElement('style'); wdstyle.classList.add("optimize"); wdstyle.innerHTML = ` div.gNyVUu_s, .OaNxZqFU img, .iRX47Q8q img { display: none!important } .qdcce5kG .VFMR0HAe,:root[update-header="2"] .qlkbkha_{ background: #0000 !important } .vLt8mbfQ .y8iJbHin .mMOxHVzv, .vLt8mbfQ .y8iJbHin .rrKCA47Q, div.webcast-chatroom, .BasEuG5Q ._QjzkgP3, .OaNxZqFU,.basicPlayer.xgplayer{ 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,#slidelist,.qlkbkha_{ 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{ background: #222 !important } div.JwGiJkkI, div.xgplayer-dynamic-bg, div.umOY7cDY, div.ruqvqPsH,footer{ 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;} 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(); //},1500)