Skip to content

Commit

Permalink
Merge pull request #129 from festoney8/dev
Browse files Browse the repository at this point in the history
merge dev to main, v3.11.1
  • Loading branch information
festoney8 authored Sep 6, 2024
2 parents 400f217 + ae2a5ea commit 85f0a5a
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 28 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.11.1

- 更新:播放页 评论区过滤适配页面变化
- 修复:搜索页 视频过滤偶尔不触发问题

## 3.11.0

- 移除:播放页 接下来播放免过滤、播放结束免过滤
Expand Down
2 changes: 2 additions & 0 deletions src/filters/comment/dyn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ if (isPageDynamic()) {
// 91394217 @AI全文总结
// 473018527 @AI视频总结
// 3546639035795567 @AI总结视频
// 605801219 @AI工具集
'机器工具人',
'有趣的程序员',
'AI视频小助理',
Expand All @@ -116,6 +117,7 @@ if (isPageDynamic()) {
'AI全文总结',
'AI视频总结',
'AI总结视频',
'AI工具集',
]
const commentUsernameFilter = new CommentUsernameFilter()
commentUsernameFilter.setParam(GM_getValue(`BILICLEANER_${GM_KEYS.black.username.valueKey}`, []))
Expand Down
2 changes: 2 additions & 0 deletions src/filters/comment/space.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ if (isPageSpace()) {
// 91394217 @AI全文总结
// 473018527 @AI视频总结
// 3546639035795567 @AI总结视频
// 605801219 @AI工具集
'机器工具人',
'有趣的程序员',
'AI视频小助理',
Expand All @@ -115,6 +116,7 @@ if (isPageSpace()) {
'AI全文总结',
'AI视频总结',
'AI总结视频',
'AI工具集',
]
const commentUsernameFilter = new CommentUsernameFilter()
commentUsernameFilter.setParam(GM_getValue(`BILICLEANER_${GM_KEYS.black.username.valueKey}`, []))
Expand Down
44 changes: 19 additions & 25 deletions src/filters/comment/video.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GM_getValue, GM_setValue, unsafeWindow } from '$'
import { GM_getValue, GM_setValue } from '$'
import { ContextMenu } from '../../components/contextmenu'
import { Group } from '../../components/group'
import { ButtonItem, CheckboxItem, NumberItem } from '../../components/item'
Expand Down Expand Up @@ -29,14 +29,6 @@ let isContextMenuUsernameEnable = false
let isRootWhite = false
let isSubWhite = false

let isV2 = false
const isCommentV2 = () => {
if (!isV2) {
isV2 = unsafeWindow.__INITIAL_STATE__?.abtest?.comment_next_version === 'ELEMENTS'
}
return isV2
}

const GM_KEYS = {
black: {
username: {
Expand Down Expand Up @@ -105,6 +97,7 @@ if (isPageVideo() || isPageBangumi() || isPagePlaylist()) {
// 91394217 @AI全文总结
// 473018527 @AI视频总结
// 3546639035795567 @AI总结视频
// 605801219 @AI工具集
'机器工具人',
'有趣的程序员',
'AI视频小助理',
Expand All @@ -124,6 +117,7 @@ if (isPageVideo() || isPageBangumi() || isPagePlaylist()) {
'AI全文总结',
'AI视频总结',
'AI总结视频',
'AI工具集',
]
const commentUsernameFilter = new CommentUsernameFilter()
commentUsernameFilter.setParam(GM_getValue(`BILICLEANER_${GM_KEYS.black.username.valueKey}`, []))
Expand Down Expand Up @@ -159,13 +153,13 @@ if (isPageVideo() || isPageBangumi() || isPagePlaylist()) {
// https://b23.tv/av1350214762
root: {
username: (comment: HTMLElement): SelectorResult => {
if (isCommentV2()) {
if (!isPageBangumi()) {
return (comment as any).__data?.member?.uname?.trim()
}
return comment.querySelector('.root-reply-container .user-name')?.textContent?.trim()
},
content: (comment: HTMLElement): SelectorResult => {
if (isCommentV2()) {
if (!isPageBangumi()) {
return (comment as any).__data?.content?.message?.replace(/@[^@ ]+?( |$)/g, '').trim()
}
return comment
Expand All @@ -175,7 +169,7 @@ if (isPageVideo() || isPageBangumi() || isPagePlaylist()) {
.trim()
},
callUser: (comment: HTMLElement): SelectorResult => {
if (isCommentV2()) {
if (!isPageBangumi()) {
return (comment as any).__data?.content?.members[0]?.uname
}
return comment
Expand All @@ -184,35 +178,35 @@ if (isPageVideo() || isPageBangumi() || isPagePlaylist()) {
.trim()
},
level: (comment: HTMLElement): SelectorResult => {
if (isCommentV2()) {
if (!isPageBangumi()) {
return (comment as any).__data?.member?.level_info?.current_level
}
const c = comment.querySelector('.root-reply-container .user-level')?.className
const lv = c?.match(/level-([1-6])/)?.[1] // 忽略level-hardcore
return lv ? parseInt(lv) : undefined
},
isUp: (comment: HTMLElement): SelectorResult => {
if (isCommentV2()) {
if (!isPageBangumi()) {
const mid = (comment as any).__data?.mid
const upMid = (comment as any).__upMid
return typeof mid === 'number' && mid === upMid
}
return !!comment.querySelector('.root-reply-container .up-icon')
},
isPin: (comment: HTMLElement): SelectorResult => {
if (isCommentV2()) {
if (!isPageBangumi()) {
return !!(comment as any).__data?.reply_control?.is_up_top
}
return !!comment.querySelector('.root-reply-container .top-icon')
},
isNote: (comment: HTMLElement): SelectorResult => {
if (isCommentV2()) {
if (!isPageBangumi()) {
return !!(comment as any).__data?.reply_control?.is_note_v2
}
return !!comment.querySelector('.root-reply-container .note-prefix')
},
isLink: (comment: HTMLElement): SelectorResult => {
if (isCommentV2()) {
if (!isPageBangumi()) {
const jump_url = (comment as any).__data?.content?.jump_url
if (jump_url) {
for (const k of Object.keys(jump_url)) {
Expand All @@ -228,13 +222,13 @@ if (isPageVideo() || isPageBangumi() || isPagePlaylist()) {
},
sub: {
username: (comment: HTMLElement): SelectorResult => {
if (isCommentV2()) {
if (!isPageBangumi()) {
return (comment as any).__data?.member?.uname?.trim()
}
return comment.querySelector('.sub-user-name')?.textContent?.trim()
},
content: (comment: HTMLElement): SelectorResult => {
if (isCommentV2()) {
if (!isPageBangumi()) {
return (comment as any).__data?.content?.message
?.trim()
?.replace(/@[^@ ]+?( |$)/g, '')
Expand All @@ -249,7 +243,7 @@ if (isPageVideo() || isPageBangumi() || isPagePlaylist()) {
.trim()
},
callUser: (comment: HTMLElement): SelectorResult => {
if (isCommentV2()) {
if (!isPageBangumi()) {
return (comment as any).__data?.content?.message
?.trim()
.replace(/^回复 ?@[^@ ]+? ?:/, '')
Expand All @@ -268,23 +262,23 @@ if (isPageVideo() || isPageBangumi() || isPagePlaylist()) {
.trim()
},
level: (comment: HTMLElement): SelectorResult => {
if (isCommentV2()) {
if (!isPageBangumi()) {
return (comment as any).__data?.member?.level_info?.current_level
}
const c = comment.querySelector('.sub-user-level')?.className
const lv = c?.match(/level-([1-6])/)?.[1] // 忽略level-hardcore
return lv ? parseInt(lv) : undefined
},
isUp: (comment: HTMLElement): SelectorResult => {
if (isCommentV2()) {
if (!isPageBangumi()) {
const mid = (comment as any).__data?.mid
const upMid = (comment as any).__upMid
return typeof mid === 'number' && mid === upMid
}
return !!comment.querySelector('.sub-up-icon')
},
isLink: (comment: HTMLElement): SelectorResult => {
if (isCommentV2()) {
if (!isPageBangumi()) {
const urls = (comment as any).__data?.content?.jump_url
return urls ? Object.keys(urls).length > 0 : undefined
}
Expand All @@ -299,7 +293,7 @@ if (isPageVideo() || isPageBangumi() || isPagePlaylist()) {
// 提取元素:一级评论、二级评论
let rootComments: HTMLElement[] = []
let subComments: HTMLElement[] = []
if (isCommentV2()) {
if (!isPageBangumi()) {
const shadowRoot = document.querySelector('bili-comments')?.shadowRoot
if (!shadowRoot) {
return
Expand Down Expand Up @@ -447,7 +441,7 @@ if (isPageVideo() || isPageBangumi() || isPagePlaylist()) {
}
// 二级评论翻页
if (input.includes('/v2/reply/reply')) {
if (isCommentV2()) {
if (!isPageBangumi()) {
let cnt = 0
const id = setInterval(() => {
check(true)
Expand Down
4 changes: 2 additions & 2 deletions src/filters/video/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ if (isPageSearch()) {
}

try {
waitForEle(document, '.search-content', (node: HTMLElement): boolean => {
return node.className.includes('search-content')
waitForEle(document, '.search-layout', (node: HTMLElement): boolean => {
return node.className.includes('search-layout')
}).then((ele) => {
if (ele) {
vlc = ele
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.11.0',
version: '3.11.1',
description:
'净化 B站/哔哩哔哩 页面,支持「精简功能、播放器净化、过滤视频、过滤评论、全站黑白名单」,提供 300+ 功能,定制自己的 B 站',
author: 'festoney8',
Expand Down

0 comments on commit 85f0a5a

Please sign in to comment.