I am building a bulk download extension from chrome and firefox to download a large number of files. The pop up of the extension has the cancel/pause/resume features. The pop up works fine when downloading a small number of files. However, when downloading a larger number of files, the pop-up menu takes forever to actually pop-up (or some time it doesn't whatsoever) probably because the extension becomes very busy and processing a lot of files at a time. Is there a way to eliminate this delay?
manifest.json
"default_popup": "html/popup.html"
},
popup.html
let bgPage = chrome.extension.getBackgroundPage(); //Getting the variables from the background page
let idsOfDownload = [];
idsOfDownload = bgPage.downloadIds;
console.log(idsOfDownload);
let cancel = document.createElement("button");
cancel.id = "cancel";
cancel.className = "btn";
cancel.innerHTML='<i class="fa fa-stop-circle"></i> Cancel All</button>';
document.body.appendChild(cancel);
$('body').width(350);
setInterval(function(){
let downloadString = LZString.decompress(localStorage.getItem('downloadLinks'));
if(downloadString === "") return;
let downloadLinks = JSON.parse(downloadString);
if (downloadLinks !== undefined && downloadLinks !== null && downloadLinks !== "null") {
let status = `Total pending download: ${downloadLinks.length}`;
jQuery("#download-status").html(status);
}
},1000);
$(cancel).click(function () {
chrome.runtime.sendMessage({message: "cancel-download"});
});