Ovu skriptu ne treba izravno instalirati. To je biblioteka za druge skripte koje se uključuju u meta direktivu // @require https://update.sleazyfork.org/scripts/23945/152159/pxercorejs.js
'use strict';
window.afterLoad=function(fn){if(document.readyState!=='loading'){setTimeout(fn)}else{document.addEventListener('DOMContentLoaded',fn)}};window.setDefalut=function(obj,key,val){if(key in obj)return false;obj[key]=val;return true};Object.copy=function(target){var obj={};for(let key in target){var opd=Object.getOwnPropertyDescriptor(target,key);if(opd&&(!opd.writable||!opd.configurable||!opd.enumerable||opd.get||opd.set)){Object.defineProperty(obj,key,opd)}else{obj[key]=target[key]}};return obj};Promise.prototype['finally']=function(callback){return this.then(value=>Promise.resolve(callback()).then(()=>value),reason=>Promise.resolve(callback()).then(()=>{throw reason}))};XMLHttpRequest.prototype['refererSend']=function(url){var originUrl=document.URL;history.replaceState({},null,url);this.send();history.replaceState({},null,originUrl)};HTMLDocument.prototype['blinkTitle']=function(addMsg,spaceMsg){var addMsg=addMsg||'[完成] ';var spaceMsg=spaceMsg||'[ ] ';var timer=setInterval(()=>{if(this.title.indexOf(addMsg)!==-1){this.title=this.title.replace(addMsg,spaceMsg)}else if(this.title.indexOf(spaceMsg)!==-1){this.title=this.title.replace(spaceMsg,addMsg)}else{this.title=addMsg+this.title}},300);this.addOneEventListener('mousemove',()=>{clearInterval(timer);this.title=this.title.replace(spaceMsg,"").replace(addMsg,"")})};EventTarget.prototype['addOneEventListener']=function(type,listener,useCapture){var fn;this.addEventListener(type,listener,useCapture);this.addEventListener(type,fn=()=>{this.removeEventListener(type,listener,useCapture);this.removeEventListener(type,fn,useCapture);fn=null},useCapture)};~function(originAdd,originRemove){var map=new Map();EventTarget.prototype.addEventListener=function(type,listener,useCapture){let eltMap=map.get(this);if(eltMap===undefined)map.set(this,eltMap={});if(eltMap[type]===undefined)eltMap[type]=[];eltMap[type].push({listener,useCapture});return originAdd.apply(this,arguments)};EventTarget.prototype.removeEventListener=function(type,listener,useCapture){if(listener!=='*'&&type!=='*'){return originRemove.apply(this,arguments)};let eltMap=map.get(this);if(type==='*'){for(let hasType in eltMap){this.removeEventListener(hasType,'*',useCapture)};return};if(eltMap[type]===undefined)return;for(let{listener:l,useCapture:u}of eltMap[type]){originRemove.bind(this)(type,l,u)}}}(EventTarget.prototype.addEventListener,EventTarget.prototype.removeEventListener);['push','pop','shift','unshift','splice','sort','reverse'].forEach(function(method){var original=Array.prototype[method];Array.prototype[method]=function(){var result=original.apply(this,arguments);if(typeof this['Hook:change']==='function')this['Hook:change']();return result}});[DocumentFragment,HTMLDocument,Element].forEach(constructor=>{constructor.prototype.querySelectorList=function(...selector){var result;for(let i=0;i<selector.length;i++){result=this.querySelector(selector[i]);if(result!==null)return result}}});'use strict';class PxerRequest{constructor({url,html}){this.url=url;this.html=html}}class PxerPageRequest extends PxerRequest{constructor(...argn){super(...argn)}}class PxerWorksRequest extends PxerRequest{constructor({url,html,type,isMultiple,id}){super({url,html});this.type=type;this.isMultiple=isMultiple;this.id=id}}class PxerWorks{constructor({id,type,date,server,tagList,viewCount,ratedCount,scoreCount,fileFormat}){this.id=id;this.type=type;this.date=date;this.server=server;this.tagList=tagList;this.viewCount=viewCount;this.ratedCount=ratedCount;this.scoreCount=scoreCount;this.fileFormat=fileFormat}}class PxerMultipleWorks extends PxerWorks{constructor(data){super(data);this.multiple=data.multiple}};class PxerUgoiraWorks extends PxerWorks{constructor(data){super(data);this.fileFormat='zip';this.frames=data.frames}};'use strict';class PxerEvent{constructor(eventList=[]){this.eventList=eventList;this._event={};this._oneEvent={};return new Proxy(this,{get(target,property){if(property in target){return target[property]};let inEvent=target.eventList.some(item=>property&&(item===property));if(inEvent){return target.dispatch.bind(target,property)}},})}};PxerEvent.prototype.on=function(type,listener){if(!(this._checkEventType(type)&&this._checkListener(listener)))return false;this._event[type]||(this._event[type]=[]);this._event[type].push(listener);return true};PxerEvent.prototype.one=function(type,listener){if(!(this._checkEventType(type)&&this._checkListener(listener)))return false;this._oneEvent[type]||(this._oneEvent[type]=[]);this._oneEvent[type].push(listener);return true};PxerEvent.prototype.off=function(type,listener){if(!((type==='*'||this._checkEventType(type))&&(typeof listener==='undefined'||this._checkListener(listener))))return false;if(type==='*'){this._event={};this._oneEvent={};return true};if(typeof listener==='undefined'){delete this._event[type];delete this._oneEvent[type];return true};let index1=this._event[type].lastIndexOf(listener);if(index1!==-1){this._event[type].splice(index1,1)};let index2=this._oneEvent[type].lastIndexOf(listener);if(index2!==-1){this._oneEvent[type].splice(index2,1)};return true};PxerEvent.prototype.dispatch=function(type,data){if(!this._checkEventType(type))return false;if(Array.isArray(this._event[type])&&this._event[type].length!==0){this._event[type].forEach(function(item){item.call(this,data)},this)};if(Array.isArray(this._oneEvent[type])&&this._oneEvent[type].length!==0){this._oneEvent[type].forEach(function(item){item.call(this,data)},this);delete this._oneEvent[type]};return true};PxerEvent.prototype._checkEventType=function(type){let inEvent=this.eventList.some(item=>type&&(item===type));if(!inEvent){console.warn(`PxerEvent:"${type}"is not in eventList[${this.eventList}]`);return false};return true};PxerEvent.prototype._checkListener=function(listener){if(typeof listener!=='function'){console.warn(`PxerEvent:"${listener}"is not a function`);return false};return true};'use strict';class PxerPrint{constructor(){this.works;this.runtime={passWorks:[],address:[],ugoira_frames:{},taskInfo:'',};this.config={"manga_single":"max","manga_medium":"max","illust_single":"max","illust_medium":"max","ugoira_zip":"no","ugoira_frames":"no","task_inf":"yes",};this.filter={"score":0,"avg":0,"yes_and_tag":[],"yes_or_tag":[],"no_and_tag":[],"no_or_tag":[],"tagExp":null,"callback":null,}}};PxerPrint.getUgoira=function(works,{ugoira_zip}){const tpl={"max":"http://#server#.pixiv.net/img-zip-ugoira/img/#date#/#id#_ugoira1920x1080.zip","600p":"http://#server#.pixiv.net/img-zip-ugoira/img/#date#/#id#_ugoira600x600.zip",};var address=tpl[ugoira_zip];if(!address)return[];for(let key in works){address=address.replace(`#${key}#`,works[key])};return[address]};PxerPrint.getMultiple=function(works,{manga_medium,illust_medium}){const tpl={"max":"http://#server#.pixiv.net/img-original/img/#date#/#id#_p#index#.#fileFormat#","1200p":"http://#server#.pixiv.net/c/1200x1200/img-master/img/#date#/#id#_p#index#_master1200.jpg","cover_600p":"http://#server#.pixiv.net/c/600x600/img-master/img/#date#/#id#_p0_master1200.jpg",};var address=works.type==='manga'?tpl[manga_medium]:tpl[illust_medium];if(!address)return[];for(let key in works){address=address.replace(`#${key}#`,works[key])};var addressList=[];for(let i=0;i<works.multiple;i++){addressList.push(address.replace('#index#',i))};return addressList};PxerPrint.getWorks=function(works,{illust_single,manga_single}){const tpl={"max":"http://#server#.pixiv.net/img-original/img/#date#/#id#_p0.#fileFormat#","600p":"http://#server#.pixiv.net/c/600x600/img-master/img/#date#/#id#_p0_master1200.jpg",};var address=works.type==='manga'?tpl[manga_single]:tpl[illust_single];if(!address)return[];for(let key in works){address=address.replace(`#${key}#`,works[key])}return[address]};PxerPrint.prototype.queryPrint=function(){this.filterWorks().countAddress().getTaskInfo().print()};PxerPrint.prototype.print=function(){if(this.config['ugoira_frames']==="yes"){let win=window.open(document.URL,'_blank');win.document.write("/*! 这个页面是动图压缩包的动画参数,目前pxer还无法将动图压缩包打包成GIF,请寻找其他第三方软件 */\n<br /><br />");let frames=JSON.stringify(this.runtime.ugoira_frames,null,4);win.document.write("<pre>\n"+frames+"\n</pre>")};let win=window.open(document.URL,'_blank');win.document.write(this.runtime.taskInfo.replace(/\n/g,'<br />'));win.document.write(this.runtime.address.join("<br />"))};PxerPrint.prototype.getTaskInfo=function(){this.runtime.textHead||(this.runtime.textHead='');var[manga,ugoira,illust,unknow,multiple,single,works,address]=new Array(20).fill(0);for(let works of this.runtime.passWorks){switch(works.type){case'manga':manga++;break;case'ugoira':ugoira++;break;case'illust':illust++;break;default:unknow++;break};if(works instanceof PxerMultipleWorks){multiple++}else if(works instanceof PxerWorks){single++}};address=this.runtime.address.length;works=this.runtime.passWorks.length;this.runtime.taskInfo=`\
共计${works}个作品,${address}个下载地址。
其中有${illust}幅插画、${manga}幅漫画、${ugoira}幅动图。
单张图片作品有${multiple}个,多张图片的作品有${single}个。
`;return this};PxerPrint.prototype.countAddress=function(){this.runtime.address=[];for(let works of this.runtime.passWorks){switch(true){case works instanceof PxerUgoiraWorks:this.runtime.ugoira_frames[works.id]=works.frames;this.runtime.address.push(...PxerPrint.getUgoira(works,this.config));break;case works instanceof PxerMultipleWorks:this.runtime.address.push(...PxerPrint.getMultiple(works,this.config));break;case works instanceof PxerWorks:this.runtime.address.push(...PxerPrint.getWorks(works,this.config));break}};return this};PxerPrint.prototype.filterWorks=function(){this.runtime.passWorks=[];let isEmpty=function(filter){for(let key in filter){if(filter[key])return false};return true}(this.filter);if(isEmpty){this.runtime.passWorks=this.works;return this}for(let works of this.works){if(!(this.filter.score==0||isNaN(this.filter.score)||works.scoreCount>=this.filter.score))continue;if(!(this.filter['yes_and_tag'].length===0||this.filter['yes_and_tag'].every(tag=>works.tagList.indexOf(tag)!=-1)))continue;if(!(this.filter['yes_or_tag'].length===0||!this.filter['yes_or_tag'].some(tag=>works.tagList.indexOf(tag)!=-1)))continue;if(!(this.filter['no_and_tag'].length===0||!this.filter['no_and_tag'].every(tag=>works.tagList.indexOf(tag)==-1)))continue;if(!(this.filter['no_or_tag'].length===0||!this.filter['no_or_tag'].some(tag=>works.tagList.indexOf(tag)==-1)))continue;this.runtime.passWorks.push(works)};return this};'use strict';class PxerHtmlParser{constructor(config){this.config=config;this.task=null}};PxerHtmlParser.prototype['parseAll']=function(requests){var result=[];for(let request of requests){result.push(...this.parse(request))};return result};PxerHtmlParser.prototype['parse']=function(request){if(request instanceof PxerWorksRequest){this.task=request;return[this.parseWorks()]}else if(request instanceof PxerPageRequest){this.task=request;return this.parsePage()}else{return false}};PxerHtmlParser.prototype['parseWorks']=function(){var pw;for(let url in this.task.html){let data={task:this.task,dom:(new DOMParser()).parseFromString(this.task.html[url],'text/html'),url:url,pw:pw,};switch(true){case/mode=medium/.test(url):pw=PxerHtmlParser.parseMediumHtml(data);break;case/mode=big/.test(url):case/mode=manga_big/.test(url):pw=PxerHtmlParser.parseMangaBigHtml(data);break;case/mode=manga&/.test(url):pw=PxerHtmlParser.parseMangaHtml(data);break;default:console.warn(`Count not parse"${url}"`);};};return pw;};PxerHtmlParser.prototype['parsePage']=function(){var dom=(new DOMParser()).parseFromString(this.task.html,'text/html');var elts=dom.querySelectorAll('a.work._work');var taskList=[];for(let elt of elts){let task=new PxerWorksRequest({html:{},type:elt.matches('.ugoku-illust')?'ugoira':elt.matches(".manga")?'manga':"illust",isMultiple:elt.matches(".multiple"),id:elt.getAttribute('href').match(/illust_id=(\d+)/)[1]});task.url=getUrlList(task);taskList.push(task);};return taskList;function getUrlList(task,singleMangaMode){if(task.type==="ugoira"||(task.type==="illust"&&!task.isMultiple)){return["/member_illust.php?mode=medium&illust_id="+task.id];}else if(task.isMultiple){return["/member_illust.php?mode=medium&illust_id="+task.id,"/member_illust.php?mode=manga&illust_id="+task.id,"/member_illust.php?mode=manga_big&page=0&illust_id="+task.id];}else if(task.type==="manga"&&!task.isMultiple){return["http://www.pixiv.net/member_illust.php?mode=medium&illust_id="+task.id,"http://www.pixiv.net/member_illust.php?mode=big&illust_id="+task.id,];}else{console.warn('miss task '+task.id);return[];};};};PxerHtmlParser.parseMangaHtml=function({task,dom,url,pw}){var rePw=new PxerMultipleWorks(pw);rePw.multiple=+dom.querySelectorList(".page .total",".position .total").innerHTML;return rePw;};PxerHtmlParser.parseMangaBigHtml=function({task,dom,url,pw}){var rePw=new PxerMultipleWorks(pw);var src=dom.getElementsByTagName('img')[0].src;Object.assign(rePw,{server:src.match(/(i\d+)\.pixiv\.net/)[1],date:src.match(PxerHtmlParser.REGEXP['getDate'])[1],fileFormat:src.match(/\.(jpg|gif|png)$/)[1],});return rePw;};PxerHtmlParser.parseMediumHtml=function({task,dom,url,pw}){var rePw=new PxerWorks({id:task.id,type:task.type,tagList:[...dom.querySelectorAll(".tag a.text")].map(elt=>elt.innerHTML),viewCount:+dom.querySelector(".view-count").innerHTML,ratedCount:+dom.querySelector(".rated-count").innerHTML,scoreCount:+dom.querySelector(".score-count").innerHTML,fileFormat:'jpg',});if(task.type==='ugoira'){let script=[...dom.querySelectorAll("script")].filter(tag=>/zip/.test(tag.innerHTML))[0].innerHTML;let exp=/"src":"([^"<>]*?600x600\.zip)"[^<>]*?"frames":(\[.*?\])/mi;let arr=script.match(exp);rePw=new PxerUgoiraWorks(Object.assign(rePw,{server:arr[1].replace(/\\\//g,'\/').match(/(i\d+)\.pixiv\.net/)[1],date:arr[1].replace(/\\\//g,'\/').match(PxerHtmlParser.REGEXP['getDate'])[1],frames:JSON.parse(arr[2]),}));};if(task.type==='illust'&&!task.isMultiple){let src=dom.querySelector(".ui-modal-close-box img.original-image").getAttribute("data-src");Object.assign(rePw,{server:src.match(/(i\d+)\.pixiv\.net/)[1],date:src.match(PxerHtmlParser.REGEXP['getDate'])[1],fileFormat:src.match(/\.(jpg|gif|png)$/)[1],});}if(task.type==='manga'&&!task.isMultiple){let src=dom.querySelector("a._work.manga img").src;Object.assign(rePw,{server:src.match(/(i\d+)\.pixiv\.net/)[1],date:src.match(PxerHtmlParser.REGEXP['getDate'])[1],});}return rePw;};PxerHtmlParser.getMangaPath=function(pwr){var pw=PxerHtmlParser.parseMediumHtml({task:pwr,dom:(new DOMParser()).parseFromString(pwr.html[pwr.url[0]],'text/html'),url:pwr.url[0],pw:{},});pw.fileFormat='';return PxerPrint.getWorks(pw,{manga_single:'max'})[0];};PxerHtmlParser.REGEXP={'getDate':/img\/((?:\d+\/){5}\d+)/,};'use strict';class PxerThread extends PxerEvent{constructor({id,config,task}){super(['load','error','fail']);this.id=id;this.isFree=true;this.task=task;this.config=config||{timeout:5000,retry:3};this.runtime={};this.xhr=new XMLHttpRequest();this.xhr.timeout=this.config.timeout;this.xhr.responseType='text';};};PxerThread.checkRequest=function(url,html){if(!html)return'empty';if(html.indexOf("_no-item _error")!==-1){if(html.indexOf("sprites-r-18g-badge")!==-1)return'r-18g';if(html.indexOf("sprites-r-18-badge")!==-1)return'r-18';};if(html.indexOf("sprites-mypixiv-badge")!==-1)return'mypixiv';return true;};PxerThread.prototype['stop']=function(){this.xhr.abort();};PxerThread.prototype['init']=function(task){if(task)this.task=task;this.runtime={};this.isFree=false;if(this.task instanceof PxerWorksRequest){this.runtime.urlList=this.task.url.slice();}else if(this.task instanceof PxerPageRequest){this.runtime.urlList=[this.task.url];}else{console.error(`PxerThread:"${this.task}"is not PxerRequest`);return false;};};PxerThread.prototype['run']=function(){var prms=Promise.resolve();var thread=this;var xhr=this.xhr;xhr.removeEventListener('*');this.runtime.urlList.forEach((url)=>{prms=prms.then(()=>{return new Promise((resolve,reject)=>{var sendAjax=function(){xhr.addOneEventListener("timeout",function(){setDefalut(thread.runtime,"retry",0);if((+thread.config.retry!==0)&&(++thread.runtime.retry>=thread.config.retry)){reject({type:"timeout",url,xhr,});}else{sendAjax();};});if(thread.task.type==='manga'&&thread.task.isMultiple===false&&/mode=big/.test(url)){var referer;for(let url of thread.task.url){if(/mode=medium/.test(url)){referer=url;break;}};xhr.open('GET',url,true);xhr.refererSend(referer);}else{xhr.open('GET',url,true);xhr.send();};};xhr.addOneEventListener("load",function(){if(/^2/.test(xhr.status)||xhr.status===304){var msg=PxerThread.checkRequest(url,xhr.responseText);if(msg!==true){reject({type:msg,url,xhr,});return;};if(thread.task instanceof PxerWorksRequest){resolve(Object.assign(thread.task.html=Object(thread.task.html),{[url]:xhr.responseText}));}else{resolve(thread.task.html=xhr.responseText);};}else{reject({type:"http:"+xhr.status,url,xhr,});};});xhr.addOneEventListener("error",function(){reject({type:"error",url,xhr,});});sendAjax();});});});prms.finally(()=>{thread.isFree=true;}).then(()=>{thread.dispatch("load",thread.task);}).catch(function({type,url,xhr}){switch(type){case'error':console.error(`PxerThread#${thread.id}error!`);thread.dispatch("error",{task:thread.task,msg:type});break;case'empty':case'r-18g':case'r-18':case'mypixiv':console.warn(`Request check return ${type}form PxerThread#${thread.id}@${url}`);break;case'timeout':console.warn(`Request timeout form PxerThread#${thread.id}@${url}`);break;default:console.error(`PxerThread#${thread.id}error!`);thread.dispatch("error",{task:thread.task,msg:'unknown'});};thread.dispatch("fail",{task:thread.task,msg:type});});return true;};'use strict';class PxerThreadManager extends PxerEvent{constructor(config){super(['load','error','fail']);this.config=config||{timeout:5000,retry:3,thread:8,};this.taskList=[];this.resultSet=[];this.runtime={};this.threads=[];};};PxerThreadManager.prototype['stop']=function(){for(let thread of this.threads){thread.off('*');thread.stop();};};PxerThreadManager.prototype['init']=function(taskList){if(taskList)this.taskList=taskList.slice();this.resultSet=[];this.runtime={};this.threads=[];for(let i=0;i<this.config.thread;i++){this.threads.push(new PxerThread({id:i,config:{timeout:this.config.timeout,retry:this.config.retry,},task:null,}));};return this;};PxerThreadManager.prototype['run']=function(){this.threads.forEach(thread=>{let task=this.taskList.shift();if(!task)return;thread.on('load',data=>{this.resultSet.push(data);var task=this.taskList.shift();if(task){thread.init(task);setTimeout(thread.run.bind(thread));}else if(this.threads.every(thread=>thread.isFree)){this.dispatch('load',this.resultSet);};});thread.init(task);thread.on('fail',()=>{var task=this.taskList.shift();if(task){thread.init(task);setTimeout(thread.run.bind(thread));}else if(this.threads.every(thread=>thread.isFree)){this.dispatch('load',this.resultSet);};});thread.on('fail',this.dispatch.bind(this,"fail"));thread.on('error',this.dispatch.bind(this,"error"));setTimeout(thread.run.bind(thread));});};'use strict';class PxerApp extends PxerEvent{constructor(){super(['executeWroksTask','executePageTask','finishWorksTask','finishPageTask','error','stop',]);this.runtime={"pageType":'',"illust_number":0,"failList":[],};this.resultSet=[];this.taskList=[];this.pp=new PxerPrint();this.printConfig=this.pp.config;this.printFilter=this.pp.filter;this.ptm=new PxerThreadManager();this.threadManagerConfig=this.ptm.config;this.php=new PxerHtmlParser();this.ptm.on("error",({task})=>console.error(task));this.ptm.on("fail",({task})=>console.warn(task));this.ptm.on("fail",({task,msg})=>{setDefalut(this.runtime,'failList',[]);this.runtime.failList.push({task,msg});});this.on('error',err=>console.error(err));};};PxerApp.version='6.1.2';PxerApp.prototype["stop"]=function(){this.ptm.stop();this.dispatch('finishWorksTask');this.dispatch('stop');};PxerApp.prototype["autoSwitch"]=function(){this.one('finishPageTask',()=>{this.taskList=this.php.parseAll(this.resultSet);this.resultSet=[];this.executeWroksTask();});this.one('finishWorksTask',()=>{this.pp.works=this.php.parseAll(this.resultSet);this.taskList=[];});};PxerApp.prototype["queryExecute"]=function(){this.autoSwitch();this.one('finishWorksTask',()=>{this.pp.queryPrint();});this.executePageTask();};PxerApp.prototype["executePageTask"]=function(){if(this.taskList.length===0){this.dispatch('error','Could not find request!');return false;};if(!this.taskList.every(request=>request instanceof PxerPageRequest)){this.dispatch('error','Task list is not every instance PxerPageRequest');return false;};this.dispatch('executePageTask');this.ptm.one('load',(data)=>{setDefalut(this,'resultSet',[]);this.resultSet.push(...data);setTimeout(this.dispatch.bind(this,'finishPageTask'));});this.ptm.init(this.taskList);this.ptm.run();return true;};PxerApp.prototype["executeWroksTask"]=function(){if(this.taskList.length===0){this.dispatch('error','Could not find request!');return false;};if(!this.taskList.every(request=>request instanceof PxerWorksRequest)){this.dispatch('error','Task list is not every instance PxerWorksRequest');return false;};this.dispatch('executeWroksTask');this.ptm.one('load',(data)=>{setDefalut(this,'resultSet',[]);this.resultSet.push(...data);setTimeout(this.dispatch.bind(this,'finishWorksTask'));});this.ptm.init(this.taskList);this.ptm.run();return true;};PxerApp.prototype["analyzePage"]=function(){switch(this.runtime.pageType){case"member_illust":case"search":case"bookmark":this.runtime.illust_number=parseInt(document.querySelector(".count-badge").innerHTML);var separator=/\?/.test(document.URL)?"&":"?";for(var i=0;i<Math.ceil(this.runtime.illust_number/20);i++){this.taskList.push(new PxerPageRequest({url:document.URL+separator+"p="+(i+1),}));};break;default:return false;};return true;};PxerApp.prototype["getPageType"]=function(){var typeAnalyzer={"member":function(url){return/member\.php/.test(url);},"member_illust":function(url){return/member_illust\.php/.test(url);},"search":function(url){return/search\.php/.test(url);},"bookmark":function(url){return/bookmark\.php/.test(url);},"illust_medium":function(url){return/member_illust\.php/.test(url)&&/illust_id/.test(url);}};for(var key in typeAnalyzer){if(typeAnalyzer[key](document.URL)){return this.runtime.pageType=key;}}return false;};'use strict';~function(){if(/\.php(\?.+)?$/.test(pxerDefinePxerConfig['TEMPLATE_URL'])){pxerDefinePxerConfig['TEMPLATE_URL']=pxerDefinePxerConfig['TEMPLATE_URL'].replace(/\.php(\?.+)?$/,'.js$1');};var tpl=document.createElement('script');tpl.src=pxerDefinePxerConfig['URL_ROOT']+pxerDefinePxerConfig['TEMPLATE_URL']+"?"+(new Date()).getTime();;tpl.addEventListener('load',function(){var parentNote=document.getElementById('page-mypage')||document.getElementById('wrapper')||document.getElementById('contents')||document.body;var pxerTpl=(new DOMParser()).parseFromString(pxerDefinePxerConfig['PXER_TPL'],'text/html').body;parentNote.insertBefore(pxerTpl,parentNote.firstChild);var pu=new PxerUI(document.getElementById('pxer'));afterLoad(pu.init.bind(pu));window.pu=pu;});document.head.appendChild(tpl);}();class PxerUI{constructor(elt){this.elt=elt;this.pxer=new PxerApp();this.button=[];this.window=[];this.runtime={runtime:0,state:'wait',taskRuntime:0,taskTimer:null,};this.timer=setInterval(()=>{this.runtime.runtime||(this.runtime.runtime=0);this.runtime.runtime++;},1000);};};PxerUI.prototype['constMap']={version:PxerApp.version};PxerUI.prototype['init']=function(){this.button=[...this.elt.querySelectorAll('[pxer-button]')];this.button.forEach((item,index,array)=>array[item.getAttribute('pxer-button')]=item);this.window=[...this.elt.querySelectorAll('[pxer-window]')];this.window.forEach((item,index,array)=>array[item.getAttribute('pxer-window')]=item);[...this.elt.querySelectorAll('[pxer-const]')].forEach(item=>item.innerHTML=this.constMap[item.getAttribute('pxer-const')]);if(this.pxer.getPageType()===false&&pxerDefinePxerConfig['DEBUG']!==true){this.button.run.disabled=true;console.warn('getPageType return false');return false;}else{this.button.run.disabled=false;this.button.run.innerHTML='<span class="glyphicon glyphicon-play"></span>';};this.pxer.autoSwitch();this.pxer.on('finishWorksTask',()=>clearInterval(this.timer));(()=>{var originRetry=this.pxer.ptm.config.retry;this.pxer.on('executePageTask',()=>this.pxer.ptm.config.retry=0);this.pxer.on('finishPageTask',()=>this.pxer.ptm.config.retry=originRetry);})();this.pxer.on('finishWorksTask',()=>this.window.print.style.display='');this.pxer.on('finishWorksTask',()=>this.window.inf.style.display='none');this.button.run.addEventListener('click',()=>{if(this.button.run.classList.contains('btn-success')){this.button.run.classList.remove('btn-success');this.button.run.classList.add('btn-info');this.button.run.innerHTML='<span class="glyphicon glyphicon-ok"></span>';this.window.inf.style.display='';}else if(this.button.run.classList.contains('btn-info')){this.button.run.classList.remove('btn-info');this.button.run.classList.add('btn-danger');this.button.run.innerHTML='<span class="glyphicon glyphicon-remove"></span>';}else if(this.button.run.classList.contains('btn-danger')){this.button.run.style.display='none';this.button.run.classList.remove('btn-danger');this.button.run.classList.add('btn-success');this.button.run.innerHTML='<span class="glyphicon glyphicon-play"></span>';};});this.pxer.on('executePageTask',()=>this.runtime.state='getPageTask');this.pxer.on('executeWroksTask',()=>this.runtime.state='getWorks');this.pxer.on('finishWorksTask',()=>this.runtime.state='finish');this.pxer.on('finishWorksTask',()=>this.button.run.style.display='none');this.pxer.on('error',()=>this.runtime.state='error');this.pxer.on('stop',()=>this.runtime.state='stop');this.pxer.on('finishWorksTask',()=>document.blinkTitle());this.pxer.on('executePageTask',()=>{this.runtime.taskTimer=setInterval(()=>{this.runtime.taskRuntime++;},500);});this.pxer.on('executeWroksTask',()=>{this.runtime.taskRuntime=0;});this.pxer.on('finishWorksTask',()=>{clearInterval(this.runtime.taskTimer);});[...this.elt.querySelectorAll('[pxer-bind]')].forEach(item=>this.signBind(item,item.getAttribute('pxer-bind')));[...this.elt.querySelectorAll('[pxer-config]')].forEach(item=>this.signConfig(item,item.getAttribute('pxer-config')));this.button.run.addOneEventListener('click',()=>{this.pxer.analyzePage();this.button.run.addOneEventListener('click',()=>{this.pxer.executePageTask();this.button.run.addOneEventListener('click',()=>{if(this.runtime.state==='getPageTask'||this.runtime.state==='getWorks')this.pxer.stop();});});});this.button.echo.addEventListener('click',()=>this.pxer.pp.queryPrint());this.button.count.addEventListener('click',()=>{this.window.taskInfo.style.display='';this.pxer.pp.filterWorks().countAddress().getTaskInfo();});this.button.warn.addEventListener('click',()=>{this.window.warn.classList.toggle('show-block');});this.button.selectAllfw.addEventListener('click',()=>{var elt=this.button.selectAllfw.parentNode;while(elt.tagName.toLowerCase()!=='table'){elt=elt.parentNode;};[...elt.querySelectorAll('[name="again_works"]')].forEach(elt=>elt.checked=true);});this.button.again.addEventListener('click',()=>{var againIds=[...document.querySelectorAll('[name="again_works"]:checked')].map(elt=>elt.value);if(againIds.length===0)return;setDefalut(this.pxer,'taskList',[]);this.pxer.runtime.failList=this.pxer.runtime.failList.filter(({task})=>{if(againIds.some(id=>id==task.id)){this.pxer.taskList.push(task);return false;}else{return true;};});if(this.pxer.runtime.failList.length===0)this.window.warn.classList.remove('show-block');this.readyAgain();});};PxerUI.prototype['readyAgain']=function(){if(this.runtime.readyAgain)return;this.runtime.readyAgain=true;this.pxer.one('finishWorksTask',()=>this.pxer.taskList=[]);this.pxer.one('finishWorksTask',()=>this.runtime.readyAgain=false);this.pxer.one('finishWorksTask',()=>this.runtime.failList=[]);this.button.run.classList.contains('btn-danger')&&this.button.run.click();this.button.run.style.display='';this.button.run.addOneEventListener('click',()=>{this.button.run.addOneEventListener('click',()=>{this.pxer.executeWroksTask();this.button.run.addOneEventListener('click',()=>{if(this.runtime.state==='getPageTask'||this.runtime.state==='getWorks')this.pxer.stop();});});});this.pxer.on('finishWorksTask',()=>{this.pxer.pp.works.push(...this.pxer.php.parseAll(this.pxer.ptm.resultSet));this.pxer.ptm.resultSet=[];});};PxerUI.prototype['signBind']=function(elt,key){var bindMap=this.bindMap(key);if(bindMap===undefined)return console.warn(`Count not find field"${key}"in PxerUI::bindMap`);if(bindMap.object[bindMap.propertyName]instanceof Array){let oldOpd=Object.getOwnPropertyDescriptor(bindMap.object,bindMap.propertyName)||{value:[],writable:true,enumerable:true,configurable:true,};let newOpd=Object.assign(Object.copy(oldOpd),{set(newValue){if(newValue instanceof Array){if('Hook:change'in newValue){var originHook=newValue['Hook:change'];newValue['Hook:change']=function(){bindMap.update(elt,newValue);originHook.bind(newValue)();};}else{Object.defineProperty(newValue,'Hook:change',{value:function(){bindMap.update(elt,newValue);},enumerable:false,configurable:true,writable:true,});};};bindMap.update(elt,newValue);if(typeof oldOpd.set==='function'){oldOpd.set(newValue);}else{oldOpd.value=newValue;};},get(){if(typeof oldOpd.get==='function'){return oldOpd.get();}else{return oldOpd.value;};},});delete newOpd.value;delete newOpd.writable;Object.defineProperty(bindMap.object,bindMap.propertyName,newOpd);bindMap.object[bindMap.propertyName]=bindMap.object[bindMap.propertyName];return true;};var oldOpd=Object.getOwnPropertyDescriptor(bindMap.object,bindMap.propertyName)||{value:undefined,writable:true,enumerable:true,configurable:true,};var newOpd=Object.assign(Object.copy(oldOpd),{set(newValue){if(typeof oldOpd.set==='function'){oldOpd.set(newValue);}else{oldOpd.value=newValue;};if(bindMap.update){bindMap.update(elt,newValue);}else{elt.innerHTML=newValue;};},get(){if(typeof oldOpd.get==='function'){return oldOpd.get();}else{return oldOpd.value;};},});delete newOpd.value;delete newOpd.writable;Object.defineProperty(bindMap.object,bindMap.propertyName,newOpd);bindMap.object[bindMap.propertyName]=bindMap.object[bindMap.propertyName];};PxerUI.prototype['bindMap']=function(key){var obj={record:{object:this.runtime,propertyName:'runtime',update(elt,time){var second=time%60;var minute=~~(time/60);if(second<10)second='0'+second;elt.innerHTML=`${minute}:${second}`;},},pageType:{object:this.pxer.runtime,propertyName:'pageType',update(elt,value){var pt='';switch(value){case'member':pt='个人资料页';break;case'member_illust':pt='个人作品页';break;case'search':pt='搜索页';break;case'bookmark':pt='收藏页';break;case'medium':pt='作品详情查看';break;default:pt='未知';};elt.innerHTML=pt;},},worksNum:{object:this.pxer.runtime,propertyName:'illust_number',},pret:{object:this.pxer,propertyName:'taskList',update(elt,arr){elt.innerHTML=arr.length},},finish:{object:this.pxer.ptm,propertyName:'resultSet',update(elt,arr){elt.innerHTML=arr.length},},forecast:{object:this.runtime,propertyName:'taskRuntime',update:(elt,value)=>{var time=~~((0.5*value)/this.pxer.ptm.resultSet.length*this.pxer.ptm.taskList.length);isNaN(time)&&(time=0);var second=time%60;var minute=~~(time/60);if(second<10)second='0'+second;elt.innerHTML=`${minute}:${second}`;},},failTaskLength:{object:this.pxer.runtime,propertyName:'failList',update(elt,arr){if(arr&&arr.length){elt.innerHTML=arr.length;};}},hasFailTask:{object:this.pxer.runtime,propertyName:'failList',update(elt,arr){if(arr&&arr.length){elt.style.display='';}else{elt.style.display='none';};}},failList:{object:this.pxer.runtime,propertyName:'failList',update(elt,arr){var signMap={timeout:'重试',mypixiv:'申请画师好友获得查看权限',empty:'重试或手动保存',error:'重试或手动保存,并报告给花生',unknown:'重试或手动保存,并报告给花生','r-18':'在用户设置中设置显示R-18作品','r-18g':'在用户设置中设置显示R-18G作品',};var html='';for(let{task,msg}of arr){html+=`<tr><td><a href="http://www.pixiv.net/member_illust.php?mode=medium&illust_id=${task.id}">${task.id}</a></td><td>${msg}</td><td>${signMap[msg]||signMap['unknown']}</td><td class="text-center"><input type="checkbox"name="again_works"value="${task.id}"/></td></tr>`;};elt.innerHTML=html;}},taskInfo:{object:this.pxer.pp.runtime,propertyName:'taskInfo',},state:{object:this.runtime,propertyName:'state',update(elt,value){var pt='';switch(value){case'wait':pt='待命中';break;case'getPageTask':pt='获取作品信息中';break;case'getWorks':pt='爬取作品中';break;case'finish':pt='已完成';break;case'error':pt='出现错误';break;case'stop':pt='手动停止';break;default:pt='未知';};elt.innerHTML=pt;},},};return obj[key];};PxerUI.prototype['signConfig']=function(elt,key){var configMap=this.configMap(key);if(configMap===undefined)return console.warn(`Count not find field"${key}"in PxerUI::configMap`);if(typeof configMap.toValue==='function'){elt.value=configMap.toValue(configMap.object[configMap.propertyName]);}else{elt.value=configMap.object[configMap.propertyName];};let eventType=elt.tagName==='SELECT'?'change':'input';elt.addEventListener(eventType,()=>{if(typeof configMap.toConfig==='function'){configMap.object[configMap.propertyName]=configMap.toConfig(elt.value);}else{configMap.object[configMap.propertyName]=elt.value;};})};PxerUI.prototype['configMap']=function(key){var obj={thread:{object:this.pxer.ptm.config,propertyName:'thread',},timeout:{object:this.pxer.ptm.config,propertyName:'timeout',},maxRetry:{object:this.pxer.ptm.config,propertyName:'retry',},score:{object:this.pxer.printFilter,propertyName:'score',},avg:{object:this.pxer.printFilter,propertyName:'avg',},yes_and_tag:{object:this.pxer.printFilter,propertyName:'yes_and_tag',toConfig:value=>value.trim().split(' '),toValue:config=>config.join(' '),},yes_or_tag:{object:this.pxer.printFilter,propertyName:'yes_or_tag',toConfig:value=>value.trim().split(' '),toValue:config=>config.join(' '),},no_and_tag:{object:this.pxer.printFilter,propertyName:'no_and_tag',toConfig:value=>value.trim().split(' '),toValue:config=>config.join(' '),},no_or_tag:{object:this.pxer.printFilter,propertyName:'no_or_tag',toConfig:value=>value.trim().split(' '),toValue:config=>config.join(' '),},illust_single:{object:this.pxer.printConfig,propertyName:'illust_single',},illust_medium:{object:this.pxer.printConfig,propertyName:'illust_medium',},manga_single:{object:this.pxer.printConfig,propertyName:'manga_single',},manga_medium:{object:this.pxer.printConfig,propertyName:'manga_medium',},ugoira:{object:this.pxer.printConfig,propertyName:'ugoira_zip',toConfig:value=>{var arr=value.split('-');this.pxer.printConfig['ugoira_frames']=arr[1];return arr[0];},toValue:config=>`${config}-${this.pxer.printConfig['ugoira_frames']}`,},};return obj[key]};