首页 > 解决方案 > 需要帮助循环让 runOurCode

问题描述

我试图将 runOurCode 设置为 true,然后每 5 秒设置一次 false 我尝试了 setInterval、setTimout、forLoop 并且仍然有效询问了一些朋友,但每个人都离线 rn:/

var editingCode;
let runOurCode = false
const oldFrame = requestAnimationFrame;
WebSocket.prototype.send = new Proxy(WebSocket.prototype.send, {
  apply: function(target, scope, args) {
    if (typeof(args[0]) === 'string') {
      let json = JSON.parse(args[0]);
      if (json[0] === 3) {
        editingCode = (json[1])
      }
    }
    let data = target.apply(scope, args);
    return data;
  }
})

WebSocket.prototype.send = new Proxy(WebSocket.prototype.send, {
  apply: function(target, scope, args) {
    if (typeof(args[0]) === 'string') {
      let json = JSON.parse(args[0]);
      if (runOurCode) {
        target.apply(scope, [`[5,77]`]) // u dont need function here (MY BAD)
        runOurCode = false // set back to false so it doesnt keep drinking
      }
    }

    let run = false
    document.addEventListener("keypress", e => {
      if (e.code === "KeyC") {
        runOurCode = true
      }
    })

    let data = target.apply(scope, args);
    return data;
  }
})

标签: javascript

解决方案


推荐阅读