From 6e0cf8f3deea05f46dd2e76cf08b007b4a736e2d Mon Sep 17 00:00:00 2001 From: josc146 Date: Thu, 25 Jan 2024 17:31:28 +0800 Subject: [PATCH] improve #603 --- src/content-script/site-adapters/bilibili/index.mjs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/content-script/site-adapters/bilibili/index.mjs b/src/content-script/site-adapters/bilibili/index.mjs index 932db1fb..aa831b91 100644 --- a/src/content-script/site-adapters/bilibili/index.mjs +++ b/src/content-script/site-adapters/bilibili/index.mjs @@ -6,14 +6,14 @@ export default { try { // B站页面是SSR的,如果插入过早,页面 js 检测到实际 Dom 和期望 Dom 不一致,会导致重新渲染 await waitForElementToExistAndSelect('img.bili-avatar-img') - let oldUrl = location.href - const checkUrlChange = async () => { - if (location.href !== oldUrl) { - oldUrl = location.href + let oldPath = location.pathname + const checkPathChange = async () => { + if (location.pathname !== oldPath) { + oldPath = location.pathname mountComponent(config.bilibili, userConfig) } } - window.setInterval(checkUrlChange, 500) + window.setInterval(checkPathChange, 500) } catch (e) { /* empty */ }