// INFO // var INFO = Mitsugu Oyama MIT

You can save image from pixiv by this plugin.

'pixiv' :pixiv

You can save image from pixiv by this plugin.

You must login pixiv.

; commands.addUserCommand( ['pixiv'], 'Save Image File from pixiv', function(){ let contents=gBrowser.selectedBrowser.contentDocument; if(contents.domain!="www.pixiv.net"){ liberator.echoerr('This page is not pixiv.'); return false; } if(contents.URL.search(/medium&illust_id=/i)==-1){ liberator.echoerr("This page is not pixiv's image page."); return false; } let Cc=Components.classes; let Ci=Components.interfaces; let id; if(-1==contents.URL.search(/\&from_sid=/i)){ id=contents.URL.substr(contents.URL.lastIndexOf('=')+1); }else{ let st=contents.URL.search(/illust_id=/i)+'illust_id='.length; let end=contents.URL.lastIndexOf('&'); id=contents.URL.substr(st,end-st); } let baseInfo; 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="; scroll=''; }else if(-1!=type.search(/manga&illust_id=/i)){ baseInfo="http://www.pixiv.net/member_illust.php?mode=manga&illust_id="; 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() { 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 saveDirectory=directoryPicker(); if(saveDirectory.length<1) return; 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(0license>GPL</license> <minVersion>1.2</minVersion> <maxVersion>2.1</maxVersion> <updateURL>https://github.com/vimpr/vimperator-plugins/raw/master/amazon_simple_uri.js</updateURL> <detail><![CDATA[ == Option == >|| let g:amazon_asamashi = "hogehoge-22" ||< と設定することによりAmazon アソシエイトID(上の例ではhogehoge-22)をURLに追加します ]]></detail> </VimperatorPlugin>; //}}} // (function() { // URLを正規表現でチェックしてISBNっぽい10桁,13桁の数字と取り出す function getIsbn(uri) { var regex = new RegExp("([0-9]{9,13}[0-9Xx])"); var match = uri.match(regex); var isbn = match[0]; if (isbn.length == 13) { isbn = getIsbn10(isbn); } return isbn; } // SSBのAPIを使ってISBNから書籍情報を取得 function getBookInfo(isbn) { var uri = "http://stack.nayutaya.jp/api/book/"; if (isbn.length == 10) { uri += "isbn10/" + isbn + ".json"; } else if (isbn.length == 13) { uri += "isbn13/" + isbn + ".json"; } var xhr = new XMLHttpRequest(); xhr.open('GET', uri, false); xhr.send(null); if (xhr.status != 200) { liberator.echoerr('false'); return; } return window.eval('(' + xhr.responseText + ')'); } //SSBのAPIから書籍情報を取り、そこからISBN10を取得 function getIsbn10(isbn13) { var info = getBookInfo(isbn13); return info.response.book.isbn10; } commands.addUserCommand( ['amazoncopy','asc'], 'Copy Amazon Short URI', function(args) { var asin = window.content.document.getElementById('ASIN'); // ASINが取得できなかった場合 / Amazon以外の書籍情報ページから取得する場合 if (asin == null) { asin = getIsbn(buffer.URL); } else { asin = asin.value } var uri = "http://www.amazon.co.jp/dp/" + asin + "/"; var asamashi = typeof liberator.globalVariables.amazon_asamashi == "undefined" ? '' : liberator.globalVariables.amazon_asamashi; if (args == "+a") { uri += asamashi; } util.copyToClipboard(uri); liberator.echo("[ASC] Copy to clipboard."); } ); })();