抖音网页版优化

抖音网页版推荐页面优化,自动网页全屏,背景全黑,自动释放内存

目前为 2022-07-16 提交的版本。查看 最新版本

// ==UserScript==
// @name 抖音网页版优化
// @description 抖音网页版推荐页面优化,自动网页全屏,背景全黑,自动释放内存
// @namespace https://space.bilibili.com/482343
// @author 古海沉舟
// @license 古海沉舟
// @version 1.3.3
// @include https://www.douyin.com/recommend
// @include https://www.douyin.com/*
// @include https://www.douyin.com/?*
// @include https://www.douyin.com/follow
// @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
// ==/UserScript==
var maxs=6;  //释放内存后保留已播放视频的数量
var lastindex=0;
function gx(){
    $(`div[class="swiper-wrapper"]>div.swiper-slide`).each(function (){
        var inde=$("div.swiper-wrapper div.swiper-slide").index(this);
        if ($(this).hasClass("swiper-slide-active")){
            if (inde-lastindex>maxs){
                //console.log("已加载   :  ", inde,"     删除多余:",lastindex, "~",inde-maxs-1);
                $("div.swiper-wrapper div.swiper-slide").slice(lastindex, inde-maxs).empty();
                lastindex=inde-maxs;
            }
        }
    });
}

gx();
function keydown(event) {
    gx();
    //console.log(event.keyCode);
    if(event.keyCode == 109 || event.keyCode == 189){ // 按-或者小键盘-
        pagefullscreen();
    }
}
document.addEventListener('keydown', keydown, false);
var aaa= new Date();
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
var observer = new MutationObserver(function (records) {
    var bbb = new Date();
    if (bbb-aaa>200){
        aaa=bbb;
        records.map(function (record) {
            if (record.addedNodes) {
                gx();
            }
        });
    }
});
var option = {
    childList: true,
    subtree: true,
};
observer.observe(document.body, option);
var haspagefullscreen=0;
function pagefullscreen(){
    //$(`#slidelist > div > div.swiper-wrapper > div.swiper-slide-active xg-icon.xgplayer-page-full-screen > div.xgplayer-icon`).click();
    $(`#slidelist > div > div.swiper-wrapper > div.swiper-slide-active xg-icon.xgplayer-page-full-screen > div.xgplayer-icon`).each(function(){
        haspagefullscreen=1;
        $(this).click();
    })
}
var firstfullscreen=setInterval(function(){
    if (haspagefullscreen){
        clearInterval(firstfullscreen);
        return;
    }
    pagefullscreen();
},500);


function addCSS(){
    let wdstyle = document.createElement('style');
    wdstyle.classList.add("optimize");
    wdstyle.innerHTML = `
div.gNyVUu_s{display:none!important}
.qdcce5kG .VFMR0HAe{background:#0000 !important}
.vLt8mbfQ .y8iJbHin .mMOxHVzv,.vLt8mbfQ .y8iJbHin .rrKCA47Q{background:#000 !important}
.Npz7CPXj{background:#111 !important}
`
    document.body.appendChild(wdstyle);
}
addCSS();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址