// ==UserScript== // @author Feny // @license MIT // @version 0.6 // @name 哔哩哔哩、腾讯视频、芒果TV自动网页全屏(个人自用) // @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/* // @downloadURL none // ==/UserScript== (function () { "use strict"; // 监听URL变化 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; }; }; 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")); }, }; webfullscreen.init(); window.addEventListener("popstate", () => webfullscreen.init()); window.addEventListener("pushState", () => webfullscreen.init()); history.pushState = location.host.includes("v.qq.com") ? _wr("popstate") : _wr("pushState"); })();