Skip to content

Commit

Permalink
Only start the timer once all HTML is loaded.
Browse files Browse the repository at this point in the history
  • Loading branch information
mscavnicky committed Mar 6, 2016
1 parent d7bf34a commit 0d91270
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions js/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@ function block() {
chrome.runtime.sendMessage(message, function(imageId) {
var html = request.responseText.replace(/{{imageId}}/g, imageId);
document.all[0].innerHTML = html;
});
}

// Start the countdown
chrome.storage.sync.get(defaultOptions, function(items) {
var waitTime = items.waitTime;
document.getElementById('timer').innerHTML = waitTime;

var timer = setInterval(function() {
if (waitTime <= 0) {
clearInterval(timer);
unblock();
} else {
// Start the countdown
chrome.storage.sync.get(defaultOptions, function(items) {
var waitTime = items.waitTime;
document.getElementById('timer').innerHTML = waitTime;
waitTime -= 1;
}
}, 1000);
});

var timer = setInterval(function() {
if (waitTime <= 0) {
clearInterval(timer);
unblock();
} else {
document.getElementById('timer').innerHTML = waitTime;
waitTime -= 1;
}
}, 1000);
});
});
}
}

function unblock() {
Expand Down

0 comments on commit 0d91270

Please sign in to comment.