B站(bilibili)自动续播因未登录而暂停的视频 (Bilibili: Continue playing without logging-in)

解决B站(bilibili)因未登录而自动暂停视频并弹出登录窗口的问题 / Solve the problem of Bilibili automatically pausing video and popping up a login window because it is not logged in

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

Advertisement:

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

Advertisement:

// ==UserScript==
// @name         B站(bilibili)自动续播因未登录而暂停的视频 (Bilibili: Continue playing without logging-in)
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  解决B站(bilibili)因未登录而自动暂停视频并弹出登录窗口的问题 / Solve the problem of Bilibili automatically pausing video and popping up a login window because it is not logged in
// @author       TheBeacon
// @match        https://www.bilibili.com/video/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// @license      MIT
// ==/UserScript==
(function() {
    'use strict';
    var target = document.getElementsByClassName("bpx-player-row-dm-wrap")[0];
    var config = {attributes: true, attributeFilter: ["class"]};
    var observer = new MutationObserver(function(motationList, observer) {
        setTimeout(function(){
            if (document.getElementsByClassName("bili-mini-mask").length > 0) {
                // console.log("captured!");
                // console.log(motationList[0]);
                document.getElementsByClassName("bili-mini-close-icon")[0].click();
                if (document.getElementsByClassName("bili-paused").length > 0) {
                    document.getElementsByClassName("bpx-player-ctrl-btn bpx-player-ctrl-play")[0].click();
                } //else {
                  //  console.log("but do nothing");
                //}
                observer.takeRecords();
            }
        }, 1000);
    });
    observer.observe(target, config);
})();