fix: top bar displayed on the unexpected pages (#1246,#1247,#1248)

closes #1246 #1247 #1248
This commit is contained in:
Hakadao
2025-01-06 01:56:52 +08:00
parent e4b4666a1d
commit 88cfaebb9d

View File

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