Merge pull request #5307 from wsgh0202/fix-removePromotions

【修复】删除广告组件部分广告屏蔽失效
This commit is contained in:
Grant Howard 2025-07-25 20:18:21 +08:00 committed by GitHub
commit 27f41b0370
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 56 additions and 8 deletions

View File

@ -1,4 +1,7 @@
删除站内的各种广告. 包括首页的推广模块, 手机 app 推荐, 视频页面右侧的广告等. 注意: 首页推广模块删除后留下空白区域是正常现象, 如果觉得怪可以开启 \`占位文本\` 选项.
删除站内的各种广告. 包括首页的推广模块, 手机 app 推荐, 视频页面右侧的广告等.
- \`占位文本\`: 删除首页推广模块的广告后显示"🚫已屏蔽广告"来替代空白区域.
- \`保留活动横幅\`: 保留视频页面的活动横幅.
> 注意: 首页推广模块删除后留下空白区域是正常现象, 如果觉得怪可以开启 `占位文本` 选项.
- `占位文本`: 删除首页推广模块的广告后显示"🚫已屏蔽广告"来替代空白区域.
- `保留活动横幅`: 保留视频页面的活动横幅.
- `debug`: 调试模式,用于查看是否正确屏蔽广告

View File

@ -88,6 +88,13 @@ const entry: ComponentEntry = async ({ settings, metadata }) => {
},
true,
)
addComponentListener(
`${metadata.name}.debug`,
(value: boolean) => {
document.body.classList.toggle('debug', value)
},
true,
)
}
export const component = defineComponentMetadata({
name: 'removePromotions',
@ -113,5 +120,9 @@ export const component = defineComponentMetadata({
displayName: '保留动态商品推荐',
defaultValue: false,
},
debug: {
displayName: '调试模式',
defaultValue: false,
},
},
})

View File

@ -90,9 +90,43 @@ body.dark .blocked-ads.new {
body:not(.preserve-feed-goods) .bili-dyn-content__orig__additional:has(.dyn-goods) {
margin: 0 !important;
}
.feed-card:has(.bili-video-card a[href*='cm.bilibili.com']),
.bili-video-card.is-rcmd:has(a[href*='cm.bilibili.com']),
.bili-video-card__wrap:has(a[href*='cm.bilibili.com']),
body:not(.promotion-show-placeholder) :is(.bili-video-card.is-rcmd, .bili-feed4-layout .feed-card):not(:has(.bili-video-card__wrap)) {
display: none !important;
// 首页广告推广
.bili-video-card__wrap:has(.bili-video-card__stats > :is(.bili-video-card__stats--text, svg)),
// 视频搜索页广告
.bili-video-card__wrap:has(.bili-video-card__info--ad) {
visibility: hidden;
pointer-events: none !important;
// 占位文本
& .bili-video-card__image::after {
@extend .blocked-ads;
content: '🚫已屏蔽广告';
width: 100%;
height: 100%;
position: absolute;
top: 0;
user-select: none;
visibility: hidden;
border-radius: 6px;
background-color: #eee;
body.dark & {
background-color: #333;
}
body.promotion-show-placeholder & {
visibility: visible;
}
body.debug & {
visibility: hidden !important;
}
}
body.debug & {
visibility: visible;
border: red 1px solid;
}
}