From a75d02f0cdaa86e34fc6f6e83edba7611383d5a8 Mon Sep 17 00:00:00 2001 From: Hakadao Date: Sun, 26 Jan 2025 07:44:56 +0800 Subject: [PATCH] fix: refactor Bilibili header visibility logic --- src/contentScripts/views/App.vue | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/contentScripts/views/App.vue b/src/contentScripts/views/App.vue index 642ed7a5..a1b3a77c 100644 --- a/src/contentScripts/views/App.vue +++ b/src/contentScripts/views/App.vue @@ -124,17 +124,6 @@ watch( window.history.replaceState({}, '', url.toString()) } - // Remove the original Bilibili top bar when using original bilibili page to avoid two top bars showing - const biliHeader = document.querySelector('.bili-header') as HTMLElement | null - if (biliHeader && isSupportedIframePages()) { - if (settingsStore.getDockItemIsUseOriginalBiliPage(activatedPage.value) && !isInIframe()) { - biliHeader.style.visibility = 'hidden' - } - else { - biliHeader.style.visibility = 'visible' - } - } - if (scrollbarRef.value) { const osInstance = scrollbarRef.value.osInstance() osInstance.elements().viewport.scrollTop = 0 @@ -144,6 +133,19 @@ watch( { immediate: true }, ) +watch([() => showTopBar.value, () => activatedPage.value], () => { + // Remove the original Bilibili top bar when using original bilibili page to avoid two top bars showing + const biliHeader = document.querySelector('.bili-header') as HTMLElement | null + if (biliHeader && isHomePage()) { + if (settingsStore.getDockItemIsUseOriginalBiliPage(activatedPage.value) && !isInIframe()) { + biliHeader.style.visibility = 'hidden' + } + else { + biliHeader.style.visibility = 'visible' + } + } +}, { immediate: true }) + // Setup necessary settings watchers setupNecessarySettingsWatchers()