Skip to content

Commit

Permalink
merge dev to main, v4.0.5 (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
festoney8 authored Oct 31, 2024
2 parents 88bc97f + ee7ec3b commit a84ce9e
Show file tree
Hide file tree
Showing 15 changed files with 254 additions and 58 deletions.
34 changes: 0 additions & 34 deletions .github/ISSUE_TEMPLATE/bug-反馈.md

This file was deleted.

118 changes: 118 additions & 0 deletions .github/ISSUE_TEMPLATE/bug.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: Bug 反馈
description: 上报功能失效、功能异常等问题
title: "[BUG] "
labels: ["bug"]
body:
- type: markdown
attributes:
value: |
## 问题描述
- type: input
id: problem_page
attributes:
label: 出问题的页面
description: 如首页、播放页、动态页、搜索页、直播页等,特殊情况请给出网址
placeholder: 输入页面名或网址
validations:
required: true

- type: input
id: problem_name
attributes:
label: 问题功能名
placeholder: 输入出问题的功能名
validations:
required: true

- type: textarea
id: problem_description
attributes:
label: 问题描述
validations:
required: true

- type: textarea
id: problem_screenshot
attributes:
label: 上传截图(可选)
validations:
required: false

- type: markdown
attributes:
value: |
## 环境
- type: input
id: env_os
attributes:
label: 操作系统
placeholder: 如 Win10 / Win11 / MacOS
validations:
required: true

- type: input
id: env_browser
attributes:
label: 浏览器版本
placeholder: 如 Chrome 130 / Firefox 131
validations:
required: true

- type: input
id: env_monkey
attributes:
label: 脚本管理器版本
placeholder: 如 Tampermonkey 最新
validations:
required: false

- type: input
id: env_plugin
attributes:
label: 本插件版本
placeholder: 如 v4.0.5 / 最新
validations:
required: false

- type: markdown
attributes:
value: |
## 初步检查
- type: dropdown
id: check_reproduce
attributes:
label: 可稳定复现问题
options:
-
-
- 未知
default: 2
validations:
required: true

- type: dropdown
id: check_script_conflict
attributes:
label: 在暴力猴/篡改猴内,只启用本脚本时,仍出现问题
options:
-
-
- 未知
default: 2
validations:
required: true

- type: dropdown
id: check_plugin_conflict
attributes:
label: 禁用掉对 B 站生效的浏览器插件后,仍出现问题
options:
-
-
- 未知
default: 2
validations:
required: true
19 changes: 19 additions & 0 deletions .github/ISSUE_TEMPLATE/feature.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: 新功能
description: 提出新功能需求
title: "[FR] "
labels: ["enhancement"]
body:
- type: markdown
attributes:
value: |
### 本插件专注于页面净化和优化,新功能以让页面更精简、更好用为主
### 暂不考虑给 B 站扩展功能、增加页面组件等工具性需求
---
- type: textarea
id: feature_description
attributes:
label: 功能描述
description: 在此介绍需要的功能
validations:
required: true
10 changes: 10 additions & 0 deletions .github/ISSUE_TEMPLATE/other.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: 其他问题
description: 其他问题
title: "[Other] "
body:
- type: textarea
id: feature_description
attributes:
label: 文字说明
validations:
required: true
10 changes: 0 additions & 10 deletions .github/ISSUE_TEMPLATE/其他问题.md

This file was deleted.

10 changes: 0 additions & 10 deletions .github/ISSUE_TEMPLATE/新功能.md

This file was deleted.

6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# CHANGELOG

## 4.0.5

- 新增:动态内容关键词过滤
- 新增:播放页 自动展开视频简介
- 更新:首页 边栏按钮屏蔽

## 4.0.4

- 移除:稍后再看列表页 双列模式 适配页面变化
Expand Down
3 changes: 2 additions & 1 deletion src/components/items/EditorComp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ const saveSuccess = ref(false)
const editorData = ref('')

const updateData = () => {
editorData.value = BiliCleanerStorage.get<string[]>(item.id, []).join('\n') + '\n' // 末尾空行
const val = BiliCleanerStorage.get<string[]>(item.id, []).join('\n')
editorData.value = val ? val + '\n' : val // 末尾空行
}

const saveData = () => {
Expand Down
63 changes: 61 additions & 2 deletions src/modules/filters/variety/dynamic/pages/dynamic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { isPageDynamic } from '../../../../../utils/pageType'
import { BiliCleanerStorage } from '../../../../../utils/storage'
import { convertTimeToSec, orderedUniq, showEle, waitForEle } from '../../../../../utils/tool'
import { coreCheck } from '../../../core/core'
import { DynDurationFilter, DynUploaderFilter, DynVideoTitleFilter } from '../subFilters/black'
import { DynContentFilter, DynDurationFilter, DynUploaderFilter, DynVideoTitleFilter } from '../subFilters/black'

const GM_KEYS = {
black: {
Expand All @@ -28,6 +28,10 @@ const GM_KEYS = {
statusKey: 'dyn-title-keyword-filter-status',
valueKey: 'global-title-keyword-filter-value',
},
content: {
statusKey: 'dyn-content-keyword-filter-status',
valueKey: 'global-content-keyword-filter-value',
},
},
}

Expand All @@ -47,6 +51,16 @@ const selectorFns = {
title: (dyn: HTMLElement): SelectorResult => {
return dyn.querySelector('.bili-dyn-card-video__title')?.textContent?.trim()
},
content: (dyn: HTMLElement): SelectorResult => {
return Array.from(
dyn.querySelectorAll(
'.bili-dyn-content :is(.dyn-card-opus__title, .bili-rich-text__content > span:not(.bili-rich-text-module.at))',
),
)
.map((v) => v?.textContent?.trim())
.filter((v) => v?.trim())
.join(' ')
},
}

class DynamicFilterDynamic implements IMainFilter {
Expand All @@ -56,12 +70,14 @@ class DynamicFilterDynamic implements IMainFilter {
dynUploaderFilter = new DynUploaderFilter()
dynDurationFilter = new DynDurationFilter()
dynVideoTitleFilter = new DynVideoTitleFilter()
dynContentFilter = new DynContentFilter()

init() {
// 黑名单
this.dynUploaderFilter.setParam(BiliCleanerStorage.get(GM_KEYS.black.uploader.valueKey, []))
this.dynDurationFilter.setParam(BiliCleanerStorage.get(GM_KEYS.black.duration.valueKey, 0))
this.dynVideoTitleFilter.setParam(BiliCleanerStorage.get(GM_KEYS.black.title.valueKey, []))
this.dynContentFilter.setParam(BiliCleanerStorage.get(GM_KEYS.black.content.valueKey, []))
}

async check(mode?: 'full' | 'incr') {
Expand All @@ -70,7 +86,12 @@ class DynamicFilterDynamic implements IMainFilter {
}
let revertAll = false
if (
!(this.dynUploaderFilter.isEnable || this.dynDurationFilter.isEnable || this.dynVideoTitleFilter.isEnable)
!(
this.dynUploaderFilter.isEnable ||
this.dynDurationFilter.isEnable ||
this.dynVideoTitleFilter.isEnable ||
this.dynContentFilter.isEnable
)
) {
revertAll = true
}
Expand Down Expand Up @@ -101,6 +122,7 @@ class DynamicFilterDynamic implements IMainFilter {
`uploader: ${selectorFns.uploader(v)}`,
`title: ${selectorFns.title(v)}`,
`duration: ${selectorFns.duration(v)}`,
`content: ${selectorFns.content(v)}`,
].join('\n'),
)
})
Expand All @@ -111,6 +133,7 @@ class DynamicFilterDynamic implements IMainFilter {
this.dynUploaderFilter.isEnable && blackPairs.push([this.dynUploaderFilter, selectorFns.uploader])
this.dynDurationFilter.isEnable && blackPairs.push([this.dynDurationFilter, selectorFns.duration])
this.dynVideoTitleFilter.isEnable && blackPairs.push([this.dynVideoTitleFilter, selectorFns.title])
this.dynContentFilter.isEnable && blackPairs.push([this.dynContentFilter, selectorFns.content])

// 检测
const blackCnt = await coreCheck(dyns, true, blackPairs, [])
Expand Down Expand Up @@ -267,6 +290,42 @@ export const dynamicFilterDynamicGroups: Group[] = [
},
],
},
{
name: '动态内容过滤',
items: [
{
type: 'switch',
id: GM_KEYS.black.content.statusKey,
name: '启用 动态内容关键词过滤',
description: ['包含被转发动态内容', '不含动态内视频信息'],
defaultEnable: false,
noStyle: true,
enableFn: () => {
mainFilter.dynContentFilter.enable()
mainFilter.checkFull()
},
disableFn: () => {
mainFilter.dynContentFilter.disable()
mainFilter.checkFull()
},
},
{
type: 'editor',
id: GM_KEYS.black.content.valueKey,
name: '编辑 动态内容关键词黑名单',
editorTitle: '动态内容关键词 黑名单',
editorDescription: [
'每行一个关键词或正则,不区分大小写',
'请勿使用过于激进的关键词或正则',
'正则默认 iu 模式,无需 flag,语法:/abc|\\d+/',
],
saveFn: async () => {
mainFilter.dynContentFilter.setParam(BiliCleanerStorage.get(GM_KEYS.black.content.valueKey, []))
mainFilter.checkFull()
},
},
],
},
]

// 右键菜单handler
Expand Down
2 changes: 2 additions & 0 deletions src/modules/filters/variety/dynamic/subFilters/black.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ export class DynUploaderFilter extends StringFilter {}
export class DynDurationFilter extends NumberMinFilter {}

export class DynVideoTitleFilter extends KeywordFilter {}

export class DynContentFilter extends KeywordFilter {}
8 changes: 8 additions & 0 deletions src/modules/rules/homepage/groups/sidebar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ html[homepage-hide-watchlater-pip-button] {
}
}

// 隐藏 广告
html[homepage-hide-adcard-button] {
.adcard,
.palette-button-wrap .adcard-content {
display: none !important;
}
}

// 隐藏 刷新按钮文字提示
html[homepage-hide-flexible-roll-btn-text] {
.palette-button-wrap .flexible-roll-btn .btn-text {
Expand Down
6 changes: 6 additions & 0 deletions src/modules/rules/homepage/groups/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ export const homepageSidebarItems: Item[] = [
id: 'homepage-hide-watchlater-pip-button',
name: '隐藏 稍后再看',
},
{
type: 'switch',
id: 'homepage-hide-adcard-button',
defaultEnable: true,
name: '隐藏 广告',
},
{
type: 'switch',
id: 'homepage-hide-flexible-roll-btn-text',
Expand Down
Loading

0 comments on commit a84ce9e

Please sign in to comment.