导航栏: 首页 评论列表

根据debug_model开启调试vconsole

默认分类 2020/05/26 02:38

代码如下:

// [根据debug_model开启调试vconsole]
;(function(){
  if (!window.localStorage || !window.localStorage.getItem('debug_model')) return ''
  var script = document.createElement('script') 
  script.src = 'vconsole.min.js' 
  document.getElementsByTagName('head')[0].appendChild(script)
  script.onload = function () { new VConsole() } 

  // [JS错误监控]
  window.saveJsErrorLog = function (msg, file, line) {
    var encode = window.encodeURIComponent
    var str = []
    var url = [
      'http://i0.hdslb.com/bfs/activity-plat/static/487ed9538142fdbfc4221cf26c20bd50/YyJiC6Zol.png?hy=1',
      '&l=' + encode(line),
      '&m=' + encode(msg),
      '&f=' + encode(file),
      '&h=' + encode(window.location.href),
      '&u=' + encode(window.navigator.userAgent),
      '&p=' + encode('{' + str.join(',<br>') + '}'),
      '&r=' + Math.random()
    ].join('')

    var p = document.createElement('img')
    p.src = url
    p.id = Math.random()
    p.width = 1
    p.height = 1
    p.style.cssText = 'position:absolute;left:-1px;top:-1px;z-index:-1;border:0'
    document.documentElement.appendChild(p)

    var blank = 'data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='
    window.setTimeout(Function('document.getElementById("' + p.id + '").src = "' + blank + '";'), 4000)
  }
  window.saveJsErrorLog.version = '3.0.0'

  if (window.addEventListener) {
    window.addEventListener('error', function(e) {
      window.saveJsErrorLog(e.message, e.filename, e.lineno)
    }, false);
  } else if (window.attachEvent) {
    window.attachEvent('onerror', function(msg, file, line) {
      window.saveJsErrorLog(msg, file, line)
    })
  }
})();


>> 留言评论