返回列表

3秒内连续点击指定元素10次,开启调试模式

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

代码如下:

// 注:3秒内连续点击.float-advertise元素10次,开启调试模式,关闭同理
document.querySelector('.float-advertise').addEventListener('click', function(){
  window.dbg_md = window.dbg_md || {}
  var me = window.dbg_md
  var now = (new Date()).getTime()
  if (me.clickTime && now - me.clickTime < 3000) {
    me.clickCount++
  } else {
    me.clickCount = 1
    me.clickTime = now
  }
  if (me.clickTimer) window.clearTimeout(me.clickTimer)
  me.clickTimer = window.setTimeout(function() {
    window.dbg_md.clickTimer = ''
    if (window.dbg_md.clickCount > 7 && window.dbg_md.clickCount < 11) {
      switchDebugModel()
      window.location.reload()
    }
  }, 1000)
})
function switchDebugModel () {
  var sign = window.localStorage.getItem('debug_model')
  sign = sign ? '' : '1'
  window.localStorage.setItem('debug_model', sign)
}


>> 留言评论