From 7b30e0eeb0a1b78cace0e3b5ce1a11858b841d75 Mon Sep 17 00:00:00 2001 From: mitsugu oyama Date: Sat, 30 Jul 2011 13:58:10 +0900 Subject: migration web site --- tinami.js | 189 -------------------------------------------------------------- 1 file changed, 189 deletions(-) delete mode 100644 tinami.js (limited to 'tinami.js') diff --git a/tinami.js b/tinami.js deleted file mode 100644 index c96bb9a..0000000 --- a/tinami.js +++ /dev/null @@ -1,189 +0,0 @@ -// INFO // -var INFO = - - Mitsugu Oyama - MIT - -

- You can save image from TINAMI by this plugin. -

- - 'TINAMI' - :tinami - -

You can save image from TINAMI by this plugin.

-

You must login tinami, and must display image page.(ex. http://www.tinami.com/view/??????)

-

Not supported manga page and novel page.

-
-
-
; - -commands.addUserCommand( - ['tinami'], - 'Save Image File from tinami', - function(){ - let Cc=Components.classes; - let Ci=Components.interfaces; - - let contents=gBrowser.selectedBrowser.contentDocument; - if(contents.domain!="www.tinami.com"){ - liberator.echoerr('This page is not tinami.'); - return false; - } - if(contents.URL.search(/view/i)==-1){ - liberator.echoerr("This page is not tinami's image page."); - return false; - } - - 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; - }; - - const baseInfo="http://www.tinami.com/view/original/"; - let id=contents.URL.substr(contents.URL.lastIndexOf('/')+1); - let cookie=contents.cookie; - let xhrImgInfo; - let xhrImg; - let saveDirectory=directoryPicker(); - if(saveDirectory.length<1) return; - let imgUrl; - let savePath; - - let trueTinamiImg=function(){ - let fileName=imgUrl.substr(imgUrl.lastIndexOf('/')); - 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); - outstream.write(instream,instream.length); - if (outstream instanceof Ci.nsISafeOutputStream) { - outstream.finish(); - }else{ - outstream.close(); - } - }; - - let falseTinamiImg=function(){ - liberator.echoerr("Image file accept error."); - return false; - }; - - let saveImag=function(){ - xhrImg=Cc["@mozilla.org/xmlextras/xmlhttprequest;1"] - .createInstance(); - xhrImg.QueryInterface(Ci.nsIDOMEventTarget); - xhrImg.addEventListener("load",trueTinamiImg,false); - xhrImg.addEventListener("error",falseTinamiImg,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); - }; - - let getDOMHtmlDocument=function(str){ - let doc; - let range; - try{ - if(document.implementation.createHTMLDocument){ - doc=document.implementation.createHTMLDocument(''); - range=doc.createRange(); - range.selectNodeContents(doc.documentElement); - range.deleteContents(); - doc.documentElement.appendChild(range.createContextualFragment(str)); - }else{ - let doctype=document.implementation.createDocumentType( - 'html', - '-//W3C//DTD HTML 4.01 Transitional//EN', - 'http://www.w3.org/TR/html4/loose.dtd' - ); - doc=document.implementation.createDocument(null,'html',doctype); - range=doc.createRange(); - range.selectNodeContents(doc.documentElement); - let content=doc.adoptNode(range.createContextualFragment(str)); - doc.documentElement.appendChild(content); - } - }catch(e){ - doc=null; - } - return doc; - }; - - let getImageUrl=function(pageContents){ - let url; - let htmldoc=getDOMHtmlDocument(pageContents); - if(htmldoc){ - if(0