From cdef4a7c90b538af0e1760b10e80c85373ea87cc Mon Sep 17 00:00:00 2001 From: Hakadao Date: Sun, 19 Jan 2025 23:46:24 +0800 Subject: [PATCH] fix(top-bar): prevent top bar from covering content (#1276) close #1276 --- src/components/TopBar/OldTopBar.vue | 13 ++++++++++--- src/components/TopBar/TopBar.vue | 11 +++++++++-- src/contentScripts/index.ts | 3 +-- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/components/TopBar/OldTopBar.vue b/src/components/TopBar/OldTopBar.vue index 9d3b2d84..73ba3a89 100644 --- a/src/components/TopBar/OldTopBar.vue +++ b/src/components/TopBar/OldTopBar.vue @@ -96,9 +96,16 @@ const isTopBarFixed = computed(() => { return false }) -const showTopBar = computed(() => { - const isCreativeCenter = /https?:\/\/member.bilibili.com\/platform.*/.test(location.href) - if (settings.value.showTopBar && !isCreativeCenter) +const showTopBar = computed((): boolean => { + if ( + // Creative center page + /https?:\/\/member.bilibili.com\/platform.*/.test(location.href) + // https://github.com/BewlyBewly/BewlyBewly/issues/1276 + || /https?:\/\/(?:www\.)?bilibili\.com\/read\/(?:preview|pcpreview).*/.test(location.href) + ) { + return false + } + if (settings.value.showTopBar) return true return false }) diff --git a/src/components/TopBar/TopBar.vue b/src/components/TopBar/TopBar.vue index ca24f379..d063b2a9 100644 --- a/src/components/TopBar/TopBar.vue +++ b/src/components/TopBar/TopBar.vue @@ -150,8 +150,15 @@ const isTopBarFixed = computed((): boolean => { }) const showTopBar = computed((): boolean => { - const isCreativeCenter = /https?:\/\/member.bilibili.com\/platform.*/.test(location.href) - if (settings.value.showTopBar && !isCreativeCenter) + if ( + // Creative center page + /https?:\/\/member.bilibili.com\/platform.*/.test(location.href) + // https://github.com/BewlyBewly/BewlyBewly/issues/1276 + || /https?:\/\/(?:www\.)?bilibili\.com\/read\/(?:preview|pcpreview).*/.test(location.href) + ) { + return false + } + if (settings.value.showTopBar) return true return false }) diff --git a/src/contentScripts/index.ts b/src/contentScripts/index.ts index e71b7029..c9c43c96 100644 --- a/src/contentScripts/index.ts +++ b/src/contentScripts/index.ts @@ -70,8 +70,7 @@ function isSupportedPages(): boolean { // channel page e.g. tv shows, movie, variety shows, mooc page || /https?:\/\/(?:www\.)?bilibili\.com\/(?:tv|movie|variety|mooc|documentary).*/.test(currentUrl) // article page - // www.bilibili.com/read/pcpreview 是专栏浏览页, 因布局问题不做适配 #846 - || /https?:\/\/(?:www\.)?bilibili\.com\/read\/(?!pcpreview).*/.test(currentUrl) + || /https?:\/\/(?:www\.)?bilibili\.com\/read\/.*/.test(currentUrl) // 404 page || /^https?:\/\/(?:www\.)?bilibili\.com\/404.*$/.test(currentUrl) // creative center page 創作中心頁