Commit 92f1725e authored by ronald's avatar ronald

update message passing from popup to background

parent 3b2abbcc
...@@ -10,17 +10,15 @@ chrome.declarativeContent.onPageChanged.removeRules(undefined, function() { ...@@ -10,17 +10,15 @@ chrome.declarativeContent.onPageChanged.removeRules(undefined, function() {
}]); }]);
}); });
var initial = 0; var initial = 0;
var a; var skus;
chrome.extension.onMessage.addListener(function(request,sender,sendResponse){ chrome.extension.onMessage.addListener(function(request,sender,sendResponse){
chrome.storage.local.get('idArray',function(item) { skus = request.idArray.split(',');
a = item.idArray.split(','); console.log(skus);
});
console.log(a);
}); });
chrome.downloads.onDeterminingFilename.addListener(function(item, suggest) { chrome.downloads.onDeterminingFilename.addListener(function(item, suggest) {
var new_filename = a[initial] + ".zip"; var new_filename = skus[initial] + ".zip";
suggest({filename: new_filename}); suggest({filename: new_filename});
initial++; initial++;
}); });
\ No newline at end of file
...@@ -11,7 +11,7 @@ inputButton.onclick = function(element) { ...@@ -11,7 +11,7 @@ inputButton.onclick = function(element) {
chrome.storage.local.set({idArray : idArray}, function () { chrome.storage.local.set({idArray : idArray}, function () {
console.log("set storage"); console.log("set storage");
}); });
chrome.runtime.sendMessage("Message sent"); chrome.runtime.sendMessage({idArray: idArray});
}); });
} }
...@@ -31,4 +31,4 @@ toGoogle.onclick = function(element) { ...@@ -31,4 +31,4 @@ toGoogle.onclick = function(element) {
// chrome.runtime.sendMessage(null); // chrome.runtime.sendMessage(null);
// }); // });
// } // }
// }); // });
\ No newline at end of file
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