Skip to content

Instantly share code, notes, and snippets.

@Qofar
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Qofar/7057243f974b03a6898e to your computer and use it in GitHub Desktop.
Save Qofar/7057243f974b03a6898e to your computer and use it in GitHub Desktop.
chrome.downloads.onDeterminingFilenameを使うと最後に保存したフォルダを記憶してくれなくなるがfilenameに絶対パスを指定することでエラーを起こし無理やり機能させる
chrome.downloads.onChanged.addListener(function(downloadDelta) {
if (downloadDelta.state && downloadDelta.state.current === "complete") {
var id = downloadDelta.id;
setTimeout(function(){
chrome.downloads.erase({id: id});
}, 5000);
}
});
chrome.downloads.onDeterminingFilename.addListener(function(downloadItem, suggest) {
var dir = "C:\\";
suggest({filename: dir + downloadItem.filename, conflictAction: "prompt"});
});
{
"background": {
"persistent": false,
"scripts": [ "background.js" ]
},
"description": "FilenameConflictAction prompt. AND auto-hide download bar.",
"manifest_version": 2,
"name": "DownloadPlus",
"permissions": [ "downloads" ],
"version": "1.0"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment