diff --git a/CHANGELOG.md b/CHANGELOG.md index 5344746..b3fe625 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## 4.1.1 +- 新增:直播页 默认网页全屏播放 - 更新:收录更多AI机器人 - 更新:播放页 右栏净化 diff --git a/src/modules/rules/live/groups/basic.ts b/src/modules/rules/live/groups/basic.ts index 553cf99..b320ca8 100644 --- a/src/modules/rules/live/groups/basic.ts +++ b/src/modules/rules/live/groups/basic.ts @@ -1,5 +1,6 @@ import { unsafeWindow } from '$' import { Item } from '@/types/item' +import { waitForBody } from '@/utils/init' import { error } from '@/utils/logger' export const liveBasicItems: Item[] = [ @@ -22,7 +23,7 @@ export const liveBasicItems: Item[] = [ { type: 'switch', id: 'activity-live-auto-jump', - name: '活动直播页 自动跳转普通直播 (实验功能)', + name: '活动直播自动跳转普通直播 (实验功能)', noStyle: true, enableFn: async () => { let cnt = 0 @@ -39,6 +40,37 @@ export const liveBasicItems: Item[] = [ }, enableFnRunAt: 'document-end', }, + { + type: 'switch', + id: 'live-page-default-webscreen', + name: '默认网页全屏播放 (实验功能)', + noStyle: true, + enableFn: async () => { + waitForBody().then(() => { + document.body.classList.add('player-full-win') + document.body.classList.add('over-hidden') + }) + document.addEventListener('DOMContentLoaded', () => { + let cnt = 0 + const id = setInterval(() => { + const player = unsafeWindow.EmbedPlayer?.instance || unsafeWindow.livePlayer + if (player) { + requestAnimationFrame(() => { + document.body.classList.remove('player-full-win') + document.body.classList.remove('over-hidden') + player.setFullscreenStatus(1) + }) + clearInterval(id) + } else { + cnt++ + if (cnt > 10) { + clearInterval(id) + } + } + }, 1000) + }) + }, + }, { type: 'switch', id: 'auto-best-quality', diff --git a/src/types/global.d.ts b/src/types/global.d.ts index fab3c49..7a73e3f 100644 --- a/src/types/global.d.ts +++ b/src/types/global.d.ts @@ -17,6 +17,7 @@ export declare global { }[] } switchQuality?: function + setFullscreenStatus?: function } } livePlayer?: { @@ -28,6 +29,7 @@ export declare global { }[] } switchQuality?: function + setFullscreenStatus?: function } } } diff --git a/src/utils/init.ts b/src/utils/init.ts index 87d704a..359dd16 100644 --- a/src/utils/init.ts +++ b/src/utils/init.ts @@ -3,6 +3,7 @@ export const waitForHead = () => { return new Promise((resolve) => { if (document.head) { resolve() + return } const observer = new MutationObserver(() => { if (document.head) { @@ -19,6 +20,7 @@ export const waitForBody = () => { return new Promise((resolve) => { if (document.body) { resolve() + return } const observer = new MutationObserver(() => { if (document.body) {