Commit d079dc5e authored by ronald's avatar ronald

can auto-rename downloading zip files

parent 8a58ca50
'use strict';
chrome.runtime.onInstalled.addListener(function() {
chrome.storage.sync.set({color: '#3aa757'}, function() {
console.log("The color is green.");
});
});
chrome.declarativeContent.onPageChanged.removeRules(undefined, function() {
chrome.declarativeContent.onPageChanged.addRules([{
conditions: [new chrome.declarativeContent.PageStateMatcher({
......@@ -15,3 +9,18 @@ chrome.declarativeContent.onPageChanged.removeRules(undefined, function() {
actions: [new chrome.declarativeContent.ShowPageAction()]
}]);
});
var initial = 0;
var a;
chrome.extension.onMessage.addListener(function(request,sender,sendResponse){
chrome.storage.local.get('idArray',function(item) {
a = item.idArray.split(',');
});
console.log(a);
});
chrome.downloads.onDeterminingFilename.addListener(function(item, suggest) {
var new_filename = a[initial] + ".zip";
suggest({filename: new_filename});
initial++;
});
\ No newline at end of file
......@@ -12,7 +12,7 @@
"manifest_version" : 2,
"permissions" : ["tabs","*://*/*","activeTab","<all_urls>","declarativeContent","storage"],
"permissions" : ["tabs","*://*/*","activeTab","<all_urls>","declarativeContent","storage","downloads"],
"page_action": {
"default_popup": "popup.html",
......
......@@ -22,6 +22,7 @@ chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
chrome.storage.local.set({idArray : idArray}, function () {
console.log("set storage");
});
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