Skip to content

Commit

Permalink
chore: update item name, update logger
Browse files Browse the repository at this point in the history
  • Loading branch information
festoney8 committed Jan 14, 2024
1 parent 86791ef commit 8b280ee
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 26 deletions.
8 changes: 4 additions & 4 deletions src/pages/bangumi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -862,11 +862,11 @@ if (location.href.startsWith('https://www.bilibili.com/bangumi/play/')) {
`#comment-module .reply-item:has(.st1.lv3):not(:has(.sub-up-icon, .reply-info .reply-like span)) {display: none !important;}`,
),
)
// 隐藏 一级评论 踩/回复/举报 hover时显示, 默认开启
// 一级评论 踩/回复 只在hover时显示, 默认开启
commentItems.push(
new CheckboxItem(
'video-page-hide-root-reply-dislike-reply-btn',
'隐藏 一级评论 踩/回复/举报 hover时显示',
'一级评论 踩/回复 只在hover时显示',
true,
undefined,
false,
Expand All @@ -880,11 +880,11 @@ if (location.href.startsWith('https://www.bilibili.com/bangumi/play/')) {
}`,
),
)
// 隐藏 二级评论 踩/回复/举报 hover时显示, 默认开启
// 二级评论 踩/回复 只在hover时显示, 默认开启
commentItems.push(
new CheckboxItem(
'video-page-hide-sub-reply-dislike-reply-btn',
'隐藏 二级评论 踩/回复/举报 hover时显示',
'二级评论 踩/回复 只在hover时显示',
true,
undefined,
false,
Expand Down
15 changes: 8 additions & 7 deletions src/pages/dynamic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { Group } from '../core/group'
import { CheckboxItem } from '../core/item'
import { debug } from '../utils/logger'

// 折叠动态,自动展开
// 自动展开 相同UP主被折叠的动态
const dynamicUnfold = () => {
// 大量动态下,单次耗时10ms内
const unfold = () => {
const dynFoldNodes = document.querySelectorAll('main .bili-dyn-list__item .bili-dyn-item-fold')
if (dynFoldNodes.length) {
Expand Down Expand Up @@ -202,11 +203,11 @@ if (location.host === 't.bilibili.com' || location.href.includes('bilibili.com/o
`.bili-rich-text-topic, .bili-dyn-content__orig__topic {display: none !important;}`,
),
)
// 隐藏 视频预约动态
// 隐藏 视频预约/直播预约动态
centerItems.push(
new CheckboxItem(
'hide-dynamic-page-bili-dyn-card-reserve',
'隐藏 视频预约动态',
'隐藏 视频预约/直播预约动态',
false,
undefined,
false,
Expand Down Expand Up @@ -509,11 +510,11 @@ if (location.host === 't.bilibili.com' || location.href.includes('bilibili.com/o
`.comment-container .reply-item:has(.st1.lv3):not(:has(.sub-up-icon, .reply-info .reply-like span)) {display: none !important;}`,
),
)
// 隐藏 一级评论 踩/回复/举报 hover时显示, 默认开启
// 一级评论 踩/回复 只在hover时显示, 默认开启
commentItems.push(
new CheckboxItem(
'video-page-hide-root-reply-dislike-reply-btn',
'隐藏 一级评论 踩/回复/举报 hover时显示',
'一级评论 踩/回复 只在hover时显示',
true,
undefined,
false,
Expand All @@ -527,11 +528,11 @@ if (location.host === 't.bilibili.com' || location.href.includes('bilibili.com/o
}`,
),
)
// 隐藏 二级评论 踩/回复/举报 hover时显示, 默认开启
// 二级评论 踩/回复 只在hover时显示, 默认开启
commentItems.push(
new CheckboxItem(
'video-page-hide-sub-reply-dislike-reply-btn',
'隐藏 二级评论 踩/回复/举报 hover时显示',
'二级评论 踩/回复 只在hover时显示',
true,
undefined,
false,
Expand Down
8 changes: 4 additions & 4 deletions src/pages/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1468,11 +1468,11 @@ if (
`.comment-container .reply-item:has(.st1.lv3):not(:has(.sub-up-icon, .reply-info .reply-like span)) {display: none !important;}`,
),
)
// 隐藏 一级评论 踩/回复/举报 hover时显示, 默认开启
// 一级评论 踩/回复 只在hover时显示, 默认开启
commentItems.push(
new CheckboxItem(
'video-page-hide-root-reply-dislike-reply-btn',
'隐藏 一级评论 踩/回复/举报 hover时显示',
'一级评论 踩/回复 只在hover时显示',
true,
undefined,
false,
Expand All @@ -1486,11 +1486,11 @@ if (
}`,
),
)
// 隐藏 二级评论 踩/回复/举报 hover时显示, 默认开启
// 二级评论 踩/回复 只在hover时显示, 默认开启
commentItems.push(
new CheckboxItem(
'video-page-hide-sub-reply-dislike-reply-btn',
'隐藏 二级评论 踩/回复/举报 hover时显示',
'二级评论 踩/回复 只在hover时显示',
true,
undefined,
false,
Expand Down
19 changes: 8 additions & 11 deletions src/utils/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ let currTime: number = startTime
* 使用 performance.now() 做精确计时
*
* @param loggingFunc console.log等带级别打印日志的函数
* @param forceEnable 强制启用日志输出, 用于log级别
* @param isDebugMode 在debug模式启用日志输出, 用于debug和error
* @param isEnable 是否打印日志
* @returns 返回wrap后的日志函数
*/
const wrapper = (loggingFunc: (..._args: any[]) => void | undefined, forceEnable: boolean, isDebugMode: boolean) => {
if (forceEnable || isDebugMode) {
const wrapper = (loggingFunc: (..._args: any[]) => void | undefined, isEnable: boolean) => {
if (isEnable) {
return (...innerArgs: any[]) => {
currTime = performance.now()
const during: string = (currTime - lastTime).toFixed(1)
Expand All @@ -25,12 +24,10 @@ const wrapper = (loggingFunc: (..._args: any[]) => void | undefined, forceEnable
lastTime = currTime
}
}
return (..._args: any) => {
return undefined
}
return (..._args: any) => {}
}

export const log = wrapper(console.log, true, settings.debugMode)
// debugMode下, 仍使用log级别输出
export const debug = wrapper(console.log, false, settings.debugMode)
export const error = wrapper(console.error, false, settings.debugMode)
export const log = wrapper(console.log, true)
export const error = wrapper(console.error, true)
// debugMode下, 使用log级别输出
export const debug = wrapper(console.log, settings.debugMode)

0 comments on commit 8b280ee

Please sign in to comment.