From 57d0bcfb996595193fe67a945bff58f584e1f978 Mon Sep 17 00:00:00 2001 From: Hakadao Date: Sun, 3 Sep 2023 01:53:26 +0800 Subject: [PATCH] feat: make top bar not fixed in search page --- src/contentScripts/views/App.vue | 46 +++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/src/contentScripts/views/App.vue b/src/contentScripts/views/App.vue index 4e3481a6..50d56423 100644 --- a/src/contentScripts/views/App.vue +++ b/src/contentScripts/views/App.vue @@ -43,7 +43,7 @@ const showTopbarMask = ref(false) const dynamicComponentKey = ref(`dynamicComponent${Number(new Date())}`) // const isVideoPage = ref(false) -// const isBilibiliHomePage = ref(false) +// const isHomePage = ref(false) const tooltipPlacement = computed(() => { if (settings.value.dockPosition === 'left') @@ -55,13 +55,7 @@ const tooltipPlacement = computed(() => { return 'right' }) -const isVideoPage = computed(() => { - if (/https?:\/\/(www.)?bilibili.com\/video\/.*/.test(location.href)) - return true - return false -}) - -const isBilibiliHomePage = computed(() => { +const isHomePage = computed(() => { if ( /https?:\/\/bilibili.com\/?$/.test(location.href) || /https?:\/\/www.bilibili.com\/?$/.test(location.href) @@ -73,6 +67,20 @@ const isBilibiliHomePage = computed(() => { return false }) +const isVideoPage = computed(() => { + if (/https?:\/\/(www.)?bilibili.com\/video\/.*/.test(location.href)) + return true + return false +}) + +const isSearchPage = computed(() => { + if ( + /https?:\/\/search.bilibili.com\/.*$/.test(location.href) + ) + return true + return false +}) + watch( () => activatedPage.value, () => { @@ -127,7 +135,7 @@ onMounted(() => { }, 1200) }) - if (isBilibiliHomePage.value) { + if (isHomePage.value) { // Force overwrite Bilibili Evolved body tag & html tag background color document.body.style.setProperty('background-color', 'unset', 'important') document.documentElement.style.setProperty('background-color', 'unset', 'important') @@ -157,7 +165,7 @@ onMounted(() => { else showTopbarMask.value = false }) - if (!isBilibiliHomePage.value) { + if (!isHomePage.value) { const originalTopBar: HTMLElement = document.querySelector('#biliMainHeader, #bili-header-container') as HTMLElement if (originalTopBar) originalTopBar.style.visibility = 'hidden' @@ -253,7 +261,7 @@ function handleBackToTop() {