Detect cid on video collection pages

This commit is contained in:
the1812 2020-12-24 11:10:47 +08:00
parent 2e4137f940
commit f7ce90935e

View File

@ -75,7 +75,21 @@ export class Observer {
})
}
static async videoChange (callback) {
const cid = await SpinQuery.select(() => unsafeWindow.cid)
const cid = await SpinQuery.select(() => {
if (unsafeWindow.cid) {
return unsafeWindow.cid
}
if (unsafeWindow.player?.getVideoMessage) {
const info = unsafeWindow.player.getVideoMessage()
if (Number.isNaN(info.cid)) {
return null
}
if (!unsafeWindow.aid) {
unsafeWindow.aid = info?.aid?.toString()
}
return info?.cid?.toString()
}
})
if (cid === null) {
return
}
@ -95,7 +109,7 @@ export class Observer {
cidHooked = true
}
// callback();
const videoContainer = await SpinQuery.select('#bilibili-player video')
const videoContainer = await SpinQuery.select('.bilibili-player-video video')
if (videoContainer) {
Observer.childList(videoContainer, callback)
} else {