ExplicitMessage_Inject

[DEBUG] 信息显式化(注入版)

2021-07-18 기준 버전입니다. 최신 버전을 확인하세요.

이 스크립트는 직접 설치하는 용도가 아닙니다. 다른 스크립트에서 메타 지시문 // @require https://update.greasyfork.org/scripts/429525/951788/ExplicitMessage_Inject.js을(를) 사용하여 포함하는 라이브러리입니다.

/**
 * ExplicitLog_Inject
 * @file [DEBUG] 显式日志(注入版)
 * @version 2.0.1.20210718
 * @author Laster2800
 */

(function() {
  const w = unsafeWindow
  const logs = ['log', 'warn', 'error']
  for (const log of logs) {
    const _ = console[log]
    console[log] = function() {
      if (w.gm429521?.config.enabled) {
        const m = [arguments, log.toUpperCase()]
        if (w.gm429521?.fn.match(m, w.gm429521?.config.include) && !w.gm429521?.fn.match(m, w.gm429521?.config.exclude)) {
          let msg = null
          if (arguments.length == 1) {
            if (typeof arguments[0] == 'object') {
              msg = JSON.stringify(arguments[0])
            } else {
              msg = arguments[0]
            }
          } else {
            msg = JSON.stringify(arguments)
          }
          w.gm429521?.fn.explicit(msg, log.toUpperCase(), GM_info.script.name)
        }
      }
      return _.apply(console, arguments)
    }
  }
})()