// ==UserScript== // @name 知乎下载器 // @namespace http://howardzhangdqs.eu.org/ // @source https://github.com/Howardzhangdqs/zhihu-copy-as-markdown // @version 0.3.26-4e0824 // @description 一键复制知乎文章/回答为Markdown,下载文章/回答为zip(包含素材图片与文章/回答信息),备份你珍贵的回答与文章。 // @author HowardZhangdqs // @match *://www.zhihu.com/* // @match *://zhuanlan.zhihu.com/* // @license MIT // @icon https://static.zhihu.com/heifetz/favicon.ico // @grant none // @downloadURL https://update.greasyfork.icu/scripts/478608/%E7%9F%A5%E4%B9%8E%E4%B8%8B%E8%BD%BD%E5%99%A8.user.js // @updateURL https://update.greasyfork.icu/scripts/478608/%E7%9F%A5%E4%B9%8E%E4%B8%8B%E8%BD%BD%E5%99%A8.meta.js // ==/UserScript== /** 更新日志 * 23.10.30: 脚本开写 * * 23.10.31: * feat: 解析、渲染表格 * feat: 解析、渲染链接 * fix: 加了一个被忘掉的break,但是我忘了是哪忘了加了 * fix: 修复编辑框会被加上`复制为Markdown`的按钮 * doc: 给types加了完整的注释 * doc: 给Lexer和Parser函数添加完整的注释 * chore: 更改触发方式 * feat: 链接解析为直达链接 * feat: 下载内容为zip * feat: 下载的zip中包含内容信息(`info.txt`) * fix: 修复回答详情里图片无法下载 * fix: 首页按钮无法正常加载 * * 23.11.1: * feat: `info.txt`加入作者信息 * chore: `info.txt`更名为`info.json` * fix: 主页中`info.json > url`字段获取错误 * chore: `info.json`中`url`字段改为`link` * fix: 主页文章作者信息获取错误 * chore: 发布在Github上 * fix: 无素材内容下来的zip中没有`index.md` * * 23.11.3: * feat: 解析想法 * feat: 解析、渲染、下载视频(回答/文章中的视频) * * 23.11.4: * fix: 按钮无法正常加载 * fix: 想法在未展开时就被解析 * fix: 修复部分内容同时出现一堆下载按钮以及不出现下载按钮的问题 * fix: 修复行内代码无法正确被解析的问题 * * 23.11.5: * feat: 解析Gif * chore: 更方便的测试 * * 23.12.5: * feat: 单独成段的内联公式升级为行间公式 [来源](https://zhuanlan.zhihu.com/p/665008681#comment-10744866371) * fix: 表格换行符解析错误 * * 24.1.19: * feat: 回答批量下载 [Issue](https://github.com/Howardzhangdqs/zhihu-copy-as-markdown/issues/1) * * 24.3.22: * fix: 修复部分回答无法下载的问题 [Issue](https://github.com/Howardzhangdqs/zhihu-copy-as-markdown/issues/2) * fix: 修改批量下载中问题描述文件夹名称为“问题描述” [Issue](https://github.com/Howardzhangdqs/zhihu-copy-as-markdown/issues/2#issuecomment-2014496716) */ (()=>{var e={434:function(e,t,r){var n;void 0!==(t="function"==typeof(n=function(){"use strict";function t(e,t,r){var n=new XMLHttpRequest;n.open("GET",e),n.responseType="blob",n.onload=function(){o(n.response,t,r)},n.onerror=function(){console.error("could not download file")},n.send()}function n(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch(e){}return 200<=t.status&&299>=t.status}function i(e){try{e.dispatchEvent(new MouseEvent("click"))}catch(r){var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var a="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof r.g&&r.g.global===r.g?r.g:void 0,s=a.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),o=a.saveAs||("object"!=typeof window||window!==a?function(){}:"download"in HTMLAnchorElement.prototype&&!s?function(e,r,s){var o=a.URL||a.webkitURL,l=document.createElement("a");r=r||e.name||"download",l.download=r,l.rel="noopener","string"==typeof e?(l.href=e,l.origin===location.origin?i(l):n(l.href)?t(e,r,s):i(l,l.target="_blank")):(l.href=o.createObjectURL(e),setTimeout((function(){o.revokeObjectURL(l.href)}),4e4),setTimeout((function(){i(l)}),0))}:"msSaveOrOpenBlob"in navigator?function(e,r,a){if(r=r||e.name||"download","string"!=typeof e)navigator.msSaveOrOpenBlob(function(e,t){return void 0===t?t={autoBom:!1}:"object"!=typeof t&&(console.warn("Deprecated: Expected third argument to be a object"),t={autoBom:!t}),t.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\ufeff",e],{type:e.type}):e}(e,a),r);else if(n(e))t(e,r,a);else{var s=document.createElement("a");s.href=e,s.target="_blank",setTimeout((function(){i(s)}))}}:function(e,r,n,i){if((i=i||open("","_blank"))&&(i.document.title=i.document.body.innerText="downloading..."),"string"==typeof e)return t(e,r,n);var o="application/octet-stream"===e.type,l=/constructor/i.test(a.HTMLElement)||a.safari,u=/CriOS\/[\d]+/.test(navigator.userAgent);if((u||o&&l||s)&&"undefined"!=typeof FileReader){var h=new FileReader;h.onloadend=function(){var e=h.result;e=u?e:e.replace(/^data:[^;]*;/,"data:attachment/file;"),i?i.location.href=e:location=e,i=null},h.readAsDataURL(e)}else{var c=a.URL||a.webkitURL,d=c.createObjectURL(e);i?i.location=d:location.href=d,i=null,setTimeout((function(){c.revokeObjectURL(d)}),4e4)}});a.saveAs=o.saveAs=o,e.exports=o})?n.apply(t,[]):n)&&(e.exports=t)},905:(e,t,r)=>{e.exports=function e(t,r,n){function i(s,o){if(!r[s]){if(!t[s]){if(a)return a(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}l=r[s]={exports:{}},t[s][0].call(l.exports,(function(e){return i(t[s][1][e]||e)}),l,l.exports,e,t,r,n)}return r[s].exports}for(var a=void 0,s=0;s>4,o=1>6:64,l=2>2)+a.charAt(s)+a.charAt(o)+a.charAt(l));return u.join("")},r.decode=function(e){var t,r,n,s,o,l=0,u=0;if("data:"===e.substr(0,5))throw new Error("Invalid base64 input, it looks like a data url.");var h,c=3*(e=e.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(e.charAt(e.length-1)===a.charAt(64)&&c--,e.charAt(e.length-2)===a.charAt(64)&&c--,c%1!=0)throw new Error("Invalid base64 input, bad content length.");for(h=new(i.uint8array?Uint8Array:Array)(0|c);l>4,r=(15&s)<<4|(s=a.indexOf(e.charAt(l++)))>>2,n=(3&s)<<6|(o=a.indexOf(e.charAt(l++))),h[u++]=t,64!==s&&(h[u++]=r),64!==o&&(h[u++]=n);return h}},{"./support":30,"./utils":32}],2:[function(e,t,r){"use strict";var n=e("./external"),i=e("./stream/DataWorker"),a=e("./stream/Crc32Probe"),s=e("./stream/DataLengthProbe");function o(e,t,r,n,i){this.compressedSize=e,this.uncompressedSize=t,this.crc32=r,this.compression=n,this.compressedContent=i}o.prototype={getContentWorker:function(){var e=new i(n.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new s("data_length")),t=this;return e.on("end",(function(){if(this.streamInfo.data_length!==t.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")})),e},getCompressedWorker:function(){return new i(n.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},o.createWorkerFrom=function(e,t,r){return e.pipe(new a).pipe(new s("uncompressedSize")).pipe(t.compressWorker(r)).pipe(new s("compressedSize")).withStreamInfo("compression",t)},t.exports=o},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,t,r){"use strict";var n=e("./stream/GenericWorker");r.STORE={magic:"\0\0",compressWorker:function(){return new n("STORE compression")},uncompressWorker:function(){return new n("STORE decompression")}},r.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,t,r){"use strict";var n=e("./utils"),i=function(){for(var e=[],t=0;t<256;t++){for(var r=t,n=0;n<8;n++)r=1&r?3988292384^r>>>1:r>>>1;e[t]=r}return e}();t.exports=function(e,t){return void 0!==e&&e.length?("string"!==n.getTypeOf(e)?function(e,t,r){var n=i,a=0+r;e^=-1;for(var s=0;s>>8^n[255&(e^t[s])];return-1^e}:function(e,t,r){var n=i,a=0+r;e^=-1;for(var s=0;s>>8^n[255&(e^t.charCodeAt(s))];return-1^e})(0|t,e,e.length):0}},{"./utils":32}],5:[function(e,t,r){"use strict";r.base64=!1,r.binary=!1,r.dir=!1,r.createFolders=!0,r.date=null,r.compression=null,r.compressionOptions=null,r.comment=null,r.unixPermissions=null,r.dosPermissions=null},{}],6:[function(e,t,r){"use strict";e="undefined"!=typeof Promise?Promise:e("lie"),t.exports={Promise:e}},{lie:37}],7:[function(e,t,r){"use strict";var n="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,i=e("pako"),a=e("./utils"),s=e("./stream/GenericWorker"),o=n?"uint8array":"array";function l(e,t){s.call(this,"FlateWorker/"+e),this._pako=null,this._pakoAction=e,this._pakoOptions=t,this.meta={}}r.magic="\b\0",a.inherits(l,s),l.prototype.processChunk=function(e){this.meta=e.meta,null===this._pako&&this._createPako(),this._pako.push(a.transformTo(o,e.data),!1)},l.prototype.flush=function(){s.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},l.prototype.cleanUp=function(){s.prototype.cleanUp.call(this),this._pako=null},l.prototype._createPako=function(){this._pako=new i[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var e=this;this._pako.onData=function(t){e.push({data:t,meta:e.meta})}},r.compressWorker=function(e){return new l("Deflate",e)},r.uncompressWorker=function(){return new l("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,t,r){"use strict";function n(e,t){for(var r="",n=0;n>>=8;return r}function i(e,t,r,i,s,h){var c=e.file,d=e.compression,f=h!==o.utf8encode,p=a.transformTo("string",h(c.name)),m=a.transformTo("string",o.utf8encode(c.name)),_=c.comment,g=(h=a.transformTo("string",h(_)),a.transformTo("string",o.utf8encode(_))),y=m.length!==c.name.length,b=(_=g.length!==_.length,""),v=c.dir,w=c.date,k={crc32:0,compressedSize:0,uncompressedSize:0};return t&&!r||(k.crc32=e.crc32,k.compressedSize=e.compressedSize,k.uncompressedSize=e.uncompressedSize),r=0,t&&(r|=8),f||!y&&!_||(r|=2048),e=0,t=0,v&&(e|=16),"UNIX"===s?(t=798,e|=(65535&((f=c.unixPermissions)?f:v?16893:33204))<<16):(t=20,e|=63&(c.dosPermissions||0)),s=w.getUTCHours(),s=(s=((s<<=6)|w.getUTCMinutes())<<5)|w.getUTCSeconds()/2,f=w.getUTCFullYear()-1980,f=(f=((f<<=4)|w.getUTCMonth()+1)<<5)|w.getUTCDate(),y&&(v=n(1,1)+n(l(p),4)+m,b+="up"+n(v.length,2)+v),_&&(c=n(1,1)+n(l(h),4)+g,b+="uc"+n(c.length,2)+c),w="",w=(w=(w=(w=(w=(w=(w=(w=(w=(w+="\n\0")+n(r,2))+d.magic)+n(s,2))+n(f,2))+n(k.crc32,4))+n(k.compressedSize,4))+n(k.uncompressedSize,4))+n(p.length,2))+n(b.length,2),{fileRecord:u.LOCAL_FILE_HEADER+w+p+b,dirRecord:u.CENTRAL_FILE_HEADER+n(t,2)+w+n(h.length,2)+"\0\0\0\0"+n(e,4)+n(i,4)+p+b+h}}var a=e("../utils"),s=e("../stream/GenericWorker"),o=e("../utf8"),l=e("../crc32"),u=e("../signature");function h(e,t,r,n){s.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=t,this.zipPlatform=r,this.encodeFileName=n,this.streamFiles=e,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(h,s),h.prototype.push=function(e){var t=e.meta.percent||0,r=this.entriesCount,n=this._sources.length;this.accumulate?this.contentBuffer.push(e):(this.bytesWritten+=e.data.length,s.prototype.push.call(this,{data:e.data,meta:{currentFile:this.currentFile,percent:r?(t+100*(r-n-1))/r:100}}))},h.prototype.openedSource=function(e){this.currentSourceOffset=this.bytesWritten,this.currentFile=e.file.name;var t=this.streamFiles&&!e.file.dir;t?(e=i(e,t,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName),this.push({data:e.fileRecord,meta:{percent:0}})):this.accumulate=!0},h.prototype.closedSource=function(e){this.accumulate=!1;var t=this.streamFiles&&!e.file.dir,r=i(e,t,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(r.dirRecord),t)this.push({data:(t=e,u.DATA_DESCRIPTOR+n(t.crc32,4)+n(t.compressedSize,4)+n(t.uncompressedSize,4)),meta:{percent:100}});else for(this.push({data:r.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},h.prototype.flush=function(){for(var e=this.bytesWritten,t=0;t=this.index;t--)r=(r<<8)+this.byteAt(t);return this.index+=e,r},readString:function(e){return n.transformTo("string",this.readData(e))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var e=this.readInt(4);return new Date(Date.UTC(1980+(e>>25&127),(e>>21&15)-1,e>>16&31,e>>11&31,e>>5&63,(31&e)<<1))}},t.exports=i},{"../utils":32}],19:[function(e,t,r){"use strict";var n=e("./Uint8ArrayReader");function i(e){n.call(this,e)}e("../utils").inherits(i,n),i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,t,r){"use strict";var n=e("./DataReader");function i(e){n.call(this,e)}e("../utils").inherits(i,n),i.prototype.byteAt=function(e){return this.data.charCodeAt(this.zero+e)},i.prototype.lastIndexOfSignature=function(e){return this.data.lastIndexOf(e)-this.zero},i.prototype.readAndCheckSignature=function(e){return e===this.readData(4)},i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./DataReader":18}],21:[function(e,t,r){"use strict";var n=e("./ArrayReader");function i(e){n.call(this,e)}e("../utils").inherits(i,n),i.prototype.readData=function(e){var t;return this.checkOffset(e),0===e?new Uint8Array(0):(t=this.data.subarray(this.zero+this.index,this.zero+this.index+e),this.index+=e,t)},t.exports=i},{"../utils":32,"./ArrayReader":17}],22:[function(e,t,r){"use strict";var n=e("../utils"),i=e("../support"),a=e("./ArrayReader"),s=e("./StringReader"),o=e("./NodeBufferReader"),l=e("./Uint8ArrayReader");t.exports=function(e){var t=n.getTypeOf(e);return n.checkSupport(t),"string"!==t||i.uint8array?"nodebuffer"===t?new o(e):i.uint8array?new l(n.transformTo("uint8array",e)):new a(n.transformTo("array",e)):new s(e)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,t,r){"use strict";r.LOCAL_FILE_HEADER="PK",r.CENTRAL_FILE_HEADER="PK",r.CENTRAL_DIRECTORY_END="PK",r.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",r.ZIP64_CENTRAL_DIRECTORY_END="PK",r.DATA_DESCRIPTOR="PK\b"},{}],24:[function(e,t,r){"use strict";var n=e("./GenericWorker"),i=e("../utils");function a(e){n.call(this,"ConvertWorker to "+e),this.destType=e}i.inherits(a,n),a.prototype.processChunk=function(e){this.push({data:i.transformTo(this.destType,e.data),meta:e.meta})},t.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(e,t,r){"use strict";var n=e("./GenericWorker"),i=e("../crc32");function a(){n.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}e("../utils").inherits(a,n),a.prototype.processChunk=function(e){this.streamInfo.crc32=i(e.data,this.streamInfo.crc32||0),this.push(e)},t.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,t,r){"use strict";var n=e("../utils"),i=e("./GenericWorker");function a(e){i.call(this,"DataLengthProbe for "+e),this.propName=e,this.withStreamInfo(e,0)}n.inherits(a,i),a.prototype.processChunk=function(e){var t;e&&(t=this.streamInfo[this.propName]||0,this.streamInfo[this.propName]=t+e.data.length),i.prototype.processChunk.call(this,e)},t.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(e,t,r){"use strict";var n=e("../utils"),i=e("./GenericWorker");function a(e){i.call(this,"DataWorker");var t=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,e.then((function(e){t.dataIsReady=!0,t.data=e,t.max=e&&e.length||0,t.type=n.getTypeOf(e),t.isPaused||t._tickAndRepeat()}),(function(e){t.error(e)}))}n.inherits(a,i),a.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,n.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished)||(n.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0)},a.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var e=null,t=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":e=this.data.substring(this.index,t);break;case"uint8array":e=this.data.subarray(this.index,t);break;case"array":case"nodebuffer":e=this.data.slice(this.index,t)}return this.index=t,this.push({data:e,meta:{percent:this.max?this.index/this.max*100:0}})},t.exports=a},{"../utils":32,"./GenericWorker":28}],28:[function(e,t,r){"use strict";function n(e){this.name=e||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}n.prototype={push:function(e){this.emit("data",e)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(e){this.emit("error",e)}return!0},error:function(e){return!this.isFinished&&(this.isPaused?this.generatedError=e:(this.isFinished=!0,this.emit("error",e),this.previous&&this.previous.error(e),this.cleanUp()),!0)},on:function(e,t){return this._listeners[e].push(t),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(e,t){if(this._listeners[e])for(var r=0;r "+e:e}},t.exports=n},{}],29:[function(e,t,r){"use strict";var n=e("../utils"),i=e("./ConvertWorker"),a=e("./GenericWorker"),s=e("../base64"),o=e("../support"),l=e("../external"),u=null;if(o.nodestream)try{u=e("../nodejs/NodejsStreamOutputAdapter")}catch(e){}function h(e,t,r){var s=t;switch(t){case"blob":case"arraybuffer":s="uint8array";break;case"base64":s="string"}try{this._internalType=s,this._outputType=t,this._mimeType=r,n.checkSupport(s),this._worker=e.pipe(new i(s)),e.lock()}catch(e){this._worker=new a("error"),this._worker.error(e)}}h.prototype={accumulate:function(e){return t=this,r=e,new l.Promise((function(e,i){var a=[],o=t._internalType,l=t._outputType,u=t._mimeType;t.on("data",(function(e,t){a.push(e),r&&r(t)})).on("error",(function(e){a=[],i(e)})).on("end",(function(){try{var t=function(e,t,r){switch(e){case"blob":return n.newBlob(n.transformTo("arraybuffer",t),r);case"base64":return s.encode(t);default:return n.transformTo(e,t)}}(l,function(e,t){for(var r=0,n=null,i=0,a=0;a>>6:(r<65536?t[s++]=224|r>>>12:(t[s++]=240|r>>>18,t[s++]=128|r>>>12&63),t[s++]=128|r>>>6&63),t[s++]=128|63&r);return t},r.utf8decode=function(e){if(i.nodebuffer)return n.transformTo("nodebuffer",e).toString("utf-8");for(var t,r,a,s=e=n.transformTo(i.uint8array?"uint8array":"array",e),l=s.length,u=new Array(2*l),h=t=0;h>10&1023,u[t++]=56320|1023&r)}return u.length!==t&&(u.subarray?u=u.subarray(0,t):u.length=t),n.applyFromCharCode(u)},n.inherits(u,s),u.prototype.processChunk=function(e){var t=n.transformTo(i.uint8array?"uint8array":"array",e.data),a=(this.leftOver&&this.leftOver.length&&(i.uint8array?(a=t,(t=new Uint8Array(a.length+this.leftOver.length)).set(this.leftOver,0),t.set(a,this.leftOver.length)):t=this.leftOver.concat(t),this.leftOver=null),function(e,t){for(var r=(t=(t=t||e.length)>e.length?e.length:t)-1;0<=r&&128==(192&e[r]);)r--;return!(r<0)&&0!==r&&r+o[e[r]]>t?r:t}(t)),s=t;a!==t.length&&(i.uint8array?(s=t.subarray(0,a),this.leftOver=t.subarray(a,t.length)):(s=t.slice(0,a),this.leftOver=t.slice(a,t.length))),this.push({data:r.utf8decode(s),meta:e.meta})},u.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:r.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},r.Utf8DecodeWorker=u,n.inherits(h,s),h.prototype.processChunk=function(e){this.push({data:r.utf8encode(e.data),meta:e.meta})},r.Utf8EncodeWorker=h},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,t,r){"use strict";var n=e("./support"),i=e("./base64"),a=e("./nodejsUtils"),s=e("./external");function o(e){return e}function l(e,t){for(var r=0;r>8;this.dir=!!(16&this.externalFileAttributes),0==e&&(this.dosPermissions=63&this.externalFileAttributes),3==e&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(){var e;this.extraFields[1]&&(e=n(this.extraFields[1].value),this.uncompressedSize===i.MAX_VALUE_32BITS&&(this.uncompressedSize=e.readInt(8)),this.compressedSize===i.MAX_VALUE_32BITS&&(this.compressedSize=e.readInt(8)),this.localHeaderOffset===i.MAX_VALUE_32BITS&&(this.localHeaderOffset=e.readInt(8)),this.diskNumberStart===i.MAX_VALUE_32BITS)&&(this.diskNumberStart=e.readInt(4))},readExtraFields:function(e){var t,r,n,i=e.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});e.index+4>>6:(r<65536?t[a++]=224|r>>>12:(t[a++]=240|r>>>18,t[a++]=128|r>>>12&63),t[a++]=128|r>>>6&63),t[a++]=128|63&r);return t},r.buf2binstring=function(e){return l(e,e.length)},r.binstring2buf=function(e){for(var t=new n.Buf8(e.length),r=0,i=t.length;r>10&1023,o[r++]=56320|1023&n)}return l(o,r)},r.utf8border=function(e,t){for(var r=(t=(t=t||e.length)>e.length?e.length:t)-1;0<=r&&128==(192&e[r]);)r--;return!(r<0)&&0!==r&&r+s[e[r]]>t?r:t}},{"./common":41}],43:[function(e,t,r){"use strict";t.exports=function(e,t,r,n){for(var i=65535&e|0,a=e>>>16&65535|0,s=0;0!==r;){for(r-=s=2e3>>1:r>>>1;e[t]=r}return e}();t.exports=function(e,t,r,i){var a=n,s=i+r;e^=-1;for(var o=i;o>>8^a[255&(e^t[o])];return-1^e}},{}],46:[function(e,t,r){"use strict";var n,i=e("../utils/common"),a=e("./trees"),s=e("./adler32"),o=e("./crc32"),l=e("./messages"),u=0,h=0,c=-2,d=2,f=8,p=286,m=30,_=19,g=2*p+1,y=15,b=3,v=258,w=v+b+1,k=42,x=113;function S(e,t){return e.msg=l[t],t}function z(e){return(e<<1)-(4e.avail_out?e.avail_out:r)&&(i.arraySet(e.output,t.pending_buf,t.pending_out,r,e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending)&&(t.pending_out=0)}function C(e,t){a._tr_flush_block(e,0<=e.block_start?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,E(e.strm)}function I(e,t){e.pending_buf[e.pending++]=t}function T(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function O(e,t){var r,n,i=e.max_chain_length,a=e.strstart,s=e.prev_length,o=e.nice_match,l=e.strstart>e.w_size-w?e.strstart-(e.w_size-w):0,u=e.window,h=e.w_mask,c=e.prev,d=e.strstart+v,f=u[a+s-1],p=u[a+s];e.prev_length>=e.good_match&&(i>>=2),o>e.lookahead&&(o=e.lookahead);do{if(u[(r=t)+s]===p&&u[r+s-1]===f&&u[r]===u[a]&&u[++r]===u[a+1]){for(a+=2,r++;u[++a]===u[++r]&&u[++a]===u[++r]&&u[++a]===u[++r]&&u[++a]===u[++r]&&u[++a]===u[++r]&&u[++a]===u[++r]&&u[++a]===u[++r]&&u[++a]===u[++r]&&al&&0!=--i);return s<=e.lookahead?s:e.lookahead}function R(e){var t,r,n,a,l,u,h,c,d,f=e.w_size;do{if(c=e.window_size-e.lookahead-e.strstart,e.strstart>=f+(f-w)){for(i.arraySet(e.window,e.window,f,f,0),e.match_start-=f,e.strstart-=f,e.block_start-=f,t=r=e.hash_size;n=e.head[--t],e.head[t]=f<=n?n-f:0,--r;);for(t=r=f;n=e.prev[--t],e.prev[t]=f<=n?n-f:0,--r;);c+=f}if(0===e.strm.avail_in)break;if(l=e.strm,u=e.window,h=e.strstart+e.lookahead,d=void 0,r=0===(d=c<(d=l.avail_in)?c:d)?0:(l.avail_in-=d,i.arraySet(u,l.input,l.next_in,d,h),1===l.state.wrap?l.adler=s(l.adler,u,d,h):2===l.state.wrap&&(l.adler=o(l.adler,u,d,h)),l.next_in+=d,l.total_in+=d,d),e.lookahead+=r,e.lookahead+e.insert>=b)for(a=e.strstart-e.insert,e.ins_h=e.window[a],e.ins_h=(e.ins_h<=b&&(e.ins_h=(e.ins_h<=b)if(n=a._tr_tally(e,e.strstart-e.match_start,e.match_length-b),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=b){for(e.match_length--;e.strstart++,e.ins_h=(e.ins_h<=b&&(e.ins_h=(e.ins_h<=b&&e.match_length<=e.prev_length){for(i=e.strstart+e.lookahead-b,n=a._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-b),e.lookahead-=e.prev_length-1,e.prev_length-=2;++e.strstart<=i&&(e.ins_h=(e.ins_h<e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(R(e),0===e.lookahead&&t===u)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+r;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,C(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-w&&(C(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(C(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(C(e,!1),e.strm.avail_out),1)})),new D(4,4,8,4,B),new D(4,5,16,8,B),new D(4,6,32,32,B),new D(4,4,16,16,L),new D(8,16,32,32,L),new D(8,16,128,128,L),new D(8,32,128,256,L),new D(32,128,258,1024,L),new D(32,258,258,4096,L)],r.deflateInit=function(e,t){return P(e,t,f,15,8,0)},r.deflateInit2=P,r.deflateReset=U,r.deflateResetKeep=N,r.deflateSetHeader=function(e,t){return e&&e.state&&2===e.state.wrap?(e.state.gzhead=t,h):c},r.deflate=function(e,t){var r,i,s,l;if(!e||!e.state||5>8&255),I(i,i.gzhead.time>>16&255),I(i,i.gzhead.time>>24&255),I(i,9===i.level?2:2<=i.strategy||i.level<2?4:0),I(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(I(i,255&i.gzhead.extra.length),I(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=o(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(I(i,0),I(i,0),I(i,0),I(i,0),I(i,0),I(i,9===i.level?2:2<=i.strategy||i.level<2?4:0),I(i,3),i.status=x)):(d=f+(i.w_bits-8<<4)<<8,d|=(2<=i.strategy||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(d|=32),d+=31-d%31,i.status=x,T(i,d),0!==i.strstart&&(T(i,e.adler>>>16),T(i,65535&e.adler)),e.adler=1)),69===i.status)if(i.gzhead.extra){for(s=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>s&&(e.adler=o(e.adler,i.pending_buf,i.pending-s,s)),E(e),s=i.pending,i.pending!==i.pending_buf_size));)I(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>s&&(e.adler=o(e.adler,i.pending_buf,i.pending-s,s)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){s=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>s&&(e.adler=o(e.adler,i.pending_buf,i.pending-s,s)),E(e),s=i.pending,i.pending===i.pending_buf_size)){l=1;break}}while(l=i.gzindexs&&(e.adler=o(e.adler,i.pending_buf,i.pending-s,s)),0===l&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){s=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>s&&(e.adler=o(e.adler,i.pending_buf,i.pending-s,s)),E(e),s=i.pending,i.pending===i.pending_buf_size)){l=1;break}}while(l=i.gzindexs&&(e.adler=o(e.adler,i.pending_buf,i.pending-s,s)),0===l&&(i.status=103)}else i.status=103;if(103===i.status&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&E(e),i.pending+2<=i.pending_buf_size&&(I(i,255&e.adler),I(i,e.adler>>8&255),e.adler=0,i.status=x)):i.status=x),0!==i.pending){if(E(e),0===e.avail_out)return i.last_flush=-1,h}else if(0===e.avail_in&&z(t)<=z(r)&&4!==t)return S(e,-5);if(666===i.status&&0!==e.avail_in)return S(e,-5);if(0!==e.avail_in||0!==i.lookahead||t!==u&&666!==i.status){var d=2===i.strategy?function(e,t){for(var r;;){if(0===e.lookahead&&(R(e),0===e.lookahead)){if(t===u)return 1;break}if(e.match_length=0,r=a._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(C(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(C(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(C(e,!1),0===e.strm.avail_out)?1:2}(i,t):3===i.strategy?function(e,t){for(var r,n,i,s,o=e.window;;){if(e.lookahead<=v){if(R(e),e.lookahead<=v&&t===u)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=b&&0e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=b?(r=a._tr_tally(e,1,e.match_length-b),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=a._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(C(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(C(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(C(e,!1),0===e.strm.avail_out)?1:2}(i,t):n[i.level].func(i,t);if(3!==d&&4!==d||(i.status=666),1===d||3===d)return 0===e.avail_out&&(i.last_flush=-1),h;if(2===d&&(1===t?a._tr_align(i):5!==t&&(a._tr_stored_block(i,0,0,!1),3===t)&&(A(i.head),0===i.lookahead)&&(i.strstart=0,i.block_start=0,i.insert=0),E(e),0===e.avail_out))return i.last_flush=-1,h}return 4===t&&(i.wrap<=0||(2===i.wrap?(I(i,255&e.adler),I(i,e.adler>>8&255),I(i,e.adler>>16&255),I(i,e.adler>>24&255),I(i,255&e.total_in),I(i,e.total_in>>8&255),I(i,e.total_in>>16&255),I(i,e.total_in>>24&255)):(T(i,e.adler>>>16),T(i,65535&e.adler)),E(e),0=r.w_size&&(0===o&&(A(r.head),r.strstart=0,r.block_start=0,r.insert=0),d=new i.Buf8(r.w_size),i.arraySet(d,t,f-r.w_size,r.w_size,0),t=d,f=r.w_size),d=e.avail_in,l=e.next_in,u=e.input,e.avail_in=f,e.next_in=0,e.input=t,R(r);r.lookahead>=b;){for(n=r.strstart,a=r.lookahead-(b-1);r.ins_h=(r.ins_h<>>=n=r>>>24,k-=n,0==(n=r>>>16&255))f[d++]=65535&r;else{if(!(16&n)){if(0==(64&n)){r=x[(65535&r)+(w&(1<>>=n,k-=n),k<15&&(w+=h[u++]<>>=n=r>>>24,k-=n,!(16&(n=r>>>16&255))){if(0==(64&n)){r=S[(65535&r)+(w&(1<>>=n,k-=n,(n=d-p)>3,w&=(1<<(k-=i<<3))-1,e.next_in=u,e.next_out=d,e.avail_in=u>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function p(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new n.Buf16(320),this.work=new n.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function m(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=h,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new n.Buf32(c),t.distcode=t.distdyn=new n.Buf32(d),t.sane=1,t.back=-1,l):u}function _(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,m(e)):u}function g(e,t){var r,n;return!e||!e.state||(n=e.state,t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15=e.wsize?(n.arraySet(e.window,t,r-e.wsize,e.wsize,0),e.wnext=0,e.whave=e.wsize):(i<(a=e.wsize-e.wnext)&&(a=i),n.arraySet(e.window,t,r-i,a,e.wnext),(i-=a)?(n.arraySet(e.window,t,r-i,i,0),e.wnext=i,e.whave=e.wsize):(e.wnext+=a,e.wnext===e.wsize&&(e.wnext=0),e.whave>>8&255,r.check=a(r.check,j,2,0),x=y=0,r.mode=2;else if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&y)<<8)+(y>>8))%31)e.msg="incorrect header check",r.mode=30;else if(8!=(15&y))e.msg="unknown compression method",r.mode=30;else{if(x-=4,D=8+(15&(y>>>=4)),0===r.wbits)r.wbits=D;else if(D>r.wbits){e.msg="invalid window size",r.mode=30;break}r.dmax=1<>8&1),512&r.flags&&(j[0]=255&y,j[1]=y>>>8&255,r.check=a(r.check,j,2,0)),x=y=0,r.mode=3;case 3:for(;x<32;){if(0===_)break e;_--,y+=c[p++]<>>8&255,j[2]=y>>>16&255,j[3]=y>>>24&255,r.check=a(r.check,j,4,0)),x=y=0,r.mode=4;case 4:for(;x<16;){if(0===_)break e;_--,y+=c[p++]<>8),512&r.flags&&(j[0]=255&y,j[1]=y>>>8&255,r.check=a(r.check,j,2,0)),x=y=0,r.mode=5;case 5:if(1024&r.flags){for(;x<16;){if(0===_)break e;_--,y+=c[p++]<>>8&255,r.check=a(r.check,j,2,0)),x=y=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&((A=_<(A=r.length)?_:A)&&(r.head&&(D=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),n.arraySet(r.head.extra,c,p,A,D)),512&r.flags&&(r.check=a(r.check,c,A,p)),_-=A,p+=A,r.length-=A),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===_)break e;for(A=0;D=c[p+A++],r.head&&D&&r.length<65536&&(r.head.name+=String.fromCharCode(D)),D&&A<_;);if(512&r.flags&&(r.check=a(r.check,c,A,p)),_-=A,p+=A,D)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&r.flags){if(0===_)break e;for(A=0;D=c[p+A++],r.head&&D&&r.length<65536&&(r.head.comment+=String.fromCharCode(D)),D&&A<_;);if(512&r.flags&&(r.check=a(r.check,c,A,p)),_-=A,p+=A,D)break e}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&r.flags){for(;x<16;){if(0===_)break e;_--,y+=c[p++]<>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=12;break;case 10:for(;x<32;){if(0===_)break e;_--,y+=c[p++]<>>=7&x,x-=7&x,r.mode=27;else{for(;x<3;){if(0===_)break e;_--,y+=c[p++]<>>=1)){case 0:r.mode=14;break;case 1:Z=W=void 0;var Z,W=r;if(w){for(b=new n.Buf32(512),v=new n.Buf32(32),Z=0;Z<144;)W.lens[Z++]=8;for(;Z<256;)W.lens[Z++]=9;for(;Z<280;)W.lens[Z++]=7;for(;Z<288;)W.lens[Z++]=8;for(o(1,W.lens,0,288,b,0,W.work,{bits:9}),Z=0;Z<32;)W.lens[Z++]=5;o(2,W.lens,0,32,v,0,W.work,{bits:5}),w=!1}if(W.lencode=b,W.lenbits=9,W.distcode=v,W.distbits=5,r.mode=20,6!==t)break;y>>>=2,x-=2;break e;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=30}y>>>=2,x-=2}break;case 14:for(y>>>=7&x,x-=7&x;x<32;){if(0===_)break e;_--,y+=c[p++]<>>16^65535)){e.msg="invalid stored block lengths",r.mode=30;break}if(r.length=65535&y,x=y=0,r.mode=15,6===t)break e;case 15:r.mode=16;case 16:if(A=r.length){if(0===(A=g<(A=_>>=5,x-=5,r.ndist=1+(31&y),y>>>=5,x-=5,r.ncode=4+(15&y),y>>>=4,x-=4,286>>=3,x-=3}for(;r.have<19;)r.lens[M[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,N={bits:r.lenbits},F=o(0,r.lens,0,19,r.lencode,0,r.work,N),r.lenbits=N.bits,F){e.msg="invalid code lengths set",r.mode=30;break}r.have=0,r.mode=19;case 19:for(;r.have>>16&255,O=65535&P,!((I=P>>>24)<=x);){if(0===_)break e;_--,y+=c[p++]<>>=I,x-=I,r.lens[r.have++]=O;else{if(16===O){for(U=I+2;x>>=I,x-=I,0===r.have){e.msg="invalid bit length repeat",r.mode=30;break}D=r.lens[r.have-1],A=3+(3&y),y>>>=2,x-=2}else if(17===O){for(U=I+3;x>>=I)),y>>>=3,x=x-I-3}else{for(U=I+7;x>>=I)),y>>>=7,x=x-I-7}if(r.have+A>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=30;break}for(;A--;)r.lens[r.have++]=D}}if(30===r.mode)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=30;break}if(r.lenbits=9,N={bits:r.lenbits},F=o(1,r.lens,0,r.nlen,r.lencode,0,r.work,N),r.lenbits=N.bits,F){e.msg="invalid literal/lengths set",r.mode=30;break}if(r.distbits=6,r.distcode=r.distdyn,N={bits:r.distbits},F=o(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,N),r.distbits=N.bits,F){e.msg="invalid distances set",r.mode=30;break}if(r.mode=20,6===t)break e;case 20:r.mode=21;case 21:if(6<=_&&258<=g){e.next_out=m,e.avail_out=g,e.next_in=p,e.avail_in=_,r.hold=y,r.bits=x,s(e,z),m=e.next_out,d=e.output,g=e.avail_out,p=e.next_in,c=e.input,_=e.avail_in,y=r.hold,x=r.bits,12===r.mode&&(r.back=-1);break}for(r.back=0;T=(P=r.lencode[y&(1<>>16&255,O=65535&P,!((I=P>>>24)<=x);){if(0===_)break e;_--,y+=c[p++]<>R)])>>>16&255,O=65535&P,!(R+(I=P>>>24)<=x);){if(0===_)break e;_--,y+=c[p++]<>>=R,x-=R,r.back+=R}if(y>>>=I,x-=I,r.back+=I,r.length=O,0===T){r.mode=26;break}if(32&T){r.back=-1,r.mode=12;break}if(64&T){e.msg="invalid literal/length code",r.mode=30;break}r.extra=15&T,r.mode=22;case 22:if(r.extra){for(U=r.extra;x>>=r.extra,x-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;T=(P=r.distcode[y&(1<>>16&255,O=65535&P,!((I=P>>>24)<=x);){if(0===_)break e;_--,y+=c[p++]<>R)])>>>16&255,O=65535&P,!(R+(I=P>>>24)<=x);){if(0===_)break e;_--,y+=c[p++]<>>=R,x-=R,r.back+=R}if(y>>>=I,x-=I,r.back+=I,64&T){e.msg="invalid distance code",r.mode=30;break}r.offset=O,r.extra=15&T,r.mode=24;case 24:if(r.extra){for(U=r.extra;x>>=r.extra,x-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=30;break}r.mode=25;case 25:if(0===g)break e;if(r.offset>(A=z-g)){if((A=r.offset-A)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=30;break}E=A>r.wnext?(A-=r.wnext,r.wsize-A):r.wnext-A,A>r.length&&(A=r.length),C=r.window}else C=d,E=m-r.offset,A=r.length;for(g-=A=gy?(v=N[U+c[S]],B[L+c[S]]):(v=96,0),f=1<<(b=x-I),z=p=1<>I)+(p-=f)]=b<<24|v<<16|w|0,0!==p;);for(f=1<>=1;if(R=0!==f?(R&f-1)+f:0,S++,0==--D[x]){if(x===A)break;x=t[r+c[S]]}if(E>>7)]}function k(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function x(e,t,r){e.bi_valid>a-r?(e.bi_buf|=t<>a-e.bi_valid,e.bi_valid+=r-a):(e.bi_buf|=t<>>=1,r<<=1,0<--t;);return r>>>1}function A(e,t,r){for(var n,i=new Array(16),a=0,s=1;s<=15;s++)i[s]=a=a+r[s-1]<<1;for(n=0;n<=t;n++){var o=e[2*n+1];0!==o&&(e[2*n]=z(i[o]++,o))}}function E(e){for(var t=0;t<286;t++)e.dyn_ltree[2*t]=0;for(t=0;t<30;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function C(e){8>1;1<=r;r--)T(e,a,r);for(i=l;r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],T(e,a,1),n=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=n,a[2*i]=a[2*r]+a[2*n],e.depth[i]=(e.depth[r]>=e.depth[n]?e.depth[r]:e.depth[n])+1,a[2*r+1]=a[2*n+1]=i,e.heap[1]=i++,T(e,a,1),2<=e.heap_len;);e.heap[--e.heap_max]=e.heap[1];for(var h,c,d,f,p,m=e,_=t.dyn_tree,g=t.max_code,y=t.stat_desc.static_tree,b=t.stat_desc.has_stree,v=t.stat_desc.extra_bits,w=t.stat_desc.extra_base,k=t.stat_desc.max_length,x=0,S=0;S<=15;S++)m.bl_count[S]=0;for(_[2*m.heap[m.heap_max]+1]=0,h=m.heap_max+1;h<573;h++)k<(S=_[2*_[2*(c=m.heap[h])+1]+1]+1)&&(S=k,x++),_[2*c+1]=S,g>=7;u<30;u++)for(y[u]=i<<7,t=0;t<1<>>=1)if(1&t&&0!==e.dyn_ltree[2*r])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(r=32;r<256;r++)if(0!==e.dyn_ltree[2*r])return 1;return 0}(e)),R(e,e.l_desc),R(e,e.d_desc),o=function(e){var t;for(B(e,e.dyn_ltree,e.l_desc.max_code),B(e,e.dyn_dtree,e.d_desc.max_code),R(e,e.bl_desc),t=18;3<=t&&0===e.bl_tree[2*u[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),i=e.opt_len+3+7>>>3,(a=e.static_len+3+7>>>3)<=i&&(i=a)):i=a=r+5,r+4<=i&&-1!==t)F(e,t,r,n);else if(4===e.strategy||a===i)x(e,2+(n?1:0),3),O(e,h,c);else{x(e,4+(n?1:0),3);var l=e,d=(t=e.l_desc.max_code+1,r=e.d_desc.max_code+1,o+1);for(x(l,t-257,5),x(l,r-1,5),x(l,d-4,4),s=0;s>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(f[r]+256+1)]++,e.dyn_dtree[2*w(t)]++),e.last_lit===e.lit_bufsize-1},r._tr_align=function(e){x(e,2,3),S(e,256,h),16===e.bi_valid?(k(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):8<=e.bi_valid&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}},{"../utils/common":41}],53:[function(e,t,r){"use strict";t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(e,t,n){(function(e){!function(e,t){"use strict";var r,n,i,a,s,o,l,u,h;function c(e){delete s[e]}function d(e){if(o)setTimeout(d,0,e);else{var r=s[e];if(r){o=!0;try{var n=r.callback,i=r.args;switch(i.length){case 0:n();break;case 1:n(i[0]);break;case 2:n(i[0],i[1]);break;case 3:n(i[0],i[1],i[2]);break;default:n.apply(t,i)}}finally{c(e),o=!1}}}}function f(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(i)&&d(+t.data.slice(i.length))}e.setImmediate||(a=1,o=!(s={}),l=e.document,u=(u=Object.getPrototypeOf&&Object.getPrototypeOf(e))&&u.setTimeout?u:e,h="[object process]"==={}.toString.call(e.process)?function(e){process.nextTick((function(){d(e)}))}:function(){var t,r;if(e.postMessage&&!e.importScripts)return t=!0,r=e.onmessage,e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=r,t}()?(i="setImmediate$"+Math.random()+"$",e.addEventListener?e.addEventListener("message",f,!1):e.attachEvent("onmessage",f),function(t){e.postMessage(i+t,"*")}):e.MessageChannel?((n=new MessageChannel).port1.onmessage=function(e){d(e.data)},function(e){n.port2.postMessage(e)}):l&&"onreadystatechange"in l.createElement("script")?(r=l.documentElement,function(e){var t=l.createElement("script");t.onreadystatechange=function(){d(e),t.onreadystatechange=null,r.removeChild(t),t=null},r.appendChild(t)}):function(e){setTimeout(d,0,e)},u.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),r=0;r{"use strict";var e,t=r(434);const n=e=>{var t=new URL(e);return"link.zhihu.com"==t.hostname?(t=new URLSearchParams(t.search).get("target"),decodeURIComponent(t)):e},i=(e,t)=>null!=e&&(e.classList.contains(t)?e:i(e.parentElement,t)),a=e=>{let t;return(t=i(e,"AnswerItem"))&&null!=(t=t.querySelector(".ContentItem-title > div > a"))?t.innerText:(t=i(e,"QuestionPage"))&&null!=(t=t.querySelector("meta[itemprop=name]"))?t.content:(t=i(e,"ArticleItem"))&&null!=(t=t.querySelector("h2.ContentItem-title a"))||(t=i(e,"Post-NormalMain"))&&null!=(t=t.querySelector("header > h1.Post-Title"))?t.innerText:"无标题"},s=e=>{let t;try{if(t=(t=(t=(t=i(e,"AnswerItem"))||(t=i(e,"ArticleItem"))&&t.querySelector(".AuthorInfo-content"))||(t=i(e,"Post-Main"))&&t.querySelector(".Post-Author"))||(t=i(e,"PinItem"))&&t.querySelector(".PinItem-author")){var r=t.querySelector(".AuthorInfo-name .UserLink-link"),n=t.querySelector(".AuthorInfo-badgeText");if(null!=t)return{name:r.innerText||r.children[0].getAttribute("alt"),url:r.href,badge:n?n.innerText:""}}}catch(e){}return null},o=e=>{var t=window.location.origin+window.location.pathname;try{if("/"==window.location.pathname){let r=i(e,"AnswerItem");return(r=r||i(e,"ArticleItem"))?r.querySelector("a[data-za-detail-view-id]").href:t+"#WARNING_Failed_to_get_URL"}}catch{}return t},l=()=>{var e=document.createElement("button");return e.setAttribute("type","button"),e.classList.add("zhihucopier-button"),e.innerText="",e.style.right="0",e.style.top="-2em",e.style.zIndex="999",e.style.width="120px",e.style.height="2em",e.style.backgroundColor="rgba(85, 85, 85, 0.9)",e.style.color="white",e.style.outline="none",e.style.cursor="pointer",e.style.borderRadius="1em",e.style.margin="0 .2em 1em .2em",e.style.fontSize=".8em",e},u=((y=e=e||{})[y.H1=0]="H1",y[y.H2=1]="H2",y[y.Text=2]="Text",y[y.Figure=3]="Figure",y[y.Gif=4]="Gif",y[y.InlineLink=5]="InlineLink",y[y.InlineCode=6]="InlineCode",y[y.Math=7]="Math",y[y.Italic=8]="Italic",y[y.Bold=9]="Bold",y[y.PlainText=10]="PlainText",y[y.UList=11]="UList",y[y.Olist=12]="Olist",y[y.BR=13]="BR",y[y.HR=14]="HR",y[y.Blockquote=15]="Blockquote",y[y.Code=16]="Code",y[y.Link=17]="Link",y[y.Table=18]="Table",y[y.Video=19]="Video",t=>{var r=[];for(let u=0;u code").classList.value.slice(9),dom:i}):i.classList.contains("RichText-LinkCardContainer")?(s=i.firstChild,r.push({type:e.Link,text:s.getAttribute("data-text"),href:n(s.href),dom:i})):i.querySelector("video")&&r.push({type:e.Video,src:i.querySelector("video").getAttribute("src"),local:!1,dom:i});break;case"blockquote":r.push({type:e.Blockquote,content:h(i),dom:i});break;case"figure":var a,s=i.querySelector("img");s.classList.contains("ztext-gif")?(a=(s.getAttribute("src")||s.getAttribute("data-thumbnail")).replace(/\..{3,4}$/g,".gif"))&&r.push({type:e.Gif,src:a,local:!1,dom:i}):(a=s.getAttribute("data-actualsrc")||s.getAttribute("data-original"))&&r.push({type:e.Figure,src:a,local:!1,dom:i});break;case"ul":var o=Array.from(i.querySelectorAll("li"));r.push({type:e.UList,content:o.map((e=>h(e))),dom:i});break;case"ol":o=Array.from(i.querySelectorAll("li")),r.push({type:e.Olist,content:o.map((e=>h(e))),dom:i});break;case"p":r.push({type:e.Text,content:h(i),dom:i});break;case"hr":r.push({type:e.HR,dom:i});break;case"table":var l=(e=>{var t,r=[];for(t of Array.from(e.rows)){var n=Array.from(t.cells);r.push(n.map((e=>e.innerHTML.replace(/(.*?).*?<\/svg><\/a>/gms,"$1").replace(/(.*?)<\/span>/gms,"$1"))))}return r})(i);r.push({type:e.Table,content:l,dom:i})}}return r}),h=t=>{if("string"==typeof t)return[{type:e.PlainText,text:t}];let r=Array.from(t.childNodes);var i,a=[];try{1==r.length&&"p"==r[0].tagName.toLowerCase()&&(r=Array.from(r[0].childNodes))}catch{}for(i of r)if(i.nodeType==i.TEXT_NODE)a.push({type:e.PlainText,text:i.textContent,dom:i});else{var s=i;switch(s.tagName.toLowerCase()){case"b":a.push({type:e.Bold,content:h(s),dom:s});break;case"i":a.push({type:e.Italic,content:h(s),dom:s});break;case"br":a.push({type:e.BR,dom:s});break;case"code":a.push({type:e.InlineCode,content:s.innerText,dom:s});break;case"span":try{s.classList.contains("ztext-math")?a.push({type:e.Math,content:s.getAttribute("data-tex"),dom:s}):s.children[0].classList.contains("RichContent-EntityWord")&&a.push({type:e.PlainText,text:s.innerText,dom:s})}catch{a.push({type:e.PlainText,text:s.innerText,dom:s})}break;case"a":a.push({type:e.InlineLink,text:s.textContent,href:n(s.href),dom:s})}}return a},c=t=>{var r=[];for(let h=0;h"- "+d(e))).join("\n"));break;case e.Olist:r.push(n.content.map(((e,t)=>t+1+". "+d(e))).join("\n"));break;case e.H1:r.push("# "+n.text);break;case e.H2:r.push("## "+n.text);break;case e.Blockquote:r.push(d(n.content,"> "));break;case e.Text:r.push(d(n.content));break;case e.HR:r.push("\n---\n");break;case e.Link:r.push(`[${n.text}](${n.href})`);break;case e.Figure:case e.Gif:r.push(`![](${n.local?n.localSrc:n.src})`);break;case e.Video:var i=document.createElement("video");i.setAttribute("src",n.local?n.localSrc:n.src),n.local||i.setAttribute("data-info","文件还未下载,随时可能失效,请使用`下载全文为Zip`将视频一同下载下来"),r.push(i.outerHTML);break;case e.Table:{var a=n.content;const e=a[0].length,t=new Array(e).fill(0);var s,o=[];for(s in a)for(var l in a[s])t[l]=Math.max(t[l],a[s][l].length);var u=r=>{let n="";for(let i=0;i{let r="";for(let n=0;n{let n="";for(var i of t)switch(i.type){case e.Bold:n+=`**${d(i.content)}**`;break;case e.Italic:n+=`*${d(i.content)}*`;break;case e.InlineLink:n+=`[${i.text}](${i.href})`;break;case e.PlainText:n+=i.text;break;case e.BR:n+="\n"+r;break;case e.InlineCode:n+=`\`${i.content}\``;break;case e.Math:1==t.length?n+=`$$\n${i.content}\n$$`:n+=`$${i.content}$`}return r+n};var f=r(905);async function p(e,t){var r=await(await fetch(e)).arrayBuffer();return e=e.replace(/\?.*?$/g,"").split("/").pop(),t.file(e,r),{zip:t,file_name:e}}const m=async(t,r="assets")=>{var n,i=new f;let a=!1;for(n of t)if(n.type===e.Figure){a=!0;break}if(a){var s,o,l,u=i.folder(r);for(s of t)s.type===e.Figure||s.type===e.Video?(o=(await p(s.src,u)).file_name,s.localSrc=`./${r}/`+o,s.local=!0):s.type===e.Gif&&(l=(await p(s.src,u)).file_name,s.localSrc=`./${r}/`+l,s.local=!0)}return t=c(t).join("\n\n"),i.file("index.md",t),i},_=t=>{const r={type:e.Text,content:[]};return t.innerText.split("\n").forEach((t=>{r.content.push({type:e.PlainText,text:t}),r.content.push({type:e.BR})})),[r]},g=[];var y=async()=>{var r,n,h,d,p,y,b,v,w,k,x,S=Array.from(document.querySelectorAll(".RichText")),z=Array.from(document.getElementsByClassName("QuestionHeader-title"));for(r of S){try{var A=Array.from(r.children);for(let e=1;e{const r=_(t);var n=((n=i(t,"PinItem"))&&Array.from(n.querySelectorAll(".Image-PreviewVague > img")).forEach((t=>{r.push({type:e.Figure,src:t.getAttribute("data-original")||t.getAttribute("data-actualsrc")})})),c(r)),{zop:a,zaExtra:o}=(()=>{var e=i(t,"PinItem");try{if(e)return{zop:JSON.parse(decodeURIComponent(e.getAttribute("data-zop"))),zaExtra:JSON.parse(decodeURIComponent(e.getAttribute("data-za-extra-module")))}}catch{}return{zop:null,zaExtra:null}})(),l=s(t),u=(a.itemId,await m(r));return u.file("info.json",JSON.stringify({author:l,url:"https://www.zhihu.com/pin/"+a.itemId,zop:a,"zop-extra-module":o},null,4)),{lex:r,markdown:n,zip:u,title:"想法",itemId:a.itemId}})(r);f={markdown:O.markdown,zip:O.zip,title:O.title,dom:r,itemId:O.itemId}}else{k=x=k=void 0,h=u((n=r).childNodes),d=c(h),p=(()=>{var e=document.querySelector("[data-zop-question]");try{if(e instanceof HTMLElement)return JSON.parse(decodeURIComponent(e.getAttribute("data-zop-question")))}catch{}return null})(),y=(()=>{let e=i(n,"AnswerItem");e=e||i(n,"Post-content");try{if(e instanceof HTMLElement)return JSON.parse(decodeURIComponent(e.getAttribute("data-zop")))}catch{}return null})(),b=(()=>{var e=document.querySelector("[data-za-extra-module]");try{if(e instanceof HTMLElement)return JSON.parse(decodeURIComponent(e.getAttribute("data-za-extra-module")))}catch{}return null})(),v=a(n),w=s(n),k=o(n),(x=await m(h)).file("info.json",JSON.stringify({title:v,url:k,author:w,zop:y,"zop-question":p,"zop-extra-module":b},null,4)),k=(y||{}).itemId||"xxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}));var R=await{lex:h,markdown:d,zip:x,title:v,itemId:k};f={markdown:R.markdown,zip:R.zip,title:R.title,dom:r,itemId:R.itemId},i(r,"QuestionRichText")&&(f.question=!0,f.itemId="问题描述")}(e=>{g.every((t=>t.dom!==e.dom))&&g.push(e)})(f);const S=l(),z=(S.innerHTML="下载全文为Zip",S.style.borderRadius="0 1em 1em 0",S.style.width="100px",S.style.paddingRight=".4em",I.prepend(S),S.addEventListener("click",(async()=>{try{var e=await f.zip.generateAsync({type:"blob"});(0,t.saveAs)(e,f.title+"-"+f.itemId+".zip"),S.innerHTML="下载成功✅",setTimeout((()=>{S.innerHTML="下载全文为Zip"}),1e3)}catch{S.innerHTML="发生未知错误
请联系开发者",S.style.height="4em",setTimeout((()=>{S.style.height="2em",S.innerHTML="下载全文为Zip"}),1e3)}})),l());z.innerHTML="复制为Markdown",z.style.borderRadius="1em 0 0 1em",z.style.paddingLeft=".4em",I.prepend(z),z.addEventListener("click",(()=>{try{navigator.clipboard.writeText(f.markdown.join("\n\n")),z.innerHTML="复制成功✅",setTimeout((()=>{z.innerHTML="复制为Markdown"}),1e3)}catch{z.innerHTML="发生未知错误
请联系开发者",z.style.height="4em",setTimeout((()=>{z.style.height="2em",z.innerHTML="复制为Markdown"}),1e3)}}))}catch(r){}}z.forEach((e=>{if(!e.querySelector(".zhihucopier-button")){const r=l();r.style.width="75px",r.style.fontSize="13px",r.style.lineHeight="13px",r.style.margin="0",r.innerHTML="批量下载",r.classList.add("zhihucopier-button"),i(e,"App-main")?e.append(r):(r.style.marginRight=".4em",e.prepend(r)),r.addEventListener("click",(e=>{e.stopPropagation(),e.preventDefault();try{(async()=>{const e=new f;g.forEach((t=>{const r=t.title+"-"+t.itemId;Object.keys(t.zip.files).forEach((n=>{e.files[r+"/"+n]=t.zip.files[n]}))})),(0,t.saveAs)(await e.generateAsync({type:"blob"}),`问题『${g[0].title}』下的${g.length}个回答.zip`)})(),r.style.width="90px",r.innerHTML="下载成功✅",setTimeout((()=>{r.innerHTML="批量下载",r.style.width="75px"}),1e3)}catch{r.style.width="190px",r.innerHTML="发生未知错误,请联系开发者",setTimeout((()=>{r.innerHTML="批量下载",r.style.width="75px"}),1e3)}}))}}))};setTimeout(y,300),setInterval(y,1e3)})()})();