diff --git a/src/_locales/cmn-CN.yml b/src/_locales/cmn-CN.yml
index baa42614..ebd77ff4 100644
--- a/src/_locales/cmn-CN.yml
+++ b/src/_locales/cmn-CN.yml
@@ -67,6 +67,7 @@ settings:
enable_horizontal_scrolling_desc: 启用后,鼠标滚动时将直接滚动横向滚动列表
enable_video_ctrl_bar_on_video_card: 在视频卡片上显示视频控制栏
hover_video_card_delayed: 将鼠标悬停在视频卡片上时延迟视频预览
+ block_ads: 屏蔽广告
auto_hide_topbar: 自动隐藏顶栏
dock_position: Dock 栏位置
dock_position_desc: 在屏幕中摆放位置
diff --git a/src/_locales/cmn-TW.yml b/src/_locales/cmn-TW.yml
index 15da687e..a56fe174 100644
--- a/src/_locales/cmn-TW.yml
+++ b/src/_locales/cmn-TW.yml
@@ -67,6 +67,7 @@ settings:
enable_horizontal_scrolling_desc: 啟用後,滑鼠捲動時將直接捲動橫向捲軸列表
enable_video_ctrl_bar_on_video_card: 在影片卡片上顯示影片控制欄
hover_video_card_delayed: 將滑鼠懸停在影片卡片上時延遲影片預覽
+ block_ads: 封鎖廣告
auto_hide_topbar: 自動隱藏頂欄
dock_position: Dock 位置
dock_position_desc: 螢幕上的位置
diff --git a/src/_locales/en.yml b/src/_locales/en.yml
index b4c0b0af..1e51303e 100644
--- a/src/_locales/en.yml
+++ b/src/_locales/en.yml
@@ -67,6 +67,7 @@ settings:
enable_horizontal_scrolling_desc: After enabling, mouse scrolling will directly scroll the horizontal scroll list
enable_video_ctrl_bar_on_video_card: Display the video control bar on the video card
hover_video_card_delayed: Delayed video preview on hover over the video card
+ block_ads: Block ads
auto_hide_topbar: Automatically hide the top bar
dock_position: Dock position
dock_position_desc: Position on screen
diff --git a/src/_locales/jyut.yml b/src/_locales/jyut.yml
index ef9cd97f..99322813 100644
--- a/src/_locales/jyut.yml
+++ b/src/_locales/jyut.yml
@@ -67,6 +67,7 @@ settings:
enable_horizontal_scrolling_desc: 用咗之後,轆緊滑鼠就可以直接打橫掃水平捲軸列表
enable_video_ctrl_bar_on_video_card: 喺影片卡片上顯示影片控制欄
hover_video_card_delayed: 滑鼠停留喺影片卡片嗰陣遲啲進行影片預覽
+ block_ads: 封鎖廣告
auto_hide_topbar: 自動收埋頂欄
dock_position: Dock 放位
dock_position_desc: 放喺螢幕邊度
diff --git a/src/components/Settings/components/General.vue b/src/components/Settings/components/General.vue
index 660bb9ee..f91a8cc0 100644
--- a/src/components/Settings/components/General.vue
+++ b/src/components/Settings/components/General.vue
@@ -101,6 +101,9 @@ function handleToggleDockItem(dockItem: any) {
+
+
+
diff --git a/src/contentScripts/views/App.vue b/src/contentScripts/views/App.vue
index 84b3e4be..1d360ac0 100644
--- a/src/contentScripts/views/App.vue
+++ b/src/contentScripts/views/App.vue
@@ -94,6 +94,16 @@ watch(() => settings.value.adaptToOtherPageStyles, () => {
handleAdaptToOtherPageStylesChange()
})
+watch(() => settings.value.blockAds, () => {
+ handleBlockAds()
+})
+
+onBeforeMount(() => {
+ handleBlockAds()
+ setAppThemeColor()
+ handleAdaptToOtherPageStylesChange()
+})
+
onMounted(() => {
// openVideoPageIfBvidExists()
@@ -114,8 +124,6 @@ onMounted(() => {
handleChangeAccessKey()
setAppAppearance()
setAppLanguage()
- setAppThemeColor()
- handleAdaptToOtherPageStylesChange()
})
function handleChangeAccessKey() {
@@ -237,6 +245,13 @@ function handleOsScroll() {
topBarRef.value?.handleScroll()
}
+function handleBlockAds() {
+ if (settings.value.blockAds)
+ document.documentElement.classList.add('block-ads')
+ else
+ document.documentElement.classList.remove('block-ads')
+}
+
// fix #166 https://github.com/hakadao/BewlyBewly/issues/166
// function openVideoPageIfBvidExists() {
// Assume the URL is https://www.bilibili.com/?bvid=BV1be41127ft&spm_id_from=333.788.seo.out
diff --git a/src/logic/storage.ts b/src/logic/storage.ts
index 5ad467d6..6a041f2e 100644
--- a/src/logic/storage.ts
+++ b/src/logic/storage.ts
@@ -14,6 +14,7 @@ export interface Settings {
enableVideoCtrlBarOnVideoCard: boolean
hoverVideoCardDelayed: boolean
autoHideTopBar: boolean
+ blockAds: boolean
dockPosition: 'left' | 'right' | 'bottom'
autoHideDock: boolean
dockItemVisibilityList: { page: AppPage, visible: boolean }[]
@@ -57,6 +58,7 @@ export const settings = useStorageLocal('settings', ref({
autoHideTopBar: false,
dockPosition: 'right',
autoHideDock: false,
+ blockAds: false,
dockItemVisibilityList: [],
theme: 'auto',
diff --git a/src/styles/blockAds.scss b/src/styles/blockAds.scss
new file mode 100644
index 00000000..3046d6a1
--- /dev/null
+++ b/src/styles/blockAds.scss
@@ -0,0 +1,23 @@
+.block-ads {
+ // 原版首頁最右則推介內容
+ .floor-single-card,
+ // 首頁不能使用不感興趣的影片都當廣告殺了
+ .feed-card:has(.bili-video-card.is-rcmd:not(.enable-no-interest)),
+ .bili-video-card.is-rcmd:not(.enable-no-interest),
+ .ad-report,
+ .brand-ad-list,
+ // 搜尋結果的遊戲廣告
+ .activity-game-list,
+ // 视频页游戏卡片
+ .video-page-game-card-small,
+ // 大家围观的直播
+ .pop-live-small-mode {
+ display: none !important;
+ }
+
+ // 首頁推介頂部卡片間距調整
+ .recommended-container_floor-aside .container>*:nth-of-type(n + 8) {
+ margin-top: 0px !important;
+ margin-bottom: 24px;
+ }
+}
diff --git a/src/styles/index.ts b/src/styles/index.ts
index 234d9afa..25ac1b9c 100644
--- a/src/styles/index.ts
+++ b/src/styles/index.ts
@@ -5,3 +5,4 @@ import './reset.scss'
import 'uno.css'
import './adaptedStyles'
import './transitionAndTransitionGroup.scss'
+import './blockAds.scss'