Greasy Fork

Greasy Fork is available in English.

Bilibili网页全屏自动点击脚本

在Bilibili网站上自动点击网页全屏按钮实现全屏浏览视频的功能。

当前为 2023-06-20 提交的版本,查看 最新版本

// ==UserScript==
// @name         Bilibili网页全屏自动点击脚本
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  在Bilibili网站上自动点击网页全屏按钮实现全屏浏览视频的功能。
// @author       Bling Cc
// @match        https://*.bilibili.com/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    window.addEventListener('load', function() {
        var fullScreenButton = document.querySelector('div[aria-label="网页全屏"]');
        if (fullScreenButton) {
            var rect = fullScreenButton.getBoundingClientRect();
            var x = rect.left + (rect.width / 2);
            var y = rect.top + (rect.height / 2);

            var event = new MouseEvent('click', {
                view: window,
                bubbles: true,
                cancelable: true,
                clientX: x,
                clientY: y
            });

            setTimeout(function() {
                fullScreenButton.dispatchEvent(event);
            }, 2000);
        }
    });
})();