aboutsummaryrefslogtreecommitdiffstats
path: root/nextlink.js
diff options
context:
space:
mode:
authorsnaka2009-06-03 19:09:31 +0000
committersnaka2009-06-03 19:09:31 +0000
commit028b1e00f3341125d5fa0be194fc00c0e126ed4b (patch)
tree8256775aa110f580aeb304b5b5f59a7004bf6f75 /nextlink.js
parentdb3faaa72c2b8cb1681246ad7542694b7ed25476 (diff)
downloadvimperator-plugins-028b1e00f3341125d5fa0be194fc00c0e126ed4b.tar.bz2
- リファクタリング
- メッセージの日本語化 - 非同期化 - 複数サイトのwatchに対応 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@33773 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'nextlink.js')
0 files changed, 0 insertions, 0 deletions
uthor> <license href="http://opensource.org/licenses/mit-license.php">MIT</license> <project name="Vimperator" minVersion="2.3"/> <p> You can save image on the currnet context area by this plugin. </p> <item> <tags>'simg'</tags> <spec>:simg</spec> <description> <p>You can save image on the currnet context area by this plugin.</p> </description> </item> </plugin>; commands.addUserCommand( ['simg'], 'Save Image File current page', function(){ let contents=gBrowser.selectedBrowser.contentDocument; let Cc=Components.classes; let Ci=Components.interfaces; let cookie=contents.cookie; let xhrImg; let directoryPicker=function() { let path; let fp=Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker); fp.init(window,'Select Directory',Ci.nsIFilePicker.modeGetFolder); let result=fp.show(); switch(result){ case Ci.nsIFilePicker.returnOK: path=fp.file.path; break; default: case Ci.nsIFilePicker.returnCancel: return ''; } return path; }; let savePath=directoryPicker(); if(savePath.length<1) return; let imgURL=contents.URL; let trueCurrntImg=function(){ let fileName=imgURL.substr(imgURL.lastIndexOf('/')); if (-1!=fileName.indexOf('?')){ fileName=fileName.substr(0,fileName.indexOf('?')); } savePath=savePath+fileName; let instream=xhrImg.responseText; let aFile=Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile); 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); outstream.write(instream,instream.length); if (outstream instanceof Ci.nsISafeOutputStream) { outstream.finish(); }else{ outstream.close(); } }; let falseCurrntImg=function(){ liberator.echo("Image file accept error."); return false; }; xhrImg=Cc["@mozilla.org/xmlextras/xmlhttprequest;1"] .createInstance(); xhrImg.QueryInterface(Ci.nsIDOMEventTarget); xhrImg.addEventListener("load",trueCurrntImg,false); xhrImg.addEventListener("error",falseCurrntImg,false); xhrImg.QueryInterface(Ci.nsIXMLHttpRequest); xhrImg.open("GET",imgURL,true); xhrImg.overrideMimeType('text/plain;charset=x-user-defined'); xhrImg.setRequestHeader('Referer',contents.URL); xhrImg.setRequestHeader('Cookie',cookie); xhrImg.send(null); } );