繁体   English   中英

使用 chrome 控制台更改脚本中的变量

[英]Change variable in script with chrome console

该网站有这样的按钮

在此处输入图像描述

当我点击它会调用下面的脚本:

在此处输入图像描述

function count(){
let downloadTimer;
var timeleft = 30;
downloadTimer = setInterval(countDown,1000)
function countDown(){
  document.getElementById("aaa").innerHTML = "Wait " ;
  document.getElementById("hid").style.display = "none";
  document.getElementById("timer").innerHTML = timeleft ;
  timeleft -= 1;
  if(timeleft < 0){
  clearInterval(downloadTimer);
  document.getElementById("timer").innerHTML = "1414-YYYI"
  }
}

$(window).blur(function(){
  console.log("blurred")
  clearInterval(downloadTimer);
})
$(window).focus(function(){
  console.log("focuesed")
  downloadTimer = setInterval(countDown,1000);
})}

使用谷歌控制台运行 function count() 时如何更改 timeleft 变量在此处输入图像描述 我可以运行 function 计数,但我无法更改 timeleft 变量

您无法访问该变量,但可以重新定义 function。

 function count() { var timeleft = 30; console.log("time left: " + timeleft) } count(); var entire = count.toString(); var body = entire.slice(entire.indexOf("{") + 1, entire.lastIndexOf("}")); var count = new Function((body).replace("30", "2")) count();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM