From 80ae8484f9a1befce480cdbe5554c547321357ec Mon Sep 17 00:00:00 2001 From: festoney8 Date: Mon, 4 Nov 2024 01:36:16 +0800 Subject: [PATCH 1/3] feat: homepage views filter --- CHANGELOG.md | 4 ++ .../filters/variety/comment/pages/dynamic.ts | 14 ---- .../filters/variety/comment/pages/space.ts | 14 ---- .../filters/variety/comment/pages/video.ts | 14 ---- .../filters/variety/dynamic/pages/dynamic.ts | 4 -- .../filters/variety/video/pages/channel.ts | 6 -- .../filters/variety/video/pages/homepage.ts | 65 +++++++++++++++++-- .../filters/variety/video/pages/popular.ts | 6 -- .../filters/variety/video/pages/search.ts | 5 -- .../filters/variety/video/pages/space.ts | 4 -- .../filters/variety/video/pages/video.ts | 6 -- .../filters/variety/video/subFilters/black.ts | 2 + vite.config.ts | 2 +- 13 files changed, 66 insertions(+), 80 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85796883..a9a456bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## 4.0.7 + +- 新增:首页 按播放量过滤 + ## 4.0.6 - 更新:播放页 播放器宽度调节相关样式 diff --git a/src/modules/filters/variety/comment/pages/dynamic.ts b/src/modules/filters/variety/comment/pages/dynamic.ts index 8c884c7d..92744438 100644 --- a/src/modules/filters/variety/comment/pages/dynamic.ts +++ b/src/modules/filters/variety/comment/pages/dynamic.ts @@ -458,7 +458,6 @@ export const commentFilterDynamicGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.username.statusKey, name: '启用 评论用户过滤 (右键单击用户名)', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.commentUsernameFilter.enable() @@ -492,7 +491,6 @@ export const commentFilterDynamicGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.content.statusKey, name: '启用 评论关键词过滤', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.commentContentFilter.enable() @@ -527,7 +525,6 @@ export const commentFilterDynamicGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.callBot.statusKey, name: '过滤 召唤AI的评论', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.commentCallBotFilter.enable() @@ -542,7 +539,6 @@ export const commentFilterDynamicGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.bot.statusKey, name: '过滤 AI发布的评论', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.commentBotFilter.enable() @@ -557,7 +553,6 @@ export const commentFilterDynamicGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.isAD.statusKey, name: '过滤 带货评论 (实验功能)', - defaultEnable: false, noStyle: true, enableFn: () => { fetchHook.addPostFn( @@ -599,7 +594,6 @@ export const commentFilterDynamicGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.callUserOnly.statusKey, name: '过滤 只含 @其他用户 的评论', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.commentCallUserOnlyFilter.enable() @@ -614,7 +608,6 @@ export const commentFilterDynamicGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.callUser.statusKey, name: '过滤 包含 @其他用户 的评论', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.commentCallUserFilter.enable() @@ -634,7 +627,6 @@ export const commentFilterDynamicGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.level.statusKey, name: '启用 用户等级过滤', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.commentLevelFilter.enable() @@ -668,7 +660,6 @@ export const commentFilterDynamicGroups: Group[] = [ type: 'switch', id: GM_KEYS.white.root.statusKey, name: '一级评论(主评论) 免过滤', - defaultEnable: false, noStyle: true, enableFn: () => { isRootWhite = true @@ -683,7 +674,6 @@ export const commentFilterDynamicGroups: Group[] = [ type: 'switch', id: GM_KEYS.white.sub.statusKey, name: '二级评论(回复) 免过滤', - defaultEnable: false, noStyle: true, enableFn: () => { isSubWhite = true @@ -698,7 +688,6 @@ export const commentFilterDynamicGroups: Group[] = [ type: 'switch', id: GM_KEYS.white.isUp.statusKey, name: 'UP主的评论 免过滤', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.commentIsUpFilter.enable() @@ -713,7 +702,6 @@ export const commentFilterDynamicGroups: Group[] = [ type: 'switch', id: GM_KEYS.white.isPin.statusKey, name: '置顶评论 免过滤', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.commentIsPinFilter.enable() @@ -728,7 +716,6 @@ export const commentFilterDynamicGroups: Group[] = [ type: 'switch', id: GM_KEYS.white.isNote.statusKey, name: '笔记/图片评论 免过滤', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.commentIsNoteFilter.enable() @@ -743,7 +730,6 @@ export const commentFilterDynamicGroups: Group[] = [ type: 'switch', id: GM_KEYS.white.isLink.statusKey, name: '含超链接的评论 免过滤', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.commentIsLinkFilter.enable() diff --git a/src/modules/filters/variety/comment/pages/space.ts b/src/modules/filters/variety/comment/pages/space.ts index 53d84720..1372c294 100644 --- a/src/modules/filters/variety/comment/pages/space.ts +++ b/src/modules/filters/variety/comment/pages/space.ts @@ -413,7 +413,6 @@ export const commentFilterSpaceGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.username.statusKey, name: '启用 评论用户过滤 (右键单击用户名)', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.commentUsernameFilter.enable() @@ -447,7 +446,6 @@ export const commentFilterSpaceGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.content.statusKey, name: '启用 评论关键词过滤', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.commentContentFilter.enable() @@ -482,7 +480,6 @@ export const commentFilterSpaceGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.callBot.statusKey, name: '过滤 召唤AI的评论', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.commentCallBotFilter.enable() @@ -497,7 +494,6 @@ export const commentFilterSpaceGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.bot.statusKey, name: '过滤 AI发布的评论', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.commentBotFilter.enable() @@ -512,7 +508,6 @@ export const commentFilterSpaceGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.isAD.statusKey, name: '过滤 带货评论 (实验功能)', - defaultEnable: false, noStyle: true, enableFn: () => { fetchHook.addPostFn( @@ -554,7 +549,6 @@ export const commentFilterSpaceGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.callUserOnly.statusKey, name: '过滤 只含 @其他用户 的评论', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.commentCallUserOnlyFilter.enable() @@ -569,7 +563,6 @@ export const commentFilterSpaceGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.callUser.statusKey, name: '过滤 包含 @其他用户 的评论', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.commentCallUserFilter.enable() @@ -589,7 +582,6 @@ export const commentFilterSpaceGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.level.statusKey, name: '启用 用户等级过滤', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.commentLevelFilter.enable() @@ -623,7 +615,6 @@ export const commentFilterSpaceGroups: Group[] = [ type: 'switch', id: GM_KEYS.white.root.statusKey, name: '一级评论(主评论) 免过滤', - defaultEnable: false, noStyle: true, enableFn: () => { isRootWhite = true @@ -638,7 +629,6 @@ export const commentFilterSpaceGroups: Group[] = [ type: 'switch', id: GM_KEYS.white.sub.statusKey, name: '二级评论(回复) 免过滤', - defaultEnable: false, noStyle: true, enableFn: () => { isSubWhite = true @@ -653,7 +643,6 @@ export const commentFilterSpaceGroups: Group[] = [ type: 'switch', id: GM_KEYS.white.isUp.statusKey, name: 'UP主的评论 免过滤', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.commentIsUpFilter.enable() @@ -668,7 +657,6 @@ export const commentFilterSpaceGroups: Group[] = [ type: 'switch', id: GM_KEYS.white.isPin.statusKey, name: '置顶评论 免过滤', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.commentIsPinFilter.enable() @@ -683,7 +671,6 @@ export const commentFilterSpaceGroups: Group[] = [ type: 'switch', id: GM_KEYS.white.isNote.statusKey, name: '笔记/图片评论 免过滤', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.commentIsNoteFilter.enable() @@ -698,7 +685,6 @@ export const commentFilterSpaceGroups: Group[] = [ type: 'switch', id: GM_KEYS.white.isLink.statusKey, name: '含超链接的评论 免过滤', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.commentIsLinkFilter.enable() diff --git a/src/modules/filters/variety/comment/pages/video.ts b/src/modules/filters/variety/comment/pages/video.ts index e7a4a898..cc45bacd 100644 --- a/src/modules/filters/variety/comment/pages/video.ts +++ b/src/modules/filters/variety/comment/pages/video.ts @@ -466,7 +466,6 @@ export const commentFilterVideoGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.username.statusKey, name: '启用 评论用户过滤 (右键单击用户名)', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.commentUsernameFilter.enable() @@ -500,7 +499,6 @@ export const commentFilterVideoGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.content.statusKey, name: '启用 评论关键词过滤', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.commentContentFilter.enable() @@ -535,7 +533,6 @@ export const commentFilterVideoGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.callBot.statusKey, name: '过滤 召唤AI的评论', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.commentCallBotFilter.enable() @@ -550,7 +547,6 @@ export const commentFilterVideoGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.bot.statusKey, name: '过滤 AI发布的评论', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.commentBotFilter.enable() @@ -565,7 +561,6 @@ export const commentFilterVideoGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.isAD.statusKey, name: '过滤 带货评论 (实验功能)', - defaultEnable: false, noStyle: true, enableFn: () => { fetchHook.addPostFn( @@ -607,7 +602,6 @@ export const commentFilterVideoGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.callUserOnly.statusKey, name: '过滤 只含 @其他用户 的评论', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.commentCallUserOnlyFilter.enable() @@ -622,7 +616,6 @@ export const commentFilterVideoGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.callUser.statusKey, name: '过滤 包含 @其他用户 的评论', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.commentCallUserFilter.enable() @@ -642,7 +635,6 @@ export const commentFilterVideoGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.level.statusKey, name: '启用 用户等级过滤', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.commentLevelFilter.enable() @@ -676,7 +668,6 @@ export const commentFilterVideoGroups: Group[] = [ type: 'switch', id: GM_KEYS.white.root.statusKey, name: '一级评论(主评论) 免过滤', - defaultEnable: false, noStyle: true, enableFn: () => { isRootWhite = true @@ -691,7 +682,6 @@ export const commentFilterVideoGroups: Group[] = [ type: 'switch', id: GM_KEYS.white.sub.statusKey, name: '二级评论(回复) 免过滤', - defaultEnable: false, noStyle: true, enableFn: () => { isSubWhite = true @@ -706,7 +696,6 @@ export const commentFilterVideoGroups: Group[] = [ type: 'switch', id: GM_KEYS.white.isUp.statusKey, name: 'UP主的评论 免过滤', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.commentIsUpFilter.enable() @@ -721,7 +710,6 @@ export const commentFilterVideoGroups: Group[] = [ type: 'switch', id: GM_KEYS.white.isPin.statusKey, name: '置顶评论 免过滤', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.commentIsPinFilter.enable() @@ -736,7 +724,6 @@ export const commentFilterVideoGroups: Group[] = [ type: 'switch', id: GM_KEYS.white.isNote.statusKey, name: '笔记/图片评论 免过滤', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.commentIsNoteFilter.enable() @@ -751,7 +738,6 @@ export const commentFilterVideoGroups: Group[] = [ type: 'switch', id: GM_KEYS.white.isLink.statusKey, name: '含超链接的评论 免过滤', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.commentIsLinkFilter.enable() diff --git a/src/modules/filters/variety/dynamic/pages/dynamic.ts b/src/modules/filters/variety/dynamic/pages/dynamic.ts index a53cd07d..78f99255 100644 --- a/src/modules/filters/variety/dynamic/pages/dynamic.ts +++ b/src/modules/filters/variety/dynamic/pages/dynamic.ts @@ -195,7 +195,6 @@ export const dynamicFilterDynamicGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.uploader.statusKey, name: '启用 动态发布人过滤 (右键单击用户名)', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.dynUploaderFilter.enable() @@ -227,7 +226,6 @@ export const dynamicFilterDynamicGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.duration.statusKey, name: '启用 时长过滤', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.dynDurationFilter.enable() @@ -262,7 +260,6 @@ export const dynamicFilterDynamicGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.title.statusKey, name: '启用 标题关键词过滤', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.dynVideoTitleFilter.enable() @@ -298,7 +295,6 @@ export const dynamicFilterDynamicGroups: Group[] = [ id: GM_KEYS.black.content.statusKey, name: '启用 动态内容关键词过滤', description: ['包含被转发动态内容', '不含动态内视频信息'], - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.dynContentFilter.enable() diff --git a/src/modules/filters/variety/video/pages/channel.ts b/src/modules/filters/variety/video/pages/channel.ts index 350e8560..6dfd5ee3 100644 --- a/src/modules/filters/variety/video/pages/channel.ts +++ b/src/modules/filters/variety/video/pages/channel.ts @@ -240,7 +240,6 @@ export const videoFilterChannelGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.duration.statusKey, name: '启用 时长过滤', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.videoDurationFilter.enable() @@ -303,7 +302,6 @@ export const videoFilterChannelGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.uploaderKeyword.statusKey, name: '启用 UP主昵称关键词过滤', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.videoUploaderKeywordFilter.enable() @@ -340,7 +338,6 @@ export const videoFilterChannelGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.title.statusKey, name: '启用 标题关键词过滤', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.videoTitleFilter.enable() @@ -375,7 +372,6 @@ export const videoFilterChannelGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.bvid.statusKey, name: '启用 BV号过滤 (右键单击标题)', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.videoBvidFilter.enable() @@ -407,7 +403,6 @@ export const videoFilterChannelGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.pubdate.statusKey, name: '启用 发布日期过滤', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.videoPubdateFilter.enable() @@ -471,7 +466,6 @@ export const videoFilterChannelGroups: Group[] = [ type: 'switch', id: GM_KEYS.white.title.statusKey, name: '启用 标题关键词白名单', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.videoTitleWhiteFilter.enable() diff --git a/src/modules/filters/variety/video/pages/homepage.ts b/src/modules/filters/variety/video/pages/homepage.ts index 0696d1ff..67ba187b 100644 --- a/src/modules/filters/variety/video/pages/homepage.ts +++ b/src/modules/filters/variety/video/pages/homepage.ts @@ -26,6 +26,7 @@ import { VideoTitleFilter, VideoUploaderFilter, VideoUploaderKeywordFilter, + VideoViewsFilter, } from '../subFilters/black' import { VideoIsFollowWhiteFilter, VideoTitleWhiteFilter, VideoUploaderWhiteFilter } from '../subFilters/white' @@ -35,6 +36,10 @@ const GM_KEYS = { statusKey: 'homepage-duration-filter-status', valueKey: 'global-duration-filter-value', }, + views: { + statusKey: 'homepage-views-filter-status', + valueKey: 'global-views-filter-value', + }, uploader: { statusKey: 'homepage-uploader-filter-status', valueKey: 'global-uploader-filter-value', @@ -77,6 +82,18 @@ const selectorFns = { const duration = video.querySelector('.bili-video-card__stats__duration')?.textContent?.trim() return duration && convertTimeToSec(duration) }, + views: (video: HTMLElement): SelectorResult => { + const text = video.querySelector('.bili-video-card__stats--text')?.textContent?.trim() + if (text) { + if (/\d+(?:\.\d+)?万/.test(text)) { + return parseFloat(text.replace('万', '')) * 10000 + } + if (/^\d+$/.test(text)) { + return parseFloat(text) + } + } + return undefined + }, title: (video: HTMLElement): SelectorResult => { return video.querySelector('.bili-video-card__info--tit a')?.textContent?.trim() }, @@ -104,6 +121,7 @@ class VideoFilterHomepage implements IMainFilter { // 黑名单 videoBvidFilter = new VideoBvidFilter() videoDurationFilter = new VideoDurationFilter() + videoViewsFilter = new VideoViewsFilter() videoTitleFilter = new VideoTitleFilter() videoPubdateFilter = new VideoPubdateFilter() videoUploaderFilter = new VideoUploaderFilter() @@ -118,6 +136,7 @@ class VideoFilterHomepage implements IMainFilter { // 黑名单 this.videoBvidFilter.setParam(BiliCleanerStorage.get(GM_KEYS.black.bvid.valueKey, [])) this.videoDurationFilter.setParam(BiliCleanerStorage.get(GM_KEYS.black.duration.valueKey, 0)) + this.videoViewsFilter.setParam(BiliCleanerStorage.get(GM_KEYS.black.views.valueKey, 0)) this.videoTitleFilter.setParam(BiliCleanerStorage.get(GM_KEYS.black.title.valueKey, [])) this.videoPubdateFilter.setParam(BiliCleanerStorage.get(GM_KEYS.black.pubdate.valueKey, 0)) this.videoUploaderFilter.setParam(BiliCleanerStorage.get(GM_KEYS.black.uploader.valueKey, [])) @@ -136,6 +155,7 @@ class VideoFilterHomepage implements IMainFilter { !( this.videoBvidFilter.isEnable || this.videoDurationFilter.isEnable || + this.videoViewsFilter.isEnable || this.videoTitleFilter.isEnable || this.videoUploaderFilter.isEnable || this.videoUploaderKeywordFilter.isEnable || @@ -167,6 +187,7 @@ class VideoFilterHomepage implements IMainFilter { `VideoFilterHomepage`, `bvid: ${selectorFns.bvid(v)}`, `duration: ${selectorFns.duration(v)}`, + `views: ${selectorFns.views(v)}`, `title: ${selectorFns.title(v)}`, `uploader: ${selectorFns.uploader(v)}`, `pubdate: ${selectorFns.pubdate(v)}`, @@ -180,6 +201,7 @@ class VideoFilterHomepage implements IMainFilter { const blackPairs: SubFilterPair[] = [] this.videoBvidFilter.isEnable && blackPairs.push([this.videoBvidFilter, selectorFns.bvid]) this.videoDurationFilter.isEnable && blackPairs.push([this.videoDurationFilter, selectorFns.duration]) + this.videoViewsFilter.isEnable && blackPairs.push([this.videoViewsFilter, selectorFns.views]) this.videoTitleFilter.isEnable && blackPairs.push([this.videoTitleFilter, selectorFns.title]) this.videoPubdateFilter.isEnable && blackPairs.push([this.videoPubdateFilter, selectorFns.pubdate]) this.videoUploaderFilter.isEnable && blackPairs.push([this.videoUploaderFilter, selectorFns.uploader]) @@ -249,7 +271,6 @@ export const videoFilterHomepageGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.duration.statusKey, name: '启用 时长过滤', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.videoDurationFilter.enable() @@ -312,7 +333,6 @@ export const videoFilterHomepageGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.uploaderKeyword.statusKey, name: '启用 UP主昵称关键词过滤', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.videoUploaderKeywordFilter.enable() @@ -349,7 +369,6 @@ export const videoFilterHomepageGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.title.statusKey, name: '启用 标题关键词过滤', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.videoTitleFilter.enable() @@ -384,7 +403,6 @@ export const videoFilterHomepageGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.bvid.statusKey, name: '启用 BV号过滤 (右键单击标题)', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.videoBvidFilter.enable() @@ -416,7 +434,6 @@ export const videoFilterHomepageGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.pubdate.statusKey, name: '启用 发布日期过滤', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.videoPubdateFilter.enable() @@ -445,6 +462,43 @@ export const videoFilterHomepageGroups: Group[] = [ }, ], }, + { + name: '播放量过滤', + fold: true, + items: [ + { + type: 'switch', + id: GM_KEYS.black.views.statusKey, + name: '启用 播放量过滤', + description: ['不推荐启用', '会导致刚发布的优质视频被过滤'], + noStyle: true, + enableFn: () => { + mainFilter.videoViewsFilter.enable() + mainFilter.checkFull() + }, + disableFn: () => { + mainFilter.videoViewsFilter.disable() + mainFilter.checkFull() + }, + }, + { + type: 'number', + id: GM_KEYS.black.views.valueKey, + name: '设定最低播放量(0~10万)', + noStyle: true, + minValue: 0, + maxValue: 100000, + step: 1, + defaultValue: 0, + disableValue: 0, + addonText: '次', + fn: (value: number) => { + mainFilter.videoViewsFilter.setParam(value) + mainFilter.checkFull() + }, + }, + ], + }, { name: '白名单 免过滤', items: [ @@ -495,7 +549,6 @@ export const videoFilterHomepageGroups: Group[] = [ type: 'switch', id: GM_KEYS.white.title.statusKey, name: '启用 标题关键词白名单', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.videoTitleWhiteFilter.enable() diff --git a/src/modules/filters/variety/video/pages/popular.ts b/src/modules/filters/variety/video/pages/popular.ts index 57db39cd..aae2cd52 100644 --- a/src/modules/filters/variety/video/pages/popular.ts +++ b/src/modules/filters/variety/video/pages/popular.ts @@ -258,7 +258,6 @@ export const videoFilterPopularGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.duration.statusKey, name: '启用 时长过滤', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.videoDurationFilter.enable() @@ -321,7 +320,6 @@ export const videoFilterPopularGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.uploaderKeyword.statusKey, name: '启用 UP主昵称关键词过滤', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.videoUploaderKeywordFilter.enable() @@ -373,7 +371,6 @@ export const videoFilterPopularGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.quality.statusKey, name: '启用 劣质视频过滤', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.videoQualityFilter.enable() @@ -409,7 +406,6 @@ export const videoFilterPopularGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.title.statusKey, name: '启用 标题关键词过滤', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.videoTitleFilter.enable() @@ -444,7 +440,6 @@ export const videoFilterPopularGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.bvid.statusKey, name: '启用 BV号过滤 (右键单击标题)', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.videoBvidFilter.enable() @@ -504,7 +499,6 @@ export const videoFilterPopularGroups: Group[] = [ type: 'switch', id: GM_KEYS.white.title.statusKey, name: '启用 标题关键词白名单', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.videoTitleWhiteFilter.enable() diff --git a/src/modules/filters/variety/video/pages/search.ts b/src/modules/filters/variety/video/pages/search.ts index 0dbd04ea..5279123d 100644 --- a/src/modules/filters/variety/video/pages/search.ts +++ b/src/modules/filters/variety/video/pages/search.ts @@ -217,7 +217,6 @@ export const videoFilterSearchGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.duration.statusKey, name: '启用 时长过滤', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.videoDurationFilter.enable() @@ -280,7 +279,6 @@ export const videoFilterSearchGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.uploaderKeyword.statusKey, name: '启用 UP主昵称关键词过滤', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.videoUploaderKeywordFilter.enable() @@ -317,7 +315,6 @@ export const videoFilterSearchGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.title.statusKey, name: '启用 标题关键词过滤', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.videoTitleFilter.enable() @@ -352,7 +349,6 @@ export const videoFilterSearchGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.bvid.statusKey, name: '启用 BV号过滤 (右键单击标题)', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.videoBvidFilter.enable() @@ -412,7 +408,6 @@ export const videoFilterSearchGroups: Group[] = [ type: 'switch', id: GM_KEYS.white.title.statusKey, name: '启用 标题关键词白名单', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.videoTitleWhiteFilter.enable() diff --git a/src/modules/filters/variety/video/pages/space.ts b/src/modules/filters/variety/video/pages/space.ts index 498eca1d..74cc7fc6 100644 --- a/src/modules/filters/variety/video/pages/space.ts +++ b/src/modules/filters/variety/video/pages/space.ts @@ -182,7 +182,6 @@ export const videoFilterSpaceGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.duration.statusKey, name: '启用 时长过滤', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.videoDurationFilter.enable() @@ -218,7 +217,6 @@ export const videoFilterSpaceGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.title.statusKey, name: '启用 标题关键词过滤', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.videoTitleFilter.enable() @@ -253,7 +251,6 @@ export const videoFilterSpaceGroups: Group[] = [ // type: 'switch', // id: GM_KEYS.black.bvid.statusKey, // name: '启用 BV号过滤 (右键单击标题)', - // defaultEnable: false, // noStyle: true, // enableFn: () => { // mainFilter.videoBvidFilter.enable() @@ -285,7 +282,6 @@ export const videoFilterSpaceGroups: Group[] = [ type: 'switch', id: GM_KEYS.white.title.statusKey, name: '启用 标题关键词白名单', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.videoTitleWhiteFilter.enable() diff --git a/src/modules/filters/variety/video/pages/video.ts b/src/modules/filters/variety/video/pages/video.ts index d0e4d2c3..9e402397 100644 --- a/src/modules/filters/variety/video/pages/video.ts +++ b/src/modules/filters/variety/video/pages/video.ts @@ -250,7 +250,6 @@ export const videoFilterVideoGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.duration.statusKey, name: '启用 时长过滤', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.videoDurationFilter.enable() @@ -313,7 +312,6 @@ export const videoFilterVideoGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.uploaderKeyword.statusKey, name: '启用 UP主昵称关键词过滤', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.videoUploaderKeywordFilter.enable() @@ -350,7 +348,6 @@ export const videoFilterVideoGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.title.statusKey, name: '启用 标题关键词过滤', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.videoTitleFilter.enable() @@ -385,7 +382,6 @@ export const videoFilterVideoGroups: Group[] = [ type: 'switch', id: GM_KEYS.black.bvid.statusKey, name: '启用 BV号过滤 (右键单击标题)', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.videoBvidFilter.enable() @@ -422,7 +418,6 @@ export const videoFilterVideoGroups: Group[] = [ '自动替换接下来播放、播放结束相关视频', '启用后,变动其他过滤功能需刷新页面', ], - defaultEnable: false, noStyle: true, enableFn: () => { enableRelatedCheck = true @@ -470,7 +465,6 @@ export const videoFilterVideoGroups: Group[] = [ type: 'switch', id: GM_KEYS.white.title.statusKey, name: '启用 标题关键词白名单', - defaultEnable: false, noStyle: true, enableFn: () => { mainFilter.videoTitleWhiteFilter.enable() diff --git a/src/modules/filters/variety/video/subFilters/black.ts b/src/modules/filters/variety/video/subFilters/black.ts index d630929e..de3e4d23 100644 --- a/src/modules/filters/variety/video/subFilters/black.ts +++ b/src/modules/filters/variety/video/subFilters/black.ts @@ -19,3 +19,5 @@ export class VideoPubdateFilter extends NumberMaxFilter {} export class VideoUploaderFilter extends StringFilter {} export class VideoUploaderKeywordFilter extends KeywordFilter {} + +export class VideoViewsFilter extends NumberMinFilter {} diff --git a/vite.config.ts b/vite.config.ts index 59078eae..4f8638cd 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -19,7 +19,7 @@ export default defineConfig({ userscript: { name: 'bilibili 页面净化大师', namespace: 'http://tampermonkey.net/', - version: '4.0.6', + version: '4.0.7', description: '净化 B站/哔哩哔哩 页面,支持「精简功能、播放器净化、过滤视频、过滤评论、全站黑白名单」,提供 300+ 功能,定制自己的 B 站', author: 'festoney8', From a5992aee68a2cc96fe9befb5f8aec36320f5339e Mon Sep 17 00:00:00 2001 From: festoney8 Date: Mon, 4 Nov 2024 02:16:59 +0800 Subject: [PATCH 2/3] fix: bangumi page scrollable bug (#169) --- CHANGELOG.md | 1 + .../rules/bangumi/groups/playerLayout.scss | 66 +++++++++---------- 2 files changed, 32 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9a456bd..fbd46726 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 4.0.7 - 新增:首页 按播放量过滤 +- 修复:番剧页 全屏滚动视频位置问题 ## 4.0.6 diff --git a/src/modules/rules/bangumi/groups/playerLayout.scss b/src/modules/rules/bangumi/groups/playerLayout.scss index df17fbe9..62d0587d 100644 --- a/src/modules/rules/bangumi/groups/playerLayout.scss +++ b/src/modules/rules/bangumi/groups/playerLayout.scss @@ -3,22 +3,20 @@ html[webscreen-scrollable] { body:has(#bilibili-player-wrap[class*='video_playerFullScreen']) { overflow: auto !important; position: relative !important; - } - body:has(#bilibili-player-wrap[class*='video_playerFullScreen']) #bilibili-player-wrap { - position: absolute !important; - width: 100vw !important; - height: 100vh !important; - } - body:has(#bilibili-player-wrap[class*='video_playerFullScreen']) .main-container { - position: static !important; - margin: 0 auto !important; - padding-top: calc(100vh + 15px) !important; - } - body:has(#bilibili-player-wrap[class*='video_playerFullScreen']) .bpx-player-video-area { - flex: unset !important; - } - body:has(#bilibili-player-wrap[class*='video_playerFullScreen'])::-webkit-scrollbar { - display: none !important; + + #bilibili-player-wrap { + position: absolute !important; + width: 100vw !important; + height: 100vh !important; + } + .main-container { + position: static !important; + margin: 0 auto !important; + padding-top: calc(100vh + 15px) !important; + } + &::-webkit-scrollbar { + display: none !important; + } } } @@ -39,25 +37,23 @@ html[fullscreen-scrollable] { body:has(#bilibili-player-wrap[class*='video_playerFullScreen']) { overflow: auto !important; position: relative !important; - } - body:has(#bilibili-player-wrap[class*='video_playerFullScreen']) .home-container { - background-color: white; - } - body:has(#bilibili-player-wrap[class*='video_playerFullScreen']) #bilibili-player-wrap { - position: absolute !important; - width: 100vw !important; - height: 100vh !important; - } - body:has(#bilibili-player-wrap[class*='video_playerFullScreen']) .main-container { - position: static !important; - margin: 0 auto !important; - padding-top: calc(100vh + 15px) !important; - } - body:has(#bilibili-player-wrap[class*='video_playerFullScreen']) .bpx-player-video-area { - flex: unset !important; - } - body:has(#bilibili-player-wrap[class*='video_playerFullScreen'])::-webkit-scrollbar { - display: none !important; + + .home-container { + background-color: white; + } + #bilibili-player-wrap { + position: absolute !important; + width: 100vw !important; + height: 100vh !important; + } + .main-container { + position: static !important; + margin: 0 auto !important; + padding-top: calc(100vh + 15px) !important; + } + &::-webkit-scrollbar { + display: none !important; + } } } From 8543c423d833b1b9623ef8596a8d2f34e1c8f7bb Mon Sep 17 00:00:00 2001 From: festoney8 Date: Mon, 4 Nov 2024 02:18:49 +0800 Subject: [PATCH 3/3] chore: update issue template --- .github/ISSUE_TEMPLATE/bug.yaml | 4 ++-- src/modules/filters/variety/video/pages/channel.ts | 1 + src/modules/filters/variety/video/pages/homepage.ts | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug.yaml b/.github/ISSUE_TEMPLATE/bug.yaml index f8eb5375..ac6d9efd 100644 --- a/.github/ISSUE_TEMPLATE/bug.yaml +++ b/.github/ISSUE_TEMPLATE/bug.yaml @@ -48,7 +48,7 @@ body: id: env_os attributes: label: 操作系统 - placeholder: 如 Win10 / Win11 / MacOS + placeholder: 如 Windows 10 / Windows 11 / MacOS validations: required: true @@ -108,7 +108,7 @@ body: - type: dropdown id: check_plugin_conflict attributes: - label: 禁用掉对 B 站生效的浏览器插件后,仍出现问题 + label: 禁用掉对 B 站生效的其他浏览器插件(不含暴力猴/篡改猴),仍出现问题 options: - 是 - 否 diff --git a/src/modules/filters/variety/video/pages/channel.ts b/src/modules/filters/variety/video/pages/channel.ts index 6dfd5ee3..5b37aafd 100644 --- a/src/modules/filters/variety/video/pages/channel.ts +++ b/src/modules/filters/variety/video/pages/channel.ts @@ -398,6 +398,7 @@ export const videoFilterChannelGroups: Group[] = [ }, { name: '发布日期过滤', + fold: true, items: [ { type: 'switch', diff --git a/src/modules/filters/variety/video/pages/homepage.ts b/src/modules/filters/variety/video/pages/homepage.ts index 67ba187b..bc31566b 100644 --- a/src/modules/filters/variety/video/pages/homepage.ts +++ b/src/modules/filters/variety/video/pages/homepage.ts @@ -429,6 +429,7 @@ export const videoFilterHomepageGroups: Group[] = [ }, { name: '发布日期过滤', + fold: true, items: [ { type: 'switch',