javascript - 需要帮助循环让 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;
}
})
解决方案
推荐阅读
- python - 为什么在烧瓶应用程序的路由中添加“Admin”一词会导致页面变为 404?
- c++ - 用模板参数推导推导出一个类的“外部类”
- flutter - Flutter - 动态添加需要更改状态的小部件
- javascript - 输入焦点从键盘输入更改为非键盘输入后,如何使离子选择弹出框正确呈现?
- javascript - 在启动时获取数据
- javascript - 如果单元格等于我的查询,如何从 html 表中获取一行?
- sas - 如何使用宏将名称中带有日期的多个文件读入SAS
- python - DataFrame对象类型列到int或float错误
- android - 如何从特定片段中的活动中禁用 onDestroy 方法?
- javascript - 使用for循环在一个字符串中插入多个字符串