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()