From 88cfaebb9d83ed0541a385284ab05abb5147f58c Mon Sep 17 00:00:00 2001 From: Hakadao Date: Mon, 6 Jan 2025 01:56:52 +0800 Subject: [PATCH] fix: top bar displayed on the unexpected pages (#1246,#1247,#1248) closes #1246 #1247 #1248 --- src/contentScripts/index.ts | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/contentScripts/index.ts b/src/contentScripts/index.ts index be10dfb7..c5f7a8c5 100644 --- a/src/contentScripts/index.ts +++ b/src/contentScripts/index.ts @@ -31,6 +31,8 @@ if (isFirefox) { const currentUrl = document.URL function isSupportedPages(): boolean { + if (isInIframe()) + return false if ( // homepage isHomePage() @@ -83,10 +85,23 @@ function isSupportedPages(): boolean { } } -export function isBlockedPages(): boolean { +// Only support dock record original bilibili page +export function isSupportedIframePages(): boolean { if ( - // https://github.com/BewlyBewly/BewlyBewly/issues/1246 - /https?:\/\/(?:t\.)?bilibili\.com\/share\/card\/index.*/.test(currentUrl) + isInIframe() + && ( + isHomePage() + || /https?:\/\/search\.bilibili\.com\/all.*/.test(currentUrl) + || /https?:\/\/www\.bilibili\.com\/anime.*/.test(currentUrl) + || /https?:\/\/space\.bilibili\.com\/\d+\/favlist.*/.test(currentUrl) + || /https?:\/\/www\.bilibili\.com\/history.*/.test(currentUrl) + || /https?:\/\/www\.bilibili\.com\/watchlater\/#\/list.*/.test(currentUrl) + || ( + /https?:\/\/t\.bilibili\.com.*/.test(currentUrl) + // https://github.com/BewlyBewly/BewlyBewly/issues/1246 + && !/https?:\/\/t\.bilibili\.com\/share\/card\/index.*/.test(currentUrl) + ) + ) ) { return true } @@ -97,7 +112,7 @@ export function isBlockedPages(): boolean { let beforeLoadedStyleEl: HTMLStyleElement | undefined -if (isSupportedPages() && !isBlockedPages()) { +if (isSupportedPages() || isSupportedIframePages()) { if (settings.value.adaptToOtherPageStyles) useDark() @@ -162,7 +177,7 @@ async function onDOMLoaded() { document.body.appendChild(originalTopBar) } - if (isSupportedPages() && !isBlockedPages()) { + if (isSupportedPages() || isSupportedIframePages()) { // Then inject the app if (isHomePage()) { injectApp()