mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import { attributes } from '@/core/observer'
|
|
import { addComponentListener, getComponentSettings } from '@/core/settings'
|
|
import { sq } from '@/core/spin-query'
|
|
import { mainSiteUrls, matchCurrentPage } from '@/core/utils/urls'
|
|
|
|
/**
|
|
* 检查是否应用透明填充(有横幅时)
|
|
*/
|
|
export const checkTransparentFill = async (vm: {
|
|
toggleStyle: (value: boolean, style: string) => void
|
|
}) => {
|
|
if (!matchCurrentPage(mainSiteUrls)) {
|
|
return
|
|
}
|
|
sq(
|
|
() => dq('#banner_link,.international-header .bili-banner, .bili-header__banner'),
|
|
banner => (banner === null ? false : Boolean((banner as HTMLElement).style.backgroundImage)),
|
|
).then((banner: HTMLElement) => {
|
|
if (!banner) {
|
|
return
|
|
}
|
|
attributes(banner, () => {
|
|
addComponentListener('customNavbar.transparent', value => {
|
|
if (!getComponentSettings('hideBanner').enabled) {
|
|
vm.toggleStyle(value, 'transparent')
|
|
}
|
|
}, true)
|
|
addComponentListener('hideBanner', value => {
|
|
if (getComponentSettings('customNavbar').options.transparent) {
|
|
vm.toggleStyle(!value, 'transparent')
|
|
}
|
|
})
|
|
})
|
|
})
|
|
}
|