diff options
-rw-r--r-- | tinami.js | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -1,6 +1,6 @@ // INFO // var INFO = -<plugin name="tinami.js" version="0.1" +<plugin name="tinami.js" version="0.2" summary="Download image from tinami" href="http://github.com/vimpr/vimperator-plugins/blob/master/tinami.js" xmlns="http://vimperator.org/namespaces/liberator"> @@ -59,17 +59,27 @@ commands.addUserCommand( let cookie=contents.cookie; let xhrImgInfo; let xhrImg; - let savePath=directoryPicker(); - if(savePath.length<1) return; + let saveDirectory=directoryPicker(); + if(saveDirectory.length<1) return; let imgUrl; + let savePath; let trueTinamiImg=function(){ let fileName=imgUrl.substr(imgUrl.lastIndexOf('/')); - savePath=savePath+fileName; + savePath=saveDirectory+fileName; let instream=xhrImg.responseText; let aFile=Cc["@mozilla.org/file/local;1"] .createInstance(Ci.nsILocalFile); aFile.initWithPath(savePath); + if(true===aFile.exists()){ + let value=window.prompt('すでに同じ名前のファイルがあります。\nデフォルトファイル名を変更してください。',fileName.substr(1)); + if(null===value){ + return false; + } + fileName='/'+value; + savePath=saveDirectory+fileName; + aFile.initWithPath(savePath); + } let outstream=Cc["@mozilla.org/network/safe-file-output-stream;1"] .createInstance(Ci.nsIFileOutputStream); outstream.init(aFile,0x02|0x08|0x20,0664,0); |