Home > front end >  Change variable in script with chrome console
Change variable in script with chrome console

Time:07-29

The website have the button like this

enter image description here

When I click it will call the script below:

enter image description here

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);
})}

How I can change timeleft variables when I run function count() with google console enter image description here I can run function count but I can't change timeleft variables

CodePudding user response:

You can't access that variable, but you can redefine the 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();

  • Related