Skip to content

Commit

Permalink
feat: live page default webscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
festoney8 committed Jan 2, 2025
1 parent 92232b5 commit 1218236
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 4.1.1

- 新增:直播页 默认网页全屏播放
- 更新:收录更多AI机器人
- 更新:播放页 右栏净化

Expand Down
34 changes: 33 additions & 1 deletion src/modules/rules/live/groups/basic.ts
Original file line number Diff line number Diff line change
@@ -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[] = [
Expand All @@ -22,7 +23,7 @@ export const liveBasicItems: Item[] = [
{
type: 'switch',
id: 'activity-live-auto-jump',
name: '活动直播页 自动跳转普通直播 (实验功能)',
name: '活动直播自动跳转普通直播 (实验功能)',
noStyle: true,
enableFn: async () => {
let cnt = 0
Expand All @@ -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',
Expand Down
2 changes: 2 additions & 0 deletions src/types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export declare global {
}[]
}
switchQuality?: function
setFullscreenStatus?: function
}
}
livePlayer?: {
Expand All @@ -28,6 +29,7 @@ export declare global {
}[]
}
switchQuality?: function
setFullscreenStatus?: function
}
}
}
2 changes: 2 additions & 0 deletions src/utils/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export const waitForHead = () => {
return new Promise<void>((resolve) => {
if (document.head) {
resolve()
return
}
const observer = new MutationObserver(() => {
if (document.head) {
Expand All @@ -19,6 +20,7 @@ export const waitForBody = () => {
return new Promise<void>((resolve) => {
if (document.body) {
resolve()
return
}
const observer = new MutationObserver(() => {
if (document.body) {
Expand Down

0 comments on commit 1218236

Please sign in to comment.