aboutsummaryrefslogtreecommitdiffstats
path: root/pixiv.js
diff options
context:
space:
mode:
authormitsugu oyama2014-12-12 16:06:04 +0900
committermitsugu oyama2014-12-12 16:06:04 +0900
commitc7477262bd421efbe5e074344dd6c1efd1640b37 (patch)
treee38ead9dbfbe8a27e5a6d562f906b77e17f94a0a /pixiv.js
parente198bec13c19bfd27ec533410de09bc059c68e23 (diff)
downloadvimperator-plugins-c7477262bd421efbe5e074344dd6c1efd1640b37.tar.bz2
pixiv のコンテンツ構造の変化に追従
1 枚画像のページにて JavaScript で画像を表示するようになっているのに 追従。
Diffstat (limited to 'pixiv.js')
-rw-r--r--pixiv.js49
1 files changed, 21 insertions, 28 deletions
diff --git a/pixiv.js b/pixiv.js
index 07ec62c..b8bd6bb 100644
--- a/pixiv.js
+++ b/pixiv.js
@@ -212,22 +212,13 @@ commands.addUserCommand(
// }}}
// {{{ save single image file
- let getImageUrl=function(pageContents){
- let url;
- let htmldoc=getDOMHtmlDocument(pageContents);
- if(htmldoc){
- if(0<htmldoc.getElementsByTagName('img').length)
- url=htmldoc.getElementsByTagName('img').item(0).getAttribute('src');
- else
- url='';
- }else{
- url=pageContents.match(/http:\/\/img[0-9]{2}\.pixiv\.net\/img\/[0-9a-z_]+\/[0-9]+\.jpg|http:\/\/img[0-9]{2}\.pixiv\.net\/img\/[0-9a-z_]+\/[0-9]+\.png/i);
- }
+ let getImageUrl=function(pContents){
+ let url = pContents.getElementsByClassName("_layout-thumbnail _illust_modal")[0].childNodes.item( 1 ).getAttribute( "data-src" );
return url;
};
let saveImageFile=function(){
- let imgUrl=getImageUrl(xhrImgInfo.responseText);
+ let imgUrl=getImageUrl(contents);
if(0<imgUrl.length){
let destPath=getDestPath(imgUrl);
if(destPath==null){
@@ -278,9 +269,7 @@ commands.addUserCommand(
// {{{ trueImgINfo
let trueImgInfo=function(){
- if(-1!=type.search(/big&illust_id=/i)){
- saveImageFile();
- }else if(-1!=type.search(/manga&illust_id=/i)){
+ if(-1!=type.search(/manga&illust_id=/i)){
saveMangaFiles();
}else{
liberator.echoerr("This page is not image page and not manga page.");
@@ -301,16 +290,20 @@ commands.addUserCommand(
done : function (aResult) {
if ( aResult == fp.returnOK ) {
saveDirectory = fp.file;
- xhrImgInfo = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"]
- .createInstance();
- xhrImgInfo.QueryInterface( Ci.nsIDOMEventTarget );
- xhrImgInfo.addEventListener( "load", trueImgInfo, false );
- xhrImgInfo.addEventListener( "error", falseImgInfo, false );
- xhrImgInfo.QueryInterface( Ci.nsIXMLHttpRequest );
- xhrImgInfo.open( "GET", url, true);
- xhrImgInfo.setRequestHeader( 'Referer', contents.URL );
- xhrImgInfo.setRequestHeader( 'Cookie', cookie );
- xhrImgInfo.send( null );
+ if ( url == null ) {
+ saveImageFile();
+ } else {
+ xhrImgInfo = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"]
+ .createInstance();
+ xhrImgInfo.QueryInterface( Ci.nsIDOMEventTarget );
+ xhrImgInfo.addEventListener( "load", trueImgInfo, false );
+ xhrImgInfo.addEventListener( "error", falseImgInfo, false );
+ xhrImgInfo.QueryInterface( Ci.nsIXMLHttpRequest );
+ xhrImgInfo.open( "GET", url, true);
+ xhrImgInfo.setRequestHeader( 'Referer', contents.URL );
+ xhrImgInfo.setRequestHeader( 'Cookie', cookie );
+ xhrImgInfo.send( null );
+ }
}
}
};
@@ -318,9 +311,9 @@ commands.addUserCommand(
type = contents.getElementsByClassName('works_display')
.item(0).firstChild.getAttribute('href');
- if(-1!=type.search(/big&illust_id=/i)){
- url=contents.documentURI.replace('medium','big');
- }else if(-1!=type.search(/manga&illust_id=/i)){
+ if( type == null ){ // single iamge
+ url=null;
+ }else if(-1!=type.search(/manga&illust_id=/i)){ // plural image
url=contents.documentURI.replace('medium','manga')+'&type=scroll';
}else{
liberator.echoerr("This page is not image page and not manga page.");