How to stop a javascript countdown timer with userscript or bookmarklet

2.3k views Asked by At

I want to disable an onload javascript countdown timer with userscript or bookmarklet.

function startTimer(duration) {
            var timer = duration, minutes, seconds;
            var refreshIntervalId =  setInterval(function () {
                minutes = parseInt(timer / 60, 10)
                seconds = parseInt(timer % 60, 10);
                minutes = minutes < 10 ?  minutes : minutes;
                seconds = seconds < 10 ?  seconds : seconds;
                // display.text(minutes + ":" + seconds);
                //display.text(seconds);
                $('#timer_msg').html('You can submit request after '+seconds+' seconds');
                if (--timer < 0) {
                    $('#timer_msg').html(' <input type="submit" name="submit_btn" class="btn btn-primary" value="Submit">');                    
                    return;
                }
            }, 1000);
        }
$( document ).ready(function() {

         startTimer(20);


                });

What this timer does is it waits 20 seconds after pageload then shows the submit button, but I want to skip this 20 seconds so that I can submit immediately. I tried re-declaring the function at the bottom of the page with startTimer(0); with userscript but no luck there!

Tried

$('timer_msg').html('<input type="submit" name="submit_btn" class="btn btn-primary" value="Submit">');

but again the timer is ticking.

Then how can I stop this timer with userscript or bookmarklet?

0

There are 0 answers