Bilibili

Bilibili website script

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!)

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!)

// ==UserScript==
// @name         Bilibili
// @namespace    https://www.bilibili.com/
// @version      0.2
// @description  Bilibili website script
// @author       youginil
// @match        https://www.bilibili.com/video/BV*
// @match        https://www.bilibili.com/video/av*
// @icon         https://www.bilibili.com/favicon.ico
// @grant        none
// ==/UserScript==

(function () {
    "use strict";
    const body = document.body;
    let timer = null;

    function resume() {
        if (timer !== null) {
            clearTimeout(timer);
        }
        timer = setTimeout(() => {
            timer = null;
            for (let i = 0; i < body.children.length; i++) {
                const child = body.children[i];
                if (child.className === "bili-mini-mask") {
                    console.log("Login box detected");
                    document
                        .querySelector(".bili-mini-mask .bili-mini-close-icon")
                        .click();
                    document
                        .querySelector(
                            ".bpx-player-control-bottom-left > .bpx-player-ctrl-play"
                        )
                        .click();
                    break;
                }
            }
        }, 1000);
    }

    const ob = new MutationObserver(() => {
        resume();
    });

    ob.observe(body, { attributes: false, childList: true, subtree: false });
})();