From 90f46257e3d7d24b0dbca76bec36a7a8e0512deb Mon Sep 17 00:00:00 2001 From: mitsugu oyama Date: Thu, 4 Nov 2010 20:49:06 +0900 Subject: complete suppoted manga page. --- pixiv.js | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 75 insertions(+), 12 deletions(-) (limited to 'pixiv.js') diff --git a/pixiv.js b/pixiv.js index ba0e9b1..85f08e8 100644 --- a/pixiv.js +++ b/pixiv.js @@ -1,6 +1,6 @@ // INFO // -var INFO = - @@ -36,8 +36,23 @@ commands.addUserCommand( let Cc=Components.classes; let Ci=Components.interfaces; - const baseInfo="http://www.pixiv.net/member_illust.php?mode=big&illust_id="; - let id=contents.URL.substr(contents.URL.lastIndexOf('=')+1); + let baseInfo; + let id; + let scroll; + let type=contents.getElementsByClassName('works_display').item(0) + .firstChild.getAttribute('href'); + if(-1!=type.search(/big&illust_id=/i)){ + baseInfo="http://www.pixiv.net/member_illust.php?mode=big&illust_id="; + id=contents.URL.substr(contents.URL.lastIndexOf('=')+1); + scroll=''; + }else if(-1!=type.search(/manga&illust_id=/i)){ + baseInfo="http://www.pixiv.net/member_illust.php?mode=manga&illust_id="; + id=contents.URL.substr(contents.URL.lastIndexOf('=')+1); + scroll='&type=scroll'; + }else{ + liberator.echoerr("This page is not image page and not manga page."); + return false; + } let cookie=contents.cookie; let directoryPicker=function() { @@ -106,11 +121,11 @@ commands.addUserCommand( let truePixivImg=function(){ let fileName=imgUrl.substr(imgUrl.lastIndexOf('/')); - savePath=savePath+fileName; + let tmpPath=savePath+fileName; let instream=xhrImg.responseText; let aFile=Cc["@mozilla.org/file/local;1"] .createInstance(Ci.nsILocalFile); - aFile.initWithPath(savePath); + aFile.initWithPath(tmpPath); let outstream=Cc["@mozilla.org/network/safe-file-output-stream;1"] .createInstance(Ci.nsIFileOutputStream); outstream.init(aFile,0x02|0x08|0x20,0664,0); @@ -127,26 +142,74 @@ commands.addUserCommand( return false; }; - let saveImag=function(){ + let saveImage=function(){ xhrImg=Cc["@mozilla.org/xmlextras/xmlhttprequest;1"] .createInstance(); xhrImg.QueryInterface(Ci.nsIDOMEventTarget); xhrImg.addEventListener("load",truePixivImg,false); xhrImg.addEventListener("error",falsePixivImg,false); xhrImg.QueryInterface(Ci.nsIXMLHttpRequest); - xhrImg.open("GET",imgUrl,true); + xhrImg.open("GET",imgUrl,false); xhrImg.overrideMimeType('text/plain;charset=x-user-defined'); xhrImg.setRequestHeader('Referer',contents.URL); xhrImg.setRequestHeader('Cookie',cookie); xhrImg.send(null); }; - let trueImgInfo=function(){ + let saveImageFile=function(){ imgUrl=getImageUrl(xhrImgInfo.responseText); if(0