Bilibili视频播放自动网页全屏

B站视频播放自动网页全屏

// ==UserScript==
// @name         Bilibili视频播放自动网页全屏
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  B站视频播放自动网页全屏
// @author       lscsczl
// @license      MIT
// @match        https://www.bilibili.com/video/*
// @grant        none
// @icon         http://bilibili.com/favicon.ico
// ==/UserScript==

(function() {
    'use strict';
    document.addEventListener("DOMContentLoaded", function() {
        var customCtrlButton = document.querySelector('.bpx-player-ctrl-btn.bpx-player-ctrl-web');

        if (customCtrlButton) {
            customCtrlButton.click();

            console.log('Yes');
        } else {
            console.log('No');
        }
    });
    var observer = new MutationObserver(function(mutationsList) {
        mutationsList.forEach(function(mutation) {
            Array.from(mutation.addedNodes).forEach(function(node) {
                if (node.nodeType === Node.ELEMENT_NODE && node.classList.contains('bpx-player-ctrl-btn') && node.classList.contains('bpx-player-ctrl-web')) {
                    node.click();
                    console.log('Fine');
                }
            });
        });
    });
    observer.observe(document.body, {childList: true, subtree: true});
})();