improve bilibili video path detection

This commit is contained in:
josc146
2024-02-20 13:42:34 +08:00
parent df6840bbf9
commit 6b494c03b7
@@ -6,10 +6,13 @@ export default {
try {
// B站页面是SSR的,如果插入过早,页面 js 检测到实际 Dom 和期望 Dom 不一致,会导致重新渲染
await waitForElementToExistAndSelect('img.bili-avatar-img')
let oldPath = location.pathname
const getVideoPath = () =>
location.pathname + `?p=${new URLSearchParams(location.search).get('p') || 1}`
let oldPath = getVideoPath()
const checkPathChange = async () => {
if (location.pathname !== oldPath) {
oldPath = location.pathname
const newPath = getVideoPath()
if (newPath !== oldPath) {
oldPath = newPath
mountComponent(config.bilibili, userConfig)
}
}