Commit 00e12d50 authored by edwin's avatar edwin

init index when enter info, attempt on getting idArray if skus empty to reduce...

init index when enter info, attempt on getting idArray if skus empty to reduce chance on undefined file name
parent 84cbc21f
......@@ -15,8 +15,13 @@ chrome.declarativeContent.onPageChanged.removeRules(undefined, function() {
chrome.extension.onMessage.addListener(function(request,sender,sendResponse){
if(request.idArray) {
// init
index = 0;
noImages = "";
skus = request.idArray.split(',');
console.log(skus);
} else if(request.nothing == "true") {
console.log("Message : nothing ");
index++;
......@@ -34,6 +39,13 @@ chrome.extension.onMessage.addListener(function(request,sender,sendResponse){
});
chrome.downloads.onDeterminingFilename.addListener(function(item, suggest) {
if(!skus.length){
chrome.storage.local.get('idArray', function (items) {
skus = items.idArray.split(',');
});
}
var new_filename = skus[index] + ".zip";
suggest({filename: new_filename});
index++;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment