Skip to content

Commit 6b494c0

Browse files
committed
improve bilibili video path detection
1 parent df6840b commit 6b494c0

File tree

1 file changed

+6
-3
lines changed
  • src/content-script/site-adapters/bilibili

1 file changed

+6
-3
lines changed

src/content-script/site-adapters/bilibili/index.mjs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@ export default {
66
try {
77
// B站页面是SSR的,如果插入过早,页面 js 检测到实际 Dom 和期望 Dom 不一致,会导致重新渲染
88
await waitForElementToExistAndSelect('img.bili-avatar-img')
9-
let oldPath = location.pathname
9+
const getVideoPath = () =>
10+
location.pathname + `?p=${new URLSearchParams(location.search).get('p') || 1}`
11+
let oldPath = getVideoPath()
1012
const checkPathChange = async () => {
11-
if (location.pathname !== oldPath) {
12-
oldPath = location.pathname
13+
const newPath = getVideoPath()
14+
if (newPath !== oldPath) {
15+
oldPath = newPath
1316
mountComponent(config.bilibili, userConfig)
1417
}
1518
}

0 commit comments

Comments
 (0)