how to keep this timer running even when popup.html is closed?
i am saving the last time in storage so that it resumes from last stopped point but how to keep the setinterval keep running manifest has persistence as true. and this script in background
function timer(){
if(localStorage.getItem('tile')==null){
secs=32400;
}
if(localStorage.getItem('tile')!=null){
secs=localStorage.getItem('tile');
}
console.log(secs);
if(secs!==0){
function z(n) { return (n < 10 ? '0' : '') + n; }
var sign = secs < 0 ? '-' : '';
secs = Math.abs(secs);
secs = secs-1;
chrome.storage.local.get(["actualtime"],function (result){aht = (((Number(result.actualtime))*((13/8)*60))/(28800-secs)/60);
document.getElementById("time2").innerHTML = aht.toFixed(2);
})
aht2 = (((secs/60))*((13/8)))/(28800/60);
document.getElementById("time3").innerHTML = aht2.toFixed(2);
document.getElementById("counter").innerHTML= sign + z(secs / 3600 | 0) + ':' + z((secs % 3600) / 60 | 0) + ':' + z(secs % 60);
console.log(localStorage.getItem('actualtime'));
localStorage.setItem('tile',secs);
}
}
setInterval(timer,1000);
cant use the same js for background as well as for popup.html //mistake i made. ran a seperate js for background and a js for popup.html used msg parsing to communicate between them Background one kept running and the js for popup.html gets called only when popup.html is opened.(and stops when closed)