ExplicitMessage_Inject

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

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

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

/**
 * ExplicitMessage_Inject
 * @file [DEBUG] 信息显式化(注入版)
 * @version 1.4.0.20210927
 * @author Laster2800
 */

(function() {
  'use strict'

  let updateAlerted = false
  const injectVersion = 20210927
  const m = unsafeWindow[Symbol.for('ExplicitMessage')]
  for (const n of ['log', 'debug', 'info', 'warn', 'error']) {
    const log = console[n]
    console[n] = (...args) => {
      if (m?.fn?.wrappedLog) {
        if (injectVersion !== m.injectUpdate) {
          if (!updateAlerted) {
            updateAlerted = true
            m.fn.updateCheck?.(GM_info.script.name, injectVersion > m.injectUpdate)
          }
          console[n] = log
        } else {
          console[n] = m.fn.wrappedLog(console, log, n.toUpperCase(), GM_info.script.name)
        }
        Reflect.apply(console[n], console, args)
      } else {
        Reflect.apply(log, console, args)
      }
    }
  }
})()