Skip to content

Commit

Permalink
Merge pull request #106 from festoney8/dev
Browse files Browse the repository at this point in the history
merge dev to main, v3.9.0
  • Loading branch information
festoney8 authored Jul 14, 2024
2 parents f085a5b + b5278ff commit 1efabde
Show file tree
Hide file tree
Showing 17 changed files with 1,199 additions and 266 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# CHANGELOG

## 3.9.0

- 新增:播放页新版评论区 净化优化 适配测试
- 新增:播放页新版评论区 评论过滤 适配测试
- 更新:对播放页/首页/热门页/频道页默认开启UP主过滤

## 3.8.2

- 修复:直播页 弹幕列表高度bug
Expand Down
32 changes: 32 additions & 0 deletions src/components/contextmenu.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#bili-cleaner-context-menu-container {
position: fixed;
background: #fff;
border-radius: 5px;
box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
overflow: hidden;
z-index: 99999;
}
#bili-cleaner-context-menu-container ul {
-webkit-margin-before: 0;
margin-block-start: 0;
-webkit-margin-after: 0;
margin-block-end: 0;
-webkit-margin-start: 0px;
margin-inline-start: 0px;
-webkit-margin-end: 0px;
margin-inline-end: 0px;
-webkit-padding-start: 0;
padding-inline-start: 0;
}
#bili-cleaner-context-menu-container li {
padding: 5px 10px;
font-size: 1rem;
}
#bili-cleaner-context-menu-container li:hover {
background: #fb7299;
font-weight: 500;
color: #fff;
}
4 changes: 2 additions & 2 deletions src/components/contextmenu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
user-select: none;
overflow: hidden;
z-index: 99999;
& ul {
ul {
margin-block-start: 0;
margin-block-end: 0;
margin-inline-start: 0px;
margin-inline-end: 0px;
padding-inline-start: 0;
}
& li {
li {
padding: 5px 10px;
font-size: 1rem;
&:hover {
Expand Down
26 changes: 13 additions & 13 deletions src/components/item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ interface ICheckboxItemOption {
itemID: string
description: string
defaultStatus?: boolean
enableFunc?: () => Promise<void>
enableFunc?: () => Promise<void> | void
// 分别对应:立即执行,DOMContentLoaded, load
enableFuncRunAt?: 'document-start' | 'document-end' | 'document-idle'
disableFunc?: () => Promise<void>
disableFunc?: () => Promise<void> | void
itemCSS?: string
}

Expand Down Expand Up @@ -125,11 +125,11 @@ export class CheckboxItem implements IItem {
if ((<HTMLInputElement>event.target).checked) {
this.setStatus(true)
this.insertItemCSS()
this.option.enableFunc && this.option.enableFunc().then().catch()
this.option.enableFunc && this.option.enableFunc()?.then().catch()
} else {
this.setStatus(false)
this.removeItemCSS()
this.option.disableFunc && this.option.disableFunc().then().catch()
this.option.disableFunc && this.option.disableFunc()?.then().catch()
}
})
debug(`watchItem ${this.option.itemID} OK`)
Expand All @@ -150,24 +150,24 @@ export class CheckboxItem implements IItem {
if (enableFunc && this.option.enableFunc) {
switch (this.option.enableFuncRunAt) {
case 'document-start':
this.option.enableFunc().then().catch()
this.option.enableFunc()?.then().catch()
break
case 'document-end':
if (['complete', 'interactive'].includes(document.readyState)) {
this.option.enableFunc().then().catch()
this.option.enableFunc()?.then().catch()
} else {
document.addEventListener('DOMContentLoaded', this.option.enableFunc)
}
break
case 'document-idle':
if (document.readyState === 'complete') {
this.option.enableFunc().then().catch()
this.option.enableFunc()?.then().catch()
} else {
document.addEventListener('load', this.option.enableFunc)
}
break
default:
this.option.enableFunc().then().catch()
this.option.enableFunc()?.then().catch()
}
}
debug(`enableItem ${this.option.itemID} OK`)
Expand All @@ -194,7 +194,7 @@ interface IRadioItemOption {
radioName: string
radioItemIDList: string[]
defaultStatus?: boolean
itemFunc?: () => Promise<void>
itemFunc?: () => Promise<void> | void
itemCSS?: string
}

Expand Down Expand Up @@ -299,7 +299,7 @@ export class RadioItem implements IItem {
debug(`radioItem ${this.option.itemID} checked`)
this.setStatus(true)
this.insertItemCSS()
this.option.itemFunc && this.option.itemFunc().then().catch()
this.option.itemFunc && this.option.itemFunc()?.then().catch()
// 相同name的其他option自动置为uncheck, 但这一行为无法被监听, 需传入itemID逐一修改
this.option.radioItemIDList.forEach((targetID) => {
if (targetID !== this.option.itemID) {
Expand Down Expand Up @@ -333,7 +333,7 @@ export class RadioItem implements IItem {
try {
this.insertItemCSS()
if (enableFunc && this.option.itemFunc) {
this.option.itemFunc().then().catch()
this.option.itemFunc()?.then().catch()
}
debug(`enableItem ${this.option.itemID} OK`)
} catch (err) {
Expand Down Expand Up @@ -529,7 +529,7 @@ interface IButtonItemOption {
itemID: string
description: string
name: string
itemFunc: () => Promise<void>
itemFunc: () => Promise<void> | void
}

/** 普通按钮 */
Expand Down Expand Up @@ -564,7 +564,7 @@ export class ButtonItem implements IItem {
const itemEle = document.querySelector(`#${this.option.itemID} button`) as HTMLButtonElement
itemEle.addEventListener('click', () => {
debug(`button ${this.option.itemID} click`)
this.option.itemFunc().then().catch()
this.option.itemFunc()?.then().catch()
})
debug(`watchItem ${this.option.itemID} OK`)
} catch (err) {
Expand Down
Loading

0 comments on commit 1efabde

Please sign in to comment.