Skip to content

Commit

Permalink
Merge pull request #40 from festoney8/dev
Browse files Browse the repository at this point in the history
merge dev to main, v3.1.6
  • Loading branch information
festoney8 authored Feb 21, 2024
2 parents c8e0e41 + 83fc584 commit c76690d
Show file tree
Hide file tree
Showing 12 changed files with 388 additions and 31 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.1.6

- 新增:页面净化支持频道页
- 新增:首页、频道页 调节页面两侧宽度

## 3.1.5

- 新增:直播页新增弹幕屏蔽项
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

> [!IMPORTANT]
>
> - **页面净化支持「首页、播放页、影视番剧播放页、直播间、搜索页、动态页、热门页」,每个页面都有独立菜单**
> - **页面净化支持「首页、播放页、影视番剧播放页、直播间、搜索页、动态页、热门页、频道页」,每个页面都有独立菜单**
> - **视频过滤支持「首页、播放页、搜索页、热门页」**
> - 「通用项」对全站生效
> - 按下图打开菜单,在每个页面进行自定义净化,支持实时预览
Expand All @@ -46,7 +46,7 @@
### 1. 页面净化

- 适用于 **净化新版 bilibili 网页**,不做老版本页面适配
- 目前支持「首页、播放页、影视番剧播放页、直播间、搜索页、动态页、热门视频/排行榜页」这 7 个页面,可在每个页面下开启插件菜单,查看功能列表
- 目前支持「首页、播放页、影视番剧播放页、直播间、搜索页、动态页、热门/排行榜页、频道页」这 8 个页面,可在每个页面下开启插件菜单,查看功能列表
- 默认用户已登录,大会员下(开发环境)体验最佳
- 默认开启少数基础功能,其余功能由用户自行设定
- 大多数功能实时生效。脚本在开启网页后立即注入,所有隐藏元素规则在开启页面后 1 秒内生效。其他需要等待元素出现的功能,如「净化分享」生效较慢
Expand Down
20 changes: 12 additions & 8 deletions src/components/item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,10 @@ export class RadioItem implements IItem {
/**
* itemID item的唯一ID, 用于在GM database中记录数值
* description 数值功能介绍
* defaultValue 默认值, 数值为-1表示默认关闭
* defaultValue 默认值
* minValue 最小值
* maxValue 最大值
* disableValue 禁用值
* unit 数值单位
* itemCSS 样式
* itemCSSPlaceholder 样式占位符,用于替换成当前数值
Expand All @@ -382,6 +383,7 @@ interface INumberItemOption {
defaultValue: number
minValue: number
maxValue: number
disableValue: number
unit: string
itemCSS?: myCSS
// CSS中待替换为数值的占位符
Expand All @@ -396,11 +398,11 @@ export class NumberItem implements IItem {

constructor(private option: INumberItemOption) {}

/** 获取数值, 初次安装使用默认值 */
/** 获取数值, 初次安装使用禁用值 */
getValue() {
this.itemValue = GM_getValue(`BILICLEANER_${this.option.itemID}`)
if (this.itemValue === undefined) {
this.itemValue = this.option.defaultValue
this.itemValue = this.option.disableValue
this.setValue(this.itemValue)
}
}
Expand Down Expand Up @@ -482,10 +484,12 @@ export class NumberItem implements IItem {
const itemEle = document.querySelector(`#${this.option.itemID} input`) as HTMLInputElement
let currValue
itemEle.addEventListener('input', () => {
if (!itemEle.value.trim().match(/^-?\d+$/)) {
return
}
currValue = parseInt(itemEle.value)
if (isNaN(currValue)) {
// itemEle.value = this.option.minValue.toString()
return
itemEle.value = this.option.disableValue.toString()
} else {
if (currValue > this.option.maxValue) {
itemEle.value = this.option.maxValue.toString()
Expand All @@ -510,10 +514,10 @@ export class NumberItem implements IItem {
}
}

/** 启用,设定带自定义数值的CSS, 数值为-1时禁用 */
/** 启用,设定带自定义数值的CSS, 数值为disableValue时禁用 */
enableItem(_enableFunc = false) {
this.getValue()
if (this.itemValue !== -1) {
if (this.itemValue !== this.option.disableValue) {
try {
this.insertItemCSS()
debug(`enableItem ${this.option.itemID} OK`)
Expand All @@ -530,7 +534,7 @@ export class NumberItem implements IItem {
if (!this.option.itemCSS) {
return
}
if (this.itemValue !== -1) {
if (this.itemValue !== this.option.disableValue) {
this.removeItemCSS()
this.insertItemCSS()
} else {
Expand Down
1 change: 1 addition & 0 deletions src/filters/pages/homepage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ if (isPageHomepage()) {
defaultValue: 60,
minValue: 0,
maxValue: 300,
disableValue: 0,
unit: '秒',
callback: (value: number) => {
homepageDurationAction.change(value)
Expand Down
1 change: 1 addition & 0 deletions src/filters/pages/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ if (isPageSearch()) {
defaultValue: 60,
minValue: 0,
maxValue: 300,
disableValue: 0,
unit: '秒',
callback: (value: number) => {
searchDurationAction.change(value)
Expand Down
1 change: 1 addition & 0 deletions src/filters/pages/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ if (isPageVideo()) {
defaultValue: 60,
minValue: 0,
maxValue: 300,
disableValue: 0,
unit: '秒',
callback: (value: number) => {
videoDurationAction.change(value)
Expand Down
2 changes: 2 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { videoFilterGroupList } from './filters/pages/video'
import { popularFilterGroupList } from './filters/pages/popular'
import { searchFilterGroupList } from './filters/pages/search'
import { SideBtn } from './components/sideBtn'
import { channelGroupList } from './rules/channel'

log('script start')

Expand All @@ -39,6 +40,7 @@ const main = async () => {
...searchGroupList,
...dynamicGroupList,
...liveGroupList,
...channelGroupList,
...commonGroupList,
]
RULE_GROUPS.forEach((e) => e.enableGroup())
Expand Down
Loading

0 comments on commit c76690d

Please sign in to comment.