mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
Improve cid hook compatibility (fix #3005)
This commit is contained in:
parent
055934a3b6
commit
bb8b914072
@ -272,17 +272,17 @@ export const videoChange = async (
|
||||
window.dispatchEvent(event)
|
||||
}
|
||||
if (!cidHooked) {
|
||||
let hookedCid = cid
|
||||
Object.defineProperty(unsafeWindow, 'cid', {
|
||||
get() {
|
||||
return hookedCid
|
||||
},
|
||||
set(newId) {
|
||||
hookedCid = newId
|
||||
if (!Array.isArray(newId)) {
|
||||
fireEvent()
|
||||
}
|
||||
},
|
||||
let lastCid = cid
|
||||
allMutations(() => {
|
||||
const { cid: newCid } = getId()
|
||||
// b 站代码的神秘行为, 在更换 cid 时会临时改成一个数组, 做监听要忽略这种值
|
||||
if (Array.isArray(newCid)) {
|
||||
return
|
||||
}
|
||||
if (lastCid !== newCid) {
|
||||
fireEvent()
|
||||
lastCid = newCid
|
||||
}
|
||||
})
|
||||
cidHooked = true
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user