Skip to content

Commit

Permalink
fix: exchange player position bug #80
Browse files Browse the repository at this point in the history
  • Loading branch information
festoney8 committed Jun 4, 2024
1 parent ea51983 commit 1d1b82c
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 3.6.4

- 新增:播放页展开完整视频标题
- 修复:交换播放器和标题位置后,宽屏模式遮盖UP主bug
- 优化:优化代码、优化功能细节

## 3.6.3
Expand Down
2 changes: 1 addition & 1 deletion src/components/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class Group {
e.querySelector('.bili-cleaner-group')!.id = this.groupID
e.querySelector('.bili-cleaner-group-title')!.innerHTML = this.title.replaceAll('\n', '<br>')

const groupList = document.getElementById('bili-cleaner-group-list') as HTMLFormElement
const groupList = document.getElementById('bili-cleaner-group-list') as HTMLElement
groupList.appendChild(e)
}
/** 插入group内item列表, 并逐一监听 */
Expand Down
8 changes: 4 additions & 4 deletions src/components/item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class CheckboxItem implements IItem {
if (this.isEnable) {
e.querySelector('input')!.checked = true
}
const itemGroupList = document.querySelector(`#${groupID} .bili-cleaner-item-list`) as HTMLFormElement
const itemGroupList = document.querySelector(`#${groupID} .bili-cleaner-item-list`) as HTMLElement
if (itemGroupList) {
itemGroupList.appendChild(e)
debug(`insertItem ${this.option.itemID} OK`)
Expand Down Expand Up @@ -247,7 +247,7 @@ export class RadioItem implements IItem {
}
// 设定radio input所属互斥组
e.querySelector('input')!.name = this.option.radioName
const itemGroupList = document.querySelector(`#${groupID} .bili-cleaner-item-list`) as HTMLFormElement
const itemGroupList = document.querySelector(`#${groupID} .bili-cleaner-item-list`) as HTMLElement
if (itemGroupList) {
itemGroupList.appendChild(e)
debug(`insertItem ${this.option.itemID} OK`)
Expand Down Expand Up @@ -428,7 +428,7 @@ export class NumberItem implements IItem {
inputNode.setAttribute('value', this.itemValue!.toString())
inputNode.setAttribute('min', this.option.minValue.toString())
inputNode.setAttribute('max', this.option.maxValue.toString())
const itemGroupList = document.querySelector(`#${groupID} .bili-cleaner-item-list`) as HTMLFormElement
const itemGroupList = document.querySelector(`#${groupID} .bili-cleaner-item-list`) as HTMLElement
if (itemGroupList) {
itemGroupList.appendChild(node)
debug(`insertItem ${this.option.itemID} OK`)
Expand Down Expand Up @@ -572,7 +572,7 @@ export class ButtonItem implements IItem {
node.id = this.option.itemID
node.innerHTML = `${this.nodeHTML}${this.option.description.replaceAll('\n', '<br>')}`
node.querySelector('button')!.innerHTML = this.option.name
const itemGroupList = document.querySelector(`#${groupID} .bili-cleaner-item-list`) as HTMLFormElement
const itemGroupList = document.querySelector(`#${groupID} .bili-cleaner-item-list`) as HTMLElement
if (itemGroupList) {
itemGroupList.appendChild(node)
debug(`insertItem ${this.option.itemID} OK`)
Expand Down
12 changes: 6 additions & 6 deletions src/components/panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class Panel {
/** 右上角关闭按钮 */
watchCloseBtn() {
try {
const closeBtn = document.getElementById('bili-cleaner-close') as HTMLFormElement
const closeBtn = document.getElementById('bili-cleaner-close') as HTMLElement
closeBtn.addEventListener('click', () => {
this.hide()
})
Expand All @@ -71,8 +71,8 @@ export class Panel {
/** 可拖拽panel bar, 拖拽panel顶部的bar可移动panel, 其他区域不可拖拽 */
draggableBar() {
try {
const panel = document.getElementById('bili-cleaner') as HTMLFormElement
const bar = document.getElementById('bili-cleaner-bar') as HTMLFormElement
const panel = document.getElementById('bili-cleaner') as HTMLElement
const bar = document.getElementById('bili-cleaner-bar') as HTMLElement
let isDragging = false
let initX: number, initY: number, initLeft: number, initTop: number

Expand Down Expand Up @@ -125,7 +125,7 @@ export class Panel {
}
/** 隐藏panel */
hide() {
const panel = document.getElementById('bili-cleaner') as HTMLFormElement
const panel = document.getElementById('bili-cleaner') as HTMLElement
if (panel) {
// 使用 display:none 代替 remove(), 同一页面内再次打开panel记录上次位置
panel.style.display = 'none'
Expand All @@ -134,15 +134,15 @@ export class Panel {
}
/** 显示panel */
show() {
const panel = document.getElementById('bili-cleaner') as HTMLFormElement
const panel = document.getElementById('bili-cleaner') as HTMLElement
if (panel) {
panel.style.removeProperty('display')
}
this.isShowing = true
}
/** 清空panel内groups, 用于替换功能group */
clearGroups() {
const groupList = document.getElementById('bili-cleaner-group-list') as HTMLFormElement
const groupList = document.getElementById('bili-cleaner-group-list') as HTMLElement
if (groupList) {
groupList.innerHTML = ''
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/wordlist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ export class WordList {
/** 可拖拽bar */
draggableBar() {
try {
const wordlist = document.getElementById('bili-cleaner-wordlist') as HTMLFormElement
const bar = document.querySelector('#bili-cleaner-wordlist .wordlist-header') as HTMLFormElement
const wordlist = document.getElementById('bili-cleaner-wordlist') as HTMLElement
const bar = document.querySelector('#bili-cleaner-wordlist .wordlist-header') as HTMLElement
let isDragging = false
let initX: number, initY: number, initLeft: number, initTop: number

Expand Down
58 changes: 57 additions & 1 deletion src/rules/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { CheckboxItem } from '../components/item'
import { debugRules as debug, error } from '../utils/logger'
import { matchAvidBvid, matchBvid } from '../utils/tool'
import { isPageFestival, isPagePlaylist, isPageVideo } from '../utils/page-type'
import { GM_getValue, GM_setValue } from '$'
import { GM_getValue, GM_setValue, unsafeWindow } from '$'

/** BV号转AV号 */
const bv2av = () => {
Expand Down Expand Up @@ -263,6 +263,62 @@ if (isPageVideo() || isPagePlaylist()) {
margin-bottom: 0 !important;
}
`,
// fix #80 宽屏模式下播放器遮盖up主
itemFunc: () => {
let _isWide = window.isWide
const onIsWideChange = (isWide: boolean) => {
if (isWide) {
let cnt = 0
const id = setInterval(() => {
const player = document.querySelector(
`.bpx-player-container[data-screen="wide"]`,
) as HTMLElement
if (player) {
const top = parseInt(getComputedStyle(player).height) + 50
const upPanel = document.querySelector('.up-panel-container') as HTMLElement
if (upPanel) {
upPanel.style.position = 'relative'
upPanel.style.top = `${top}px`
}
const danmakuBox = document.querySelector('#danmukuBox') as HTMLElement
if (danmakuBox) {
danmakuBox.style.marginTop = `${top}px`
}
clearInterval(id)
} else {
cnt++
if (cnt > 100) {
clearInterval(id)
}
}
}, 10)
} else {
const upPanel = document.querySelector('.up-panel-container') as HTMLElement
if (upPanel) {
upPanel.style.position = 'static'
upPanel.style.top = '0'
}
const danmakuBox = document.querySelector('#danmukuBox') as HTMLElement
if (danmakuBox) {
danmakuBox.style.marginTop = '0'
}
}
}
window.isWide && onIsWideChange(true)
Object.defineProperty(unsafeWindow, 'isWide', {
get() {
return _isWide
},
set(value) {
_isWide = value
if (typeof _isWide === 'boolean') {
onIsWideChange(_isWide)
}
},
configurable: true,
enumerable: true,
})
},
}),
]
videoGroupList.push(new Group('video-basic', '播放页 基本功能', basicItems))
Expand Down

0 comments on commit 1d1b82c

Please sign in to comment.