From 6b494c03b7c0b94e5340ac138c29924729594828 Mon Sep 17 00:00:00 2001 From: josc146 Date: Tue, 20 Feb 2024 13:42:34 +0800 Subject: [PATCH] improve bilibili video path detection --- src/content-script/site-adapters/bilibili/index.mjs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/content-script/site-adapters/bilibili/index.mjs b/src/content-script/site-adapters/bilibili/index.mjs index e7a72b4..f2d2d65 100644 --- a/src/content-script/site-adapters/bilibili/index.mjs +++ b/src/content-script/site-adapters/bilibili/index.mjs @@ -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) } }