Skip to content

Commit 2f03e4a

Browse files
committed
chore(bbu): hide log
1 parent 1a5a4f5 commit 2f03e4a

File tree

10 files changed

+25
-17
lines changed

10 files changed

+25
-17
lines changed

packages/bilibili-block-ugc/main.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import { RegExps, Windows, injectXhr, util_info as log } from "../unblock-area-limit/index";
1+
import { RegExps, Scripts, Windows, injectXhr, util_info, noop } from "../unblock-area-limit/index";
2+
3+
const log = Scripts.isDev ? util_info : noop
24

35
const LONG_VIDEO_DURATION = 10 * 60
46

packages/bilibili-block-ugc/rollup.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const userScriptMetaData = `
1111
// ==UserScript==
1212
// @name Bilibili UGC
1313
// @namespace https://github.com/ipcjs
14-
// @version 0.0.1
14+
// @version 0.0.2
1515
// @description Bilibili UGC
1616
// @author ipcjs
1717
// @match https://www.bilibili.com/*

packages/unblock-area-limit/index.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
export { log, util_info } from "./src/util/log";
2-
export { Windows } from "./src/util/windows";
31
export { injectXhr } from "./src/util/inject-xhr";
2+
export { log, util_info } from "./src/util/log";
43
export { RegExps } from "./src/util/regexps";
4+
export { Scripts } from "./src/util/scripts";
5+
export { noop } from "./src/util/utils";
6+
export { Windows } from "./src/util/windows";

packages/unblock-area-limit/src/feature/r.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Scripts } from "../util/scripts"
2+
13
const r_text = {
24
ok: { en: 'OK', zh_cn: '确定', },
35
close: { en: 'Close', zh_cn: '关闭' },
@@ -25,7 +27,7 @@ export const r = {
2527
readme: 'https://github.com/ipcjs/bilibili-helper/blob/user.js/packages/unblock-area-limit/README.md#%E8%A7%A3%E9%99%A4b%E7%AB%99%E5%8C%BA%E5%9F%9F%E9%99%90%E5%88%B6',
2628
},
2729
script: {
28-
is_dev: GM_info.script.name.includes('.dev'),
30+
is_dev: Scripts.isDev,
2931
},
3032
const: {
3133
mode: {

packages/unblock-area-limit/src/util/inject-xhr.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// @ts-nocheck
2-
import { r } from "../feature/r"
32
import { util_debug } from "./log"
3+
import { Scripts } from "./scripts"
44
let noReferrerHostArray: string[] = []
55
/// 注入Xhr
66
///
@@ -10,12 +10,12 @@ let noReferrerHostArray: string[] = []
1010
/// [transformResponse]:
1111
/// {@macro xhr_transform_response}
1212
export function injectXhr({ transformRequest, transformResponse }) {
13-
util_debug('XMLHttpRequest的描述符:', Object.getOwnPropertyDescriptor(window, 'XMLHttpRequest'))
13+
// util_debug('XMLHttpRequest的描述符:', Object.getOwnPropertyDescriptor(window, 'XMLHttpRequest'))
1414
let firstCreateXHR = true
1515
window.XMLHttpRequest = new Proxy(window.XMLHttpRequest, {
1616
construct: function (target, args) {
1717
// 第一次创建XHR时, 打上断点...
18-
if (firstCreateXHR && r.script.is_dev) {
18+
if (firstCreateXHR && Scripts.isDev) {
1919
firstCreateXHR = false
2020
// debugger
2121
}

packages/unblock-area-limit/src/util/log.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { r } from "../feature/r"
21
import { Objects } from "./objects"
2+
import { Scripts } from "./scripts"
33
import { Strings } from "./strings"
44

55
const tag = GM_info.script.name + '.msg'
@@ -42,7 +42,7 @@ type ConsoleLogFunctions = {
4242
}
4343

4444
function logImpl(type: keyof ConsoleLogFunctions): (...args: any) => void {
45-
if (r.script.is_dev) {
45+
if (Scripts.isDev) {
4646
// 直接打印, 会显示行数
4747
return window.console[type].bind(window.console, type + ':');
4848
} else {

packages/unblock-area-limit/src/util/message.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { util_init } from './initiator'
33
import { util_log } from './log'
44
import { util_notify } from './notification'
55
import { ui } from './ui'
6-
import { Func } from './utils'
6+
import { noop } from './utils'
77
/**
88
* {@link BiliMessageBox}
99
* MessageBox -> from base.core.js
@@ -32,7 +32,7 @@ let alertPopMessage: BiliMessageBox = {
3232
show: function (referenceElement, message, closeTime, boxType, buttonTypeConfirmCallback) {
3333
ui.alert(message, buttonTypeConfirmCallback)
3434
},
35-
close: Func.noop
35+
close: noop
3636
}
3737

3838
util_init(() => {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export namespace Scripts {
2+
export const isDev = GM_info.script.name.includes('.dev')
3+
}

packages/unblock-area-limit/src/util/utils.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ export async function asyncTest() {
44
return 'asyncTest'
55
}
66

7+
export function noop() { }
8+
79
export namespace Func {
8-
export function noop() { }
910

1011
export function runCatching(func: Function, onError?: (e: any) => any) {
1112
let ret = function (this: any) {

scripts/bilibili_block_ugc.user.js

+2-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)