Greasy Fork

Greasy Fork is available in English.

视频网站自动网页全屏

哔哩哔哩、腾讯视频、芒果TV自动网页全屏

当前为 2024-12-05 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @version      0.5
// @author       Feny
// @license      MIT
// @name         视频网站自动网页全屏
// @namespace    http://tampermonkey.net/
// @description  哔哩哔哩、腾讯视频、芒果TV自动网页全屏
// @icon         https://i0.hdslb.com/bfs/static/jinkela/long/images/favicon.ico
// @include      http*://www.mgtv.com/b/*
// @include      http*://v.qq.com/x/cover/*
// @include      http*://www.bilibili.com/video/*
// @include      http*://www.bilibili.com/bangumi/play/*
// ==/UserScript==

(function () {
    "use strict";
    // 监听URL变化
    const type = location.host.includes("bilibili") ? "popstate" : "pushState"
    const _wr = function (type) {
        const orig = history[type];
        return function () {
            const rv = orig.apply(this, arguments);
            const e = new Event(type);
            e.arguments = arguments;
            window.dispatchEvent(e);
            return rv;
        };
    };
    history[type] = _wr("popstate")

    const webfullscreen = {
        init() {
            const interval = setInterval(() => {
                const element = this.getElement()
                if (element) this.fullScreen(element) & clearInterval(interval);
            }, 300);
        },
        getElement() {
            return document.querySelector('div[aria-label="网页全屏"]')
                || document.querySelector(".bpx-player-ctrl-web")
                || document.querySelector(".webfullscreenBtn i")
        },
        fullScreen(elem) {
            if (!elem) return
            elem.click ? elem.click() : elem.dispatchEvent(new Event("click"));
            console.log('网页全屏成功!!!')
        },
    };

    webfullscreen.init();
    window.addEventListener("popstate", () => webfullscreen.init());
})();