// 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 need libDLImage.js under of plugin/modules.

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(/illust_id=/i)==-1)|| (contents.URL.search(/mode=medium/i)==-1)){ liberator.echoerr("This page is not pixiv's image page."); return false; } const Cc=Components.classes; const Ci=Components.interfaces; let createWorker=function(fileName){ let ret; const resourceName="vimp-plugin"; const ioService=Cc["@mozilla.org/network/io-service;1"] .getService(Ci.nsIIOService); const resProt=ioService.getProtocolHandler("resource") .QueryInterface(Ci.nsIResProtocolHandler); let pluginDirs=io.getRuntimeDirectories("plugin"); if (pluginDirs.length === 0){ return null; } resProt.setSubstitution(resourceName,ioService.newFileURI(pluginDirs[0])); try { worker=new ChromeWorker("resource://"+resourceName+"/modules/"+fileName); }catch(e){ return null; } return worker; }; let worker=createWorker('libDLImage.js'); if(worker==null){ liberator.echoerr('plugin directory is not found'); return false; } worker.addEventListener('message',function(event){ if(event.data.status=='error'){ liberator.echoerr(event.data.message); return false; }; let instream=event.data.message; let savePath=event.data.savePath; 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(); } },false); worker.addEventListener('error',function(event){ liberator.echoerr(event.data.status); },false); let id; let idTmp=contents.URL.match(/illust_id=(\d+)/i); if(idTmp===null){ liberator.echoerr("This page is not image page and not manga page."); return false; }else{ id=idTmp[1]; } 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(); if(result==Ci.nsIFilePicker.returnOK){ return fp.file; } return null; }; let saveDirectory=directoryPicker(); if(saveDirectory==null) return false; 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 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336