0

I have a js function(timer to reload the webpage) running on a website and I want to know is there any way to access and modify variables in this function so that website can reload right now.

I tried to access variables using following in the console

window.secondsLeft=0

But nothing happened. If I tried to access any other variable I got undefined.

<script type="text/javascript">
var end_time = moment().add(265.96296960866664, 'minutes').toDate();
var totalSeconds = 15957.778176519998;
$('#clock').countdown(end_time).on('update.countdown', function(event) {
   var format = '%D Days %H Hr : %M min : %S sec ';
   var secondsLeft = (new Date(end_time).getTime() - parseInt(event.timeStamp))/(1000);
   var percentage = 100 - (secondsLeft/parseFloat(totalSeconds))*100;
   if (secondsLeft <= 60 && secondsLeft >= 59)   {
       toastr.info('Starting!.', 'Info', {timeOut: 5000});
   } 
  else if (secondsLeft <= 0)    {
       toastr.clear();
   }
   $(this).html(event.strftime(format));
   })
   .on('finish.countdown', function(event) {
   document.location.reload(true);
   });
</script>

Is there any way to set secondsLeft = 0 ?

2 Answers 2

1

The only way you could change a local variable in the console is to set a breakpoint in the code that has access to that variable, and once the breakpoint is hit enter your command in the console. Other than with breakpoints, any commands are going to run in a global scope, and don't have access to local variables.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks I tried but even though this function is available in source code it isn't visible in debugger. I tried to find it in files shown in Debugger. I think it has been hidden.
0

You can try to override the event listener of $('#clock')

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.