Skip to content

Commit

Permalink
Merge pull request #69 from festoney8/dev
Browse files Browse the repository at this point in the history
merge dev to main, v3.5.1
  • Loading branch information
festoney8 authored Apr 30, 2024
2 parents 7886cdb + b02fbf4 commit 79cd725
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 97 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGELOG

## 3.5.1

- 优化:视频质量计算参数
- 修复:修复typo,优化代码

## 3.5.0

- 新增:热门/每周必看/排行榜页 时长过滤
Expand Down
18 changes: 13 additions & 5 deletions src/filters/videoFilter/filters/subfilters/quality.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,20 @@ class QualityFilter implements IVideoSubFilter {
this.threshold = threshold
}

// 根据coinLikeRatio计算视频质量, 参数源于爬虫数据拟合
/*
根据coinLikeRatio计算视频质量
对爬虫数据中投币点赞比在热门视频中所在排名进行拟合(百分制,4PL Formula)
保持Quality在5%~80%时的高拟合度
热门(质量要求适中):f(x) = (-9.881-168.6)/(1+(x/0.3829)^0.6463)+168.6
排行榜(较低):h(x) = (-14.82-115.9)/(1+(x/0.05327)^0.6639)+115.9
每周必看(严格):p(x) = (1.534-173.4)/(1+(x/0.7463)^1.401)+173.4
*/
calcQuality = (ratio: number): number => {
const A = -1.201e1
const B = 6.861e-1
const C = 7.369e-2
const D = 1.192e2
const A = -9.881
const B = 6.463e-1
const C = 3.829e-1
const D = 1.686e2
const ans = (A - D) / (1 + Math.pow(ratio / C, B)) + D
return ans > 0 ? ans : 0
}
Expand Down
22 changes: 8 additions & 14 deletions src/filters/videoFilter/pages/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,29 +119,23 @@ if (isPageChannel()) {

// 监听视频列表内部变化, 有变化时检测视频列表
const watchVideoListContainer = () => {
if (videoListContainer) {
debug('watchVideoListContainer start')
// 初次全站检测
const check = async (fillSite: boolean) => {
if (
channelDurationAction.status ||
channelUploaderAction.status ||
channelUploaderKeywordAction.status ||
channelBvidAction.status ||
channelTitleKeywordAction.status
) {
checkVideoList(true)
checkVideoList(fillSite)
}
}
if (videoListContainer) {
// 初次全站检测
check(true)
const videoObverser = new MutationObserver(() => {
if (
channelDurationAction.status ||
channelUploaderAction.status ||
channelUploaderKeywordAction.status ||
channelBvidAction.status ||
channelTitleKeywordAction.status
) {
// 增量检测
checkVideoList(false)
}
// 增量检测
check(false)
})
videoObverser.observe(videoListContainer, { childList: true, subtree: true })
debug('watchVideoListContainer OK')
Expand Down
22 changes: 8 additions & 14 deletions src/filters/videoFilter/pages/homepage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,29 +152,23 @@ if (isPageHomepage()) {

// 监听视频列表内部变化, 有变化时检测视频列表
const watchVideoListContainer = () => {
if (videoListContainer) {
debug('watchVideoListContainer start')
const check = async (fullSite: boolean) => {
if (
homepageDurationAction.status ||
homepageUploaderAction.status ||
homepageUploaderKeywordAction.status ||
homepageBvidAction.status ||
homepageTitleKeywordAction.status
) {
// 初次全站检测
checkVideoList(true)
checkVideoList(fullSite)
}
}
if (videoListContainer) {
// 初次全站检测
check(true)
const videoObverser = new MutationObserver(() => {
if (
homepageDurationAction.status ||
homepageUploaderAction.status ||
homepageUploaderKeywordAction.status ||
homepageBvidAction.status ||
homepageTitleKeywordAction.status
) {
// 增量检测
checkVideoList(false)
}
// 增量检测
check(false)
})
videoObverser.observe(videoListContainer, { childList: true })
debug('watchVideoListContainer OK')
Expand Down
42 changes: 12 additions & 30 deletions src/filters/videoFilter/pages/popular.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,7 @@ if (isPagePopular()) {

// 监听视频列表内部变化, 有变化时检测视频列表
const watchVideoListContainer = async () => {
if (videoListContainer) {
debug('watchVideoListContainer start')
const check = async (fullSite: boolean) => {
if (
popularDurationAction.status ||
popularUploaderAction.status ||
Expand All @@ -240,36 +239,19 @@ if (isPagePopular()) {
popularBvidAction.status ||
popularTitleKeywordAction.status
) {
// 初次全站检测
if (location.pathname.match(/\/v\/popular\/(?:all|rank|weekly)/)) {
if (popularDurationAction.status || popularQualityAction.status || popularDimensionAction) {
await parseResp()
} else {
parseResp()
}
popularDurationAction.status || popularQualityAction.status || popularDimensionAction.status
? await parseResp()
: parseResp()
}
checkVideoList(true)
checkVideoList(fullSite)
}
}

if (videoListContainer) {
check(true)
const videoObverser = new MutationObserver(async () => {
if (
popularDurationAction.status ||
popularUploaderAction.status ||
popularQualityAction.status ||
popularDimensionAction.status ||
popularUploaderKeywordAction.status ||
popularBvidAction.status ||
popularTitleKeywordAction.status
) {
// 全量检测
if (location.pathname.match(/\/v\/popular\/(?:all|rank|weekly)/)) {
if (popularDurationAction.status || popularQualityAction.status || popularDimensionAction) {
await parseResp()
} else {
parseResp()
}
}
checkVideoList(true)
}
check(true)
})
videoObverser.observe(videoListContainer, { childList: true, subtree: true })
debug('watchVideoListContainer OK')
Expand Down Expand Up @@ -410,8 +392,8 @@ if (isPagePopular()) {
}),
new NumberItem({
itemID: popularQualityAction.valueKey,
description: '设定 劣质视频过滤百分比',
defaultValue: 20,
description: '劣质视频过滤百分比 (0~80%)',
defaultValue: 25,
minValue: 0,
maxValue: 80,
disableValue: 0,
Expand Down
18 changes: 6 additions & 12 deletions src/filters/videoFilter/pages/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,27 +123,21 @@ if (isPageSearch()) {

// 监听视频列表内部变化, 有变化时检测视频列表
const watchVideoListContainer = () => {
if (videoListContainer) {
debug('watchVideoListContainer start')
const check = async (fullSite: boolean) => {
if (
searchDurationAction.status ||
searchUploaderAction.status ||
searchUploaderKeywordAction.status ||
searchBvidAction.status ||
searchTitleKeywordAction.status
) {
checkVideoList(true)
checkVideoList(fullSite)
}
}
if (videoListContainer) {
check(true)
const videoObverser = new MutationObserver(() => {
if (
searchDurationAction.status ||
searchUploaderAction.status ||
searchUploaderKeywordAction.status ||
searchBvidAction.status ||
searchTitleKeywordAction.status
) {
checkVideoList(true)
}
check(true)
})
videoObverser.observe(videoListContainer, { childList: true, subtree: true })
debug('watchVideoListContainer OK')
Expand Down
14 changes: 7 additions & 7 deletions src/filters/videoFilter/pages/space.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,16 @@ if (isPageSpace()) {

// 监听视频列表内部变化, 有变化时检测视频列表
const watchVideoListContainer = () => {
if (videoListContainer) {
debug('watchVideoListContainer start')
const check = async (fullSite: boolean) => {
if (spaceDurationAction.status || spaceBvidAction.status || spaceTitleKeywordAction.status) {
checkVideoList(true)
checkVideoList(fullSite)
}
}
if (videoListContainer) {
check(true)
const videoObverser = new MutationObserver(() => {
if (spaceDurationAction.status || spaceBvidAction.status || spaceTitleKeywordAction.status) {
// 全量检测
checkVideoList(true)
}
// 全量检测
check(true)
})
videoObverser.observe(videoListContainer, { childList: true, subtree: true })
debug('watchVideoListContainer OK')
Expand Down
21 changes: 7 additions & 14 deletions src/filters/videoFilter/pages/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,30 +121,23 @@ if (isPageVideo() || isPagePlaylist()) {

// 监听视频列表内部变化, 有变化时检测视频列表
const watchVideoListContainer = () => {
if (videoListContainer) {
debug('watchVideoListContainer start')
const check = async (fullSite: boolean) => {
if (
videoDurationAction.status ||
videoUploaderAction.status ||
videoUploaderKeywordAction.status ||
videoBvidAction.status ||
videoTitleKeywordAction.status
) {
// 播放页右栏载入慢, 始终做全站检测
checkVideoList(true)
checkVideoList(fullSite)
}
}
if (videoListContainer) {
check(true)
const videoObverser = new MutationObserver(() => {
if (
videoDurationAction.status ||
videoUploaderAction.status ||
videoUploaderKeywordAction.status ||
videoBvidAction.status ||
videoTitleKeywordAction.status
) {
checkVideoList(true)
}
// 播放页右栏载入慢, 始终做全站检测
check(true)
})
// 播放页需监听subtree
videoObverser.observe(videoListContainer, { childList: true, subtree: true })
debug('watchVideoListContainer OK')
}
Expand Down
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default defineConfig({
userscript: {
name: 'bilibili 页面净化大师',
namespace: 'http://tampermonkey.net/',
version: '3.5.0',
version: '3.5.1',
description:
'净化 B站/哔哩哔哩 页面,支持「精简功能、播放器净化、过滤视频、过滤评论、全站黑白名单」,提供 300+ 功能,定制自己的 B 站',
author: 'festoney8',
Expand Down

0 comments on commit 79cd725

Please sign in to comment.