Greasy Fork

Greasy Fork is available in English.

哔哩哔哩bilibili默认关闭弹幕

Bilibili html5播放器默认关闭弹幕

当前为 2020-06-21 提交的版本,查看 最新版本

// ==UserScript==
// @name         哔哩哔哩bilibili默认关闭弹幕
// @description  Bilibili html5播放器默认关闭弹幕
// @author       cngege
// @version      2020.6.21.a
// @namespace    cngege
// @icon         https://www.bilibili.com/favicon.ico
// @icon64       https://s1.ax1x.com/2020/06/17/NV4aEq.png
// @match        *://*.bilibili.com/video/*
// @match        *://*.bilibili.com/watchlater/*
// @match        *://*.bilibili.com/bangumi/play/*
// @require      https://cdn.bootcss.com/jquery/3.5.0/jquery.min.js
// @grant        none
// @run-at       document-end
// ==/UserScript==

(function() {
    let url = geturl();
    let isgo = true;        //本页面是否结束判断
    let Const = 0;          //记录一个页面中已循环次数,超过三十次则本页面不再循环判断是否关闭弹幕
    let DebugLog = false;
    //go();

    let geturl = ()=>{return window.location.href;}
    let go = ()=>
    {
        Const++;

        //判断弹幕开关是否是打开的 并关闭
        if($(".bilibili-player-video-danmaku-switch .bui-switch-dot").css("left") == "30px"){
            //向弹幕开关发送点击消息
            $('.bui-switch-input').click();
            if(DebugLog){console.log("向弹幕开关发送点击消息")}
        }
        if($(".bilibili-player-video-danmaku-switch .bui-switch-dot").css("left") == "2px"){
           isgo = false;
           if(DebugLog){console.log("检测到弹幕开关关闭");}
           return;
        }
        if(Const>30){isgo = false;return;}
        setTimeout(go,300);
    }
    setInterval(()=>
    {
        if(!isgo && url!=geturl()){
           if(url!=geturl()){
               Const = 0;
           }
           url=geturl();
           isgo = true;
           go();
        }
    },1000)
})();