├── css ├── main.css └── popup.css ├── images ├── icon-128px-dark.png ├── icon-128px-origin.png └── icon-128px.png ├── js ├── background.js ├── content │ ├── FileSaver.min.js │ ├── autosave.js │ ├── jszip.min.js │ ├── keysync.js │ ├── main.js │ └── show.js └── popup.js ├── manifest.json ├── options.html ├── popup.html └── static └── js ├── main.b7f29431.js ├── main.b7f29431.js.LICENSE.txt └── main.b7f29431.js.map /css/main.css: -------------------------------------------------------------------------------- 1 | /* It would work on github.com */ 2 | 3 | /*body{ 4 | background: black !important; 5 | }*/ 6 | 7 | /*override styles*/ 8 | .repository-content .js-navigation-container tr.js-navigation-item td.icon{ 9 | position: relative; 10 | } 11 | 12 | *[class*="gitzip-"]{ 13 | transition:all 0.3s ease; 14 | -webkit-transition:all 0.3s ease; /* Safari and Chrome */ 15 | } 16 | 17 | .gitzip-show{ 18 | visibility: visible !important; 19 | opacity: 1 !important; 20 | } 21 | 22 | .gitzip-header{ 23 | color: #333; 24 | background-color: #f5f5f5; 25 | padding: 10px 15px; 26 | border-bottom: 1px solid #ddd; 27 | border-top-left-radius: 3px; 28 | border-top-right-radius: 3px; 29 | } 30 | 31 | .gitzip-dark .gitzip-header { 32 | color: #f0f6fc; 33 | background-color: #1e2126; 34 | border-bottom: 1px solid #222; 35 | } 36 | 37 | .gitzip-close{ 38 | float: right; 39 | font-weight: 800; 40 | cursor: pointer; 41 | visibility: hidden; 42 | } 43 | 44 | .gitzip-fail .gitzip-close{ 45 | visibility: visible; 46 | } 47 | 48 | .gitzip-body{ 49 | margin: 10px 0; 50 | height: 246px; 51 | overflow: auto; 52 | } 53 | 54 | .gitzip-body p{ 55 | margin: 0; 56 | padding: 0 15px; 57 | color: #333; 58 | } 59 | 60 | .gitzip-dark .gitzip-body p{ 61 | color: #f0f6fc; 62 | } 63 | 64 | .gitzip-body p.warn{ 65 | background-color: #fffbe7; 66 | color: #624115; 67 | border: 1px solid #fff4c7; 68 | } 69 | 70 | .gitzip-body p.error{ 71 | background-color: #fff0f0; 72 | color: #ff081e; 73 | border: 1px solid #ffd6d6; 74 | } 75 | 76 | .gitzip-dark .gitzip-body p.warn, .gitzip-dark .gitzip-body p.error{ 77 | background-color: inherit; 78 | border: none; 79 | } 80 | 81 | .gitzip-dark .gitzip-body p.warn{ 82 | color: #e3b341; 83 | } 84 | 85 | .gitzip-downloading{ 86 | width: 480px !important; 87 | height: 320px !important; 88 | background-color: transparent !important; 89 | border-radius: 0px !important; 90 | } 91 | 92 | .gitzip-check-mark{ 93 | position: absolute; 94 | left: -10px; 95 | top: 0px; 96 | font-size: 18px; 97 | margin:0 !important; 98 | visibility: hidden; 99 | opacity: 0; 100 | color: #333; 101 | } 102 | 103 | .gitzip-dark.gitzip-check-mark{ 104 | color: #f0f6fc; 105 | } 106 | 107 | .gitzip-check-wrap{ 108 | position: absolute; 109 | left: -5px; 110 | top: 0px; 111 | height: 100%; 112 | display: none; 113 | align-items: center; 114 | } 115 | 116 | /* In new UI */ 117 | td .gitzip-check-mark, 118 | td .gitzip-check-wrap{ 119 | left: 4px; 120 | } 121 | 122 | .gitzip-collect-wrap{ 123 | position: fixed; 124 | right: 28px; 125 | bottom: 28px; 126 | z-index: 1000; 127 | } 128 | 129 | .gitzip-collect-arrow{ 130 | position: absolute; 131 | right: 0px; 132 | bottom: 0px; 133 | visibility: hidden; 134 | opacity: 0; 135 | width: 56px; 136 | height: 56px; 137 | color: #333; 138 | } 139 | 140 | .gitzip-dark .gitzip-collect-arrow{ 141 | color: #f0f6fc; 142 | } 143 | 144 | .gitzip-collect-arrow:hover{ 145 | width: 270px; 146 | height: 65px; 147 | border-radius: 8px; 148 | color: #f0f6fc; 149 | background-color: #333; 150 | } 151 | 152 | .gitzip-dark .gitzip-collect-arrow:hover{ 153 | background-color: transparent; 154 | } 155 | 156 | .gitzip-collect-down{ 157 | font-size: 56px; 158 | line-height: 56px; 159 | margin: 0; 160 | -webkit-transform: rotate(90deg); /* Chrome, Safari, Opera */ 161 | transform: rotate(90deg); 162 | cursor: pointer; 163 | position: absolute; 164 | right: 0px; 165 | bottom: 4px; 166 | } 167 | 168 | .gitzip-collect-dash{ 169 | box-shadow: 1px 1px 10px 0px #d0d0d0; 170 | background-color: #fff; 171 | border-radius: 4px; 172 | border: 1px solid #ddd; 173 | visibility: hidden; 174 | opacity: 0; 175 | position: absolute; 176 | right: 0; 177 | bottom: 0; 178 | width: 0px; 179 | height: 0px; 180 | } 181 | 182 | .gitzip-dark .gitzip-collect-dash { 183 | box-shadow: 1px 1px 10px 0px #2f2f2f; 184 | background-color: #13171d; 185 | border: 1px solid #222; 186 | } 187 | 188 | .gitzip-downloading .gitzip-collect-dash{ 189 | width: 100%; 190 | height: 100%; 191 | display: block; 192 | visibility: visible; 193 | opacity: 1; 194 | } 195 | 196 | .gitzip-collect-tip{ 197 | visibility: hidden; 198 | opacity: 0; 199 | cursor: pointer; 200 | position: absolute; 201 | left: -213px; 202 | bottom: 0; 203 | margin: 0; 204 | line-height: 65px; 205 | font-size: 18px; 206 | width: 230px; 207 | padding-left:10px; 208 | } 209 | 210 | .gitzip-collect-arrow:hover .gitzip-collect-tip{ 211 | visibility: visible; opacity: 1; 212 | left: 0px; 213 | } 214 | 215 | .gitzip-downloading .gitzip-collect-tip, .gitzip-downloading .gitzip-collect-down{ 216 | display: none !important; 217 | } 218 | -------------------------------------------------------------------------------- /css/popup.css: -------------------------------------------------------------------------------- 1 | 2 | * { 3 | -webkit-box-sizing: border-box; 4 | -moz-box-sizing: border-box; 5 | box-sizing: border-box; 6 | } 7 | 8 | input { margin: 0; } 9 | 10 | a { 11 | color: #337ab7; 12 | text-decoration: none; 13 | background-color: transparent; 14 | } 15 | 16 | body{ 17 | font-family: "Helvetica Neue",Helvetica,Arial,sans-serif; 18 | font-size: 14px; 19 | line-height: 1.42857143; 20 | color: #333; 21 | margin: 5px; 22 | background-color: #f5f5f5; 23 | } 24 | 25 | .panel{ 26 | width: 400px; 27 | height: 130px; 28 | background-color: #fff; 29 | border-radius: 4px; 30 | } 31 | 32 | .panel-heading{ 33 | color: #333; 34 | background-color: #f5f5f5; 35 | border-color: #ddd; 36 | padding: 10px 15px; 37 | border-bottom: 1px solid transparent; 38 | border-top-left-radius: 3px; 39 | border-top-right-radius: 3px; 40 | } 41 | 42 | .panel-body{ 43 | padding: 15px; 44 | } 45 | 46 | .form-control{ 47 | display: block; 48 | width: 100%; 49 | height: 34px; 50 | padding: 6px 12px; 51 | font-size: 14px; 52 | line-height: 1.42857143; 53 | color: #555; 54 | background-color: #fff; 55 | background-image: none; 56 | border: 1px solid #ccc; 57 | border-radius: 4px; 58 | -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075); 59 | box-shadow: inset 0 1px 1px rgba(0,0,0,.075); 60 | } 61 | 62 | .token-right{ 63 | float: right; 64 | padding: 8px 10px 0px; 65 | } 66 | 67 | .tip-left{ 68 | float: left; 69 | font-size: 10px; 70 | color: red; 71 | padding: 4px 5px 0px; 72 | display: none; 73 | } 74 | 75 | body.dark-theme { 76 | color: #f0f6fc; 77 | background-color: #1e2126; 78 | } 79 | 80 | .dark-theme .panel-heading { 81 | color: #f0f6fc; 82 | background-color: #1e2126; 83 | border-color: #222; 84 | } 85 | 86 | .dark-theme .panel{ 87 | background-color: #000; 88 | } 89 | 90 | .dark-theme .form-control{ 91 | outline: none !important; 92 | color: #aaa; 93 | background-color: #000; 94 | border: 1px solid #222; 95 | -webkit-box-shadow: inset 0 1px 1px rgba(255,255,255,.075); 96 | box-shadow: inset 0 1px 1px rgba(255,255,255,.075); 97 | } 98 | 99 | .dark-theme .form-control:focus{ 100 | border: 1px solid #555; 101 | } 102 | -------------------------------------------------------------------------------- /images/icon-128px-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitZip/chrome-extension/971515cbf3f941200a30d997881d1d55a67db0bf/images/icon-128px-dark.png -------------------------------------------------------------------------------- /images/icon-128px-origin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitZip/chrome-extension/971515cbf3f941200a30d997881d1d55a67db0bf/images/icon-128px-origin.png -------------------------------------------------------------------------------- /images/icon-128px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitZip/chrome-extension/971515cbf3f941200a30d997881d1d55a67db0bf/images/icon-128px.png -------------------------------------------------------------------------------- /js/background.js: -------------------------------------------------------------------------------- 1 | 2 | // Received a message from content script 3 | chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) { 4 | switch (request.action){ 5 | case "showIcon": 6 | chrome.action.enable(sender.tab.id, function(res){ sendResponse(res); }); 7 | return true; 8 | case "getKey": 9 | chrome.storage.sync.get("gitzip-github-token", function(res){ 10 | sendResponse(res["gitzip-github-token"] || ""); 11 | }); 12 | return true; 13 | case "setKey": 14 | chrome.storage.sync.set( {"gitzip-github-token": request.value}, function(res){ 15 | sendResponse(res); 16 | }); 17 | return true; 18 | case "getCurrentPath": 19 | chrome.tabs.query({currentWindow: true, active: true}, function(tabs){ 20 | var tab = tabs[0]; 21 | if(tab) chrome.tabs.sendMessage(tab.id, {action: "getCurrentPath" }, function(res){ 22 | sendResponse(res); 23 | }); 24 | }); 25 | return true; 26 | case "createContextNested": 27 | var main = chrome.contextMenus.create({ 28 | id: "gitzip-nested", 29 | title: "GitZip Download", 30 | contexts: ["all"] 31 | }); 32 | chrome.contextMenus.create({ 33 | id: "gitzip-nested-items", 34 | parentId: main, 35 | title: "Checked Items", 36 | contexts: ["all"], 37 | enabled: false 38 | }); 39 | chrome.contextMenus.create({ 40 | id: "gitzip-nested-seperator", 41 | parentId: main, 42 | title: "seperator", 43 | type: "separator", 44 | contexts: ["all"] 45 | }); 46 | chrome.contextMenus.create({ 47 | id: "gitzip-nested-selected", 48 | parentId: main, 49 | title: "(selected)", 50 | contexts: ["all"], 51 | enabled: false 52 | }); 53 | chrome.contextMenus.create({ 54 | id: "gitzip-nested-current", 55 | parentId: main, 56 | title: "(current)", 57 | contexts: ["all"], 58 | enabled: false 59 | }); 60 | return true; 61 | case "updateContextNested": 62 | var id = request.target; 63 | var updateObj = { enabled: request.enabled !== false }; 64 | switch (id) { 65 | case "selected": 66 | updateObj.title = updateObj.enabled ? ("Selected " + (request.urlType == "blob" ? "File - " : "Folder - ") + request.urlName) : "(selected)"; 67 | break; 68 | case "current": 69 | if (request.root === true) 70 | updateObj.title = "Whole Repository"; 71 | else 72 | updateObj.title = updateObj.enabled ? ("Current " + (request.urlType == "blob" ? "File - " : "Folder - ") + request.urlName) : "(current)"; 73 | break; 74 | } 75 | chrome.contextMenus.update("gitzip-nested-" + id, updateObj); 76 | return true; 77 | case "removeContext": 78 | chrome.contextMenus.removeAll(function(res){ sendResponse(res); }); 79 | return true; 80 | } 81 | }); 82 | 83 | chrome.contextMenus.onClicked.addListener(function(info, tab){ 84 | if ( info.menuItemId.toString().indexOf("gitzip-") != -1 ) { 85 | chrome.tabs.sendMessage(tab.id, {action: info.menuItemId + "-clicked"}); 86 | } 87 | }); 88 | 89 | chrome.tabs.onActivated.addListener(function(activeInfo) { 90 | // disable first 91 | chrome.action.disable(activeInfo.tabId); 92 | 93 | // handle other tabs active 94 | chrome.contextMenus.removeAll(); 95 | 96 | // change back to current tab 97 | chrome.tabs.sendMessage(activeInfo.tabId, {action: "github-tab-active", from: "onActivated" }); 98 | }); 99 | 100 | chrome.tabs.onUpdated.addListener(function(tabId, changeInfo){ 101 | if ( changeInfo.status == "loading" ) { 102 | chrome.contextMenus.removeAll(); 103 | } else if ( changeInfo.status == "complete" ) { 104 | // coding like this because it would cause error during current page loading and then shift another tab quickly. 105 | chrome.tabs.query({currentWindow: true, active: true}, function(tabs){ 106 | var tab = tabs[0]; 107 | if(tab) chrome.tabs.sendMessage(tab.id, {action: "github-tab-active", from: "onUpdated" }); 108 | }); 109 | } 110 | }); 111 | 112 | -------------------------------------------------------------------------------- /js/content/FileSaver.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | ! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js 3 | 4 | The MIT License 5 | 6 | Copyright © 2016 [Eli Grey][1]. 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 11 | 12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 13 | 14 | [1]: http://eligrey.com 15 | 16 | */ 17 | var saveAs=saveAs||function(e){"use strict";if(typeof navigator!=="undefined"&&/MSIE [1-9]\./.test(navigator.userAgent)){return}var t=e.document,n=function(){return e.URL||e.webkitURL||e},r=t.createElementNS("http://www.w3.org/1999/xhtml","a"),i="download"in r,o=function(e){var t=new MouseEvent("click");e.dispatchEvent(t)},a=/Version\/[\d\.]+.*Safari/.test(navigator.userAgent),f=e.webkitRequestFileSystem,u=e.requestFileSystem||f||e.mozRequestFileSystem,s=function(t){(e.setImmediate||e.setTimeout)(function(){throw t},0)},c="application/octet-stream",d=0,l=500,w=function(t){var r=function(){if(typeof t==="string"){n().revokeObjectURL(t)}else{t.remove()}};if(e.chrome){r()}else{setTimeout(r,l)}},p=function(e,t,n){t=[].concat(t);var r=t.length;while(r--){var i=e["on"+t[r]];if(typeof i==="function"){try{i.call(e,n||e)}catch(o){s(o)}}}},v=function(e){if(/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)){return new Blob(["\ufeff",e],{type:e.type})}return e},y=function(t,s,l){if(!l){t=v(t)}var y=this,m=t.type,S=false,h,R,O=function(){p(y,"writestart progress write writeend".split(" "))},g=function(){if(R&&a&&typeof FileReader!=="undefined"){var r=new FileReader;r.onloadend=function(){var e=r.result;R.location.href="data:attachment/file"+e.slice(e.search(/[,;]/));y.readyState=y.DONE;O()};r.readAsDataURL(t);y.readyState=y.INIT;return}if(S||!h){h=n().createObjectURL(t)}if(R){R.location.href=h}else{var i=e.open(h,"_blank");if(i==undefined&&a){e.location.href=h}}y.readyState=y.DONE;O();w(h)},b=function(e){return function(){if(y.readyState!==y.DONE){return e.apply(this,arguments)}}},E={create:true,exclusive:false},N;y.readyState=y.INIT;if(!s){s="download"}if(i){h=n().createObjectURL(t);r.href=h;r.download=s;setTimeout(function(){o(r);O();w(h);y.readyState=y.DONE});return}if(e.chrome&&m&&m!==c){N=t.slice||t.webkitSlice;t=N.call(t,0,t.size,c);S=true}if(f&&s!=="download"){s+=".download"}if(m===c||f){R=e}if(!u){g();return}d+=t.size;u(e.TEMPORARY,d,b(function(e){e.root.getDirectory("saved",E,b(function(e){var n=function(){e.getFile(s,E,b(function(e){e.createWriter(b(function(n){n.onwriteend=function(t){R.location.href=e.toURL();y.readyState=y.DONE;p(y,"writeend",t);w(e)};n.onerror=function(){var e=n.error;if(e.code!==e.ABORT_ERR){g()}};"writestart progress write abort".split(" ").forEach(function(e){n["on"+e]=y["on"+e]});n.write(t);y.abort=function(){n.abort();y.readyState=y.DONE};y.readyState=y.WRITING}),g)}),g)};e.getFile(s,{create:false},b(function(e){e.remove();n()}),b(function(e){if(e.code===e.NOT_FOUND_ERR){n()}else{g()}}))}),g)}),g)},m=y.prototype,S=function(e,t,n){return new y(e,t,n)};if(typeof navigator!=="undefined"&&navigator.msSaveOrOpenBlob){return function(e,t,n){if(!n){e=v(e)}return navigator.msSaveOrOpenBlob(e,t||"download")}}m.abort=function(){var e=this;e.readyState=e.DONE;p(e,"abort")};m.readyState=m.INIT=0;m.WRITING=1;m.DONE=2;m.error=m.onwritestart=m.onprogress=m.onwrite=m.onabort=m.onerror=m.onwriteend=null;return S}(typeof self!=="undefined"&&self||typeof window!=="undefined"&&window||this.content);if(typeof module!=="undefined"&&module.exports){module.exports.saveAs=saveAs}else if(typeof define!=="undefined"&&define!==null&&define.amd!=null){define([],function(){return saveAs})} -------------------------------------------------------------------------------- /js/content/autosave.js: -------------------------------------------------------------------------------- 1 | 2 | function save(){ 3 | if(document.readyState === "complete"){ 4 | var tokencache = document.querySelector('p.token-cache'); 5 | if(tokencache && tokencache.textContent){ 6 | chrome.runtime.sendMessage({action: "setKey", value: tokencache.textContent}, function(response){}); 7 | } 8 | } 9 | } 10 | 11 | if(document.readyState === "complete") save(); 12 | else document.addEventListener("readystatechange", function(){ save(); }); 13 | 14 | -------------------------------------------------------------------------------- /js/content/jszip.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | 3 | JSZip - A Javascript class for generating and reading zip files 4 | 5 | 6 | (c) 2009-2014 Stuart Knightley 7 | Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/master/LICENSE.markdown. 8 | 9 | JSZip uses the library pako released under the MIT license : 10 | https://github.com/nodeca/pako/blob/master/LICENSE 11 | */ 12 | !function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.JSZip=a()}}(function(){var a;return function b(a,c,d){function e(g,h){if(!c[g]){if(!a[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};a[g][0].call(k.exports,function(b){var c=a[g][1][b];return e(c?c:b)},k,k.exports,b,a,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;gl?a[l++]:0,e=m>l?a[l++]:0):(b=a.charCodeAt(l++),c=m>l?a.charCodeAt(l++):0,e=m>l?a.charCodeAt(l++):0),g=b>>2,h=(3&b)<<4|c>>4,i=n>1?(15&c)<<2|e>>6:64,j=n>2?63&e:64,k.push(f.charAt(g)+f.charAt(h)+f.charAt(i)+f.charAt(j));return k.join("")},c.decode=function(a){var b,c,d,g,h,i,j,k=0,l=0;a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");var m=3*a.length/4;a.charAt(a.length-1)===f.charAt(64)&&m--,a.charAt(a.length-2)===f.charAt(64)&&m--;var n;for(n=e.uint8array?new Uint8Array(m):new Array(m);k>4,c=(15&h)<<4|i>>2,d=(3&i)<<6|j,n[l++]=b,64!==i&&(n[l++]=c),64!==j&&(n[l++]=d);return n}},{"./support":27,"./utils":29}],2:[function(a,b,c){"use strict";function d(a,b,c,d,e){this.compressedSize=a,this.uncompressedSize=b,this.crc32=c,this.compression=d,this.compressedContent=e}var e=a("./external"),f=a("./stream/DataWorker"),g=a("./stream/DataLengthProbe"),h=a("./stream/Crc32Probe"),g=a("./stream/DataLengthProbe");d.prototype={getContentWorker:function(){var a=new f(e.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new g("data_length")),b=this;return a.on("end",function(){if(this.streamInfo.data_length!==b.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),a},getCompressedWorker:function(){return new f(e.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},d.createWorkerFrom=function(a,b,c){return a.pipe(new h).pipe(new g("uncompressedSize")).pipe(b.compressWorker(c)).pipe(new g("compressedSize")).withStreamInfo("compression",b)},b.exports=d},{"./external":6,"./stream/Crc32Probe":22,"./stream/DataLengthProbe":23,"./stream/DataWorker":24}],3:[function(a,b,c){"use strict";var d=a("./stream/GenericWorker");c.STORE={magic:"\x00\x00",compressWorker:function(a){return new d("STORE compression")},uncompressWorker:function(){return new d("STORE decompression")}},c.DEFLATE=a("./flate")},{"./flate":7,"./stream/GenericWorker":25}],4:[function(a,b,c){"use strict";function d(){for(var a,b=[],c=0;256>c;c++){a=c;for(var d=0;8>d;d++)a=1&a?3988292384^a>>>1:a>>>1;b[c]=a}return b}function e(a,b,c,d){var e=h,f=d+c;a=-1^a;for(var g=d;f>g;g++)a=a>>>8^e[255&(a^b[g])];return-1^a}function f(a,b,c,d){var e=h,f=d+c;a=-1^a;for(var g=d;f>g;g++)a=a>>>8^e[255&(a^b.charCodeAt(g))];return-1^a}var g=a("./utils"),h=d();b.exports=function(a,b){if("undefined"==typeof a||!a.length)return 0;var c="string"!==g.getTypeOf(a);return c?e(0|b,a,a.length,0):f(0|b,a,a.length,0)}},{"./utils":29}],5:[function(a,b,c){"use strict";c.base64=!1,c.binary=!1,c.dir=!1,c.createFolders=!0,c.date=null,c.compression=null,c.compressionOptions=null,c.comment=null,c.unixPermissions=null,c.dosPermissions=null},{}],6:[function(a,b,c){"use strict";var d=a("es6-promise").Promise;b.exports={Promise:d}},{"es6-promise":37}],7:[function(a,b,c){"use strict";function d(a,b){h.call(this,"FlateWorker/"+a),this._pako=new f[a]({raw:!0,level:b.level||-1}),this.meta={};var c=this;this._pako.onData=function(a){c.push({data:a,meta:c.meta})}}var e="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,f=a("pako"),g=a("./utils"),h=a("./stream/GenericWorker"),i=e?"uint8array":"array";c.magic="\b\x00",g.inherits(d,h),d.prototype.processChunk=function(a){this.meta=a.meta,this._pako.push(g.transformTo(i,a.data),!1)},d.prototype.flush=function(){h.prototype.flush.call(this),this._pako.push([],!0)},d.prototype.cleanUp=function(){h.prototype.cleanUp.call(this),this._pako=null},c.compressWorker=function(a){return new d("Deflate",a)},c.uncompressWorker=function(){return new d("Inflate",{})}},{"./stream/GenericWorker":25,"./utils":29,pako:38}],8:[function(a,b,c){"use strict";function d(a,b,c,d){f.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=b,this.zipPlatform=c,this.encodeFileName=d,this.streamFiles=a,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}var e=a("../utils"),f=a("../stream/GenericWorker"),g=a("../utf8"),h=a("../crc32"),i=a("../signature"),j=function(a,b){var c,d="";for(c=0;b>c;c++)d+=String.fromCharCode(255&a),a>>>=8;return d},k=function(a,b){var c=a;return a||(c=b?16893:33204),(65535&c)<<16},l=function(a,b){return 63&(a||0)},m=function(a,b,c,d,f,m){var n,o,p=a.file,q=a.compression,r=m!==g.utf8encode,s=e.transformTo("string",m(p.name)),t=e.transformTo("string",g.utf8encode(p.name)),u=p.comment,v=e.transformTo("string",m(u)),w=e.transformTo("string",g.utf8encode(u)),x=t.length!==p.name.length,y=w.length!==u.length,z="",A="",B="",C=p.dir,D=p.date,E={crc32:0,compressedSize:0,uncompressedSize:0};b&&!c||(E.crc32=a.crc32,E.compressedSize=a.compressedSize,E.uncompressedSize=a.uncompressedSize);var F=0;b&&(F|=8),r||!x&&!y||(F|=2048);var G=0,H=0;C&&(G|=16),"UNIX"===f?(H=798,G|=k(p.unixPermissions,C)):(H=20,G|=l(p.dosPermissions,C)),n=D.getUTCHours(),n<<=6,n|=D.getUTCMinutes(),n<<=5,n|=D.getUTCSeconds()/2,o=D.getUTCFullYear()-1980,o<<=4,o|=D.getUTCMonth()+1,o<<=5,o|=D.getUTCDate(),x&&(A=j(1,1)+j(h(s),4)+t,z+="up"+j(A.length,2)+A),y&&(B=j(1,1)+j(h(v),4)+w,z+="uc"+j(B.length,2)+B);var I="";I+="\n\x00",I+=j(F,2),I+=q.magic,I+=j(n,2),I+=j(o,2),I+=j(E.crc32,4),I+=j(E.compressedSize,4),I+=j(E.uncompressedSize,4),I+=j(s.length,2),I+=j(z.length,2);var J=i.LOCAL_FILE_HEADER+I+s+z,K=i.CENTRAL_FILE_HEADER+j(H,2)+I+j(v.length,2)+"\x00\x00\x00\x00"+j(G,4)+j(d,4)+s+z+v;return{fileRecord:J,dirRecord:K}},n=function(a,b,c,d,f){var g="",h=e.transformTo("string",f(d));return g=i.CENTRAL_DIRECTORY_END+"\x00\x00\x00\x00"+j(a,2)+j(a,2)+j(b,4)+j(c,4)+j(h.length,2)+h},o=function(a){var b="";return b=i.DATA_DESCRIPTOR+j(a.crc32,4)+j(a.compressedSize,4)+j(a.uncompressedSize,4)};e.inherits(d,f),d.prototype.push=function(a){var b=a.meta.percent||0,c=this.entriesCount,d=this._sources.length;this.accumulate?this.contentBuffer.push(a):(this.bytesWritten+=a.data.length,f.prototype.push.call(this,{data:a.data,meta:{currentFile:this.currentFile,percent:c?(b+100*(c-d-1))/c:100}}))},d.prototype.openedSource=function(a){if(this.currentSourceOffset=this.bytesWritten,this.currentFile=a.file.name,this.streamFiles&&!a.file.dir){var b=m(a,this.streamFiles,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:b.fileRecord,meta:{percent:0}})}else this.accumulate=!0},d.prototype.closedSource=function(a){this.accumulate=!1;var b=m(a,this.streamFiles,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(b.dirRecord),this.streamFiles&&!a.file.dir)this.push({data:o(a),meta:{percent:100}});else for(this.push({data:b.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},d.prototype.flush=function(){for(var a=this.bytesWritten,b=0;b0?a.substring(0,b):""},q=function(a){return"/"!==a.slice(-1)&&(a+="/"),a},r=function(a,b){return b="undefined"!=typeof b?b:i.createFolders,a=q(a),this.files[a]||o.call(this,a,null,{dir:!0,createFolders:b}),this.files[a]},s={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(a){var b,c,d;for(b in this.files)this.files.hasOwnProperty(b)&&(d=this.files[b],c=b.slice(this.root.length,b.length),c&&b.slice(0,this.root.length)===this.root&&a(c,d))},filter:function(a){var b=[];return this.forEach(function(c,d){a(c,d)&&b.push(d)}),b},file:function(a,b,c){if(1===arguments.length){if(d(a)){var e=a;return this.filter(function(a,b){return!b.dir&&e.test(a)})}var f=this.files[this.root+a];return f&&!f.dir?f:null}return a=this.root+a,o.call(this,a,b,c),this},folder:function(a){if(!a)return this;if(d(a))return this.filter(function(b,c){return c.dir&&a.test(b)});var b=this.root+a,c=r.call(this,b),e=this.clone();return e.root=c.name,e},remove:function(a){a=this.root+a;var b=this.files[a];if(b||("/"!==a.slice(-1)&&(a+="/"),b=this.files[a]),b&&!b.dir)delete this.files[a];else for(var c=this.filter(function(b,c){return c.name.slice(0,a.length)===a}),d=0;d=0;--f)if(this.data[f]===b&&this.data[f+1]===c&&this.data[f+2]===d&&this.data[f+3]===e)return f-this.zero;return-1},d.prototype.readAndCheckSignature=function(a){var b=a.charCodeAt(0),c=a.charCodeAt(1),d=a.charCodeAt(2),e=a.charCodeAt(3),f=this.readData(4);return b===f[0]&&c===f[1]&&d===f[2]&&e===f[3]},d.prototype.readData=function(a){if(this.checkOffset(a),0===a)return[];var b=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,b},b.exports=d},{"../utils":29,"./DataReader":15}],15:[function(a,b,c){"use strict";function d(a){this.data=a,this.length=a.length,this.index=0,this.zero=0}var e=a("../utils");d.prototype={checkOffset:function(a){this.checkIndex(this.index+a)},checkIndex:function(a){if(this.lengtha)throw new Error("End of data reached (data length = "+this.length+", asked index = "+a+"). Corrupted zip ?")},setIndex:function(a){this.checkIndex(a),this.index=a},skip:function(a){this.setIndex(this.index+a)},byteAt:function(a){},readInt:function(a){var b,c=0;for(this.checkOffset(a),b=this.index+a-1;b>=this.index;b--)c=(c<<8)+this.byteAt(b);return this.index+=a,c},readString:function(a){return e.transformTo("string",this.readData(a))},readData:function(a){},lastIndexOfSignature:function(a){},readAndCheckSignature:function(a){},readDate:function(){var a=this.readInt(4);return new Date(Date.UTC((a>>25&127)+1980,(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1))}},b.exports=d},{"../utils":29}],16:[function(a,b,c){"use strict";function d(a){e.call(this,a)}var e=a("./Uint8ArrayReader"),f=a("../utils");f.inherits(d,e),d.prototype.readData=function(a){this.checkOffset(a);var b=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,b},b.exports=d},{"../utils":29,"./Uint8ArrayReader":18}],17:[function(a,b,c){"use strict";function d(a){e.call(this,a)}var e=a("./DataReader"),f=a("../utils");f.inherits(d,e),d.prototype.byteAt=function(a){return this.data.charCodeAt(this.zero+a)},d.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)-this.zero},d.prototype.readAndCheckSignature=function(a){var b=this.readData(4);return a===b},d.prototype.readData=function(a){this.checkOffset(a);var b=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,b},b.exports=d},{"../utils":29,"./DataReader":15}],18:[function(a,b,c){"use strict";function d(a){e.call(this,a)}var e=a("./ArrayReader"),f=a("../utils");f.inherits(d,e),d.prototype.readData=function(a){if(this.checkOffset(a),0===a)return new Uint8Array(0);var b=this.data.subarray(this.zero+this.index,this.zero+this.index+a);return this.index+=a,b},b.exports=d},{"../utils":29,"./ArrayReader":14}],19:[function(a,b,c){"use strict";var d=a("../utils"),e=a("../support"),f=a("./ArrayReader"),g=a("./StringReader"),h=a("./NodeBufferReader"),i=a("./Uint8ArrayReader");b.exports=function(a){var b=d.getTypeOf(a);return d.checkSupport(b),"string"!==b||e.uint8array?"nodebuffer"===b?new h(a):e.uint8array?new i(d.transformTo("uint8array",a)):new f(d.transformTo("array",a)):new g(a)}},{"../support":27,"../utils":29,"./ArrayReader":14,"./NodeBufferReader":16,"./StringReader":17,"./Uint8ArrayReader":18}],20:[function(a,b,c){"use strict";c.LOCAL_FILE_HEADER="PK",c.CENTRAL_FILE_HEADER="PK",c.CENTRAL_DIRECTORY_END="PK",c.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",c.ZIP64_CENTRAL_DIRECTORY_END="PK",c.DATA_DESCRIPTOR="PK\b"},{}],21:[function(a,b,c){"use strict";function d(a){e.call(this,"ConvertWorker to "+a),this.destType=a}var e=a("./GenericWorker"),f=a("../utils");f.inherits(d,e),d.prototype.processChunk=function(a){this.push({data:f.transformTo(this.destType,a.data),meta:a.meta})},b.exports=d},{"../utils":29,"./GenericWorker":25}],22:[function(a,b,c){"use strict";function d(){e.call(this,"Crc32Probe")}var e=a("./GenericWorker"),f=a("../crc32"),g=a("../utils");g.inherits(d,e),d.prototype.processChunk=function(a){this.streamInfo.crc32=f(a.data,this.streamInfo.crc32||0),this.push(a)},b.exports=d},{"../crc32":4,"../utils":29,"./GenericWorker":25}],23:[function(a,b,c){"use strict";function d(a){f.call(this,"DataLengthProbe for "+a),this.propName=a,this.withStreamInfo(a,0)}var e=a("../utils"),f=a("./GenericWorker");e.inherits(d,f),d.prototype.processChunk=function(a){if(a){var b=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=b+a.data.length}f.prototype.processChunk.call(this,a)},b.exports=d},{"../utils":29,"./GenericWorker":25}],24:[function(a,b,c){"use strict";function d(a){f.call(this,"DataWorker");var b=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,a.then(function(a){b.dataIsReady=!0,b.data=a,b.max=a&&a.length||0,b.type=e.getTypeOf(a),b.isPaused||b._tickAndRepeat()},function(a){b.error(a)})}var e=a("../utils"),f=a("./GenericWorker"),g=16384;e.inherits(d,f),d.prototype.cleanUp=function(){f.prototype.cleanUp.call(this),this.data=null},d.prototype.resume=function(){return f.prototype.resume.call(this)?(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,e.delay(this._tickAndRepeat,[],this)),!0):!1},d.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(e.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},d.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var a=g,b=null,c=Math.min(this.max,this.index+a);if(this.index>=this.max)return this.end();switch(this.type){case"string":b=this.data.substring(this.index,c);break;case"uint8array":b=this.data.subarray(this.index,c);break;case"array":case"nodebuffer":b=this.data.slice(this.index,c)}return this.index=c,this.push({data:b,meta:{percent:this.max?this.index/this.max*100:0}})},b.exports=d},{"../utils":29,"./GenericWorker":25}],25:[function(a,b,c){"use strict";function d(a){this.name=a||"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}d.prototype={push:function(a){this.emit("data",a)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(a){this.emit("error",a)}return!0},error:function(a){return this.isFinished?!1:(this.isPaused?this.generatedError=a:(this.isFinished=!0,this.emit("error",a),this.previous&&this.previous.error(a),this.cleanUp()),!0)},on:function(a,b){return this._listeners[a].push(b),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(a,b){if(this._listeners[a])for(var c=0;c "+a:a}},b.exports=d},{}],26:[function(a,b,c){(function(c){"use strict";function d(a,b,c){switch(a){case"blob":return h.newBlob(h.transformTo("arraybuffer",b),c);case"base64":return k.encode(b);default:return h.transformTo(a,b)}}function e(a,b){var d,e=0,f=null,g=0;for(d=0;dk;k++)j[k]=k>=252?6:k>=248?5:k>=240?4:k>=224?3:k>=192?2:1;j[254]=j[254]=1;var l=function(a){var b,c,d,e,f,h=a.length,i=0;for(e=0;h>e;e++)c=a.charCodeAt(e),55296===(64512&c)&&h>e+1&&(d=a.charCodeAt(e+1),56320===(64512&d)&&(c=65536+(c-55296<<10)+(d-56320),e++)),i+=128>c?1:2048>c?2:65536>c?3:4;for(b=g.uint8array?new Uint8Array(i):new Array(i),f=0,e=0;i>f;e++)c=a.charCodeAt(e),55296===(64512&c)&&h>e+1&&(d=a.charCodeAt(e+1),56320===(64512&d)&&(c=65536+(c-55296<<10)+(d-56320),e++)),128>c?b[f++]=c:2048>c?(b[f++]=192|c>>>6,b[f++]=128|63&c):65536>c?(b[f++]=224|c>>>12,b[f++]=128|c>>>6&63,b[f++]=128|63&c):(b[f++]=240|c>>>18,b[f++]=128|c>>>12&63,b[f++]=128|c>>>6&63,b[f++]=128|63&c);return b},m=function(a,b){var c;for(b=b||a.length,b>a.length&&(b=a.length),c=b-1;c>=0&&128===(192&a[c]);)c--;return 0>c?b:0===c?b:c+j[a[c]]>b?c:b},n=function(a){var b,c,d,e,g=a.length,h=new Array(2*g);for(c=0,b=0;g>b;)if(d=a[b++],128>d)h[c++]=d;else if(e=j[d],e>4)h[c++]=65533,b+=e-1;else{for(d&=2===e?31:3===e?15:7;e>1&&g>b;)d=d<<6|63&a[b++],e--;e>1?h[c++]=65533:65536>d?h[c++]=d:(d-=65536,h[c++]=55296|d>>10&1023,h[c++]=56320|1023&d)}return h.length!==c&&(h.subarray?h=h.subarray(0,c):h.length=c),f.applyFromCharCode(h)};c.utf8encode=function(a){return g.nodebuffer?h.newBuffer(a,"utf-8"):l(a)},c.utf8decode=function(a){return g.nodebuffer?f.transformTo("nodebuffer",a).toString("utf-8"):(a=f.transformTo(g.uint8array?"uint8array":"array",a),n(a))},f.inherits(d,i),d.prototype.processChunk=function(a){var b=f.transformTo(g.uint8array?"uint8array":"array",a.data);if(this.leftOver&&this.leftOver.length){if(g.uint8array){var d=b;b=new Uint8Array(d.length+this.leftOver.length),b.set(this.leftOver,0),b.set(d,this.leftOver.length)}else b=this.leftOver.concat(b);this.leftOver=null}var e=m(b),h=b;e!==b.length&&(g.uint8array?(h=b.subarray(0,e),this.leftOver=b.subarray(e,b.length)):(h=b.slice(0,e),this.leftOver=b.slice(e,b.length))),this.push({data:c.utf8decode(h),meta:a.meta})},d.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:c.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},c.Utf8DecodeWorker=d,f.inherits(e,i),e.prototype.processChunk=function(a){this.push({data:c.utf8encode(a.data),meta:a.meta})},c.Utf8EncodeWorker=e},{"./nodejsUtils":12,"./stream/GenericWorker":25,"./support":27,"./utils":29}],29:[function(a,b,c){"use strict";function d(a){var b=null;return b=i.uint8array?new Uint8Array(a.length):new Array(a.length),f(a,b)}function e(a){return a}function f(a,b){for(var c=0;c1;)try{return n.stringifyByChunk(a,d,b)}catch(f){b=Math.floor(b/2)}return n.stringifyByChar(a)}function h(a,b){for(var c=0;c=f)return String.fromCharCode.apply(null,a);for(;f>e;)"array"===b||"nodebuffer"===b?d.push(String.fromCharCode.apply(null,a.slice(e,Math.min(e+c,f)))):d.push(String.fromCharCode.apply(null,a.subarray(e,Math.min(e+c,f)))),e+=c;return d.join("")},stringifyByChar:function(a){for(var b="",c=0;cb?"0":"")+b.toString(16).toUpperCase();return d},c.delay=function(a,b,c){l(function(){a.apply(c||null,b||[])})},c.inherits=function(a,b){var c=function(){};c.prototype=b.prototype,a.prototype=new c},c.extend=function(){var a,b,c={};for(a=0;ae;)a=this.reader.readInt(2),b=this.reader.readInt(4),c=this.reader.readData(b),this.zip64ExtensibleData[a]={id:a,length:b,value:c}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),this.disksCount>1)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var a,b;for(a=0;aa){var b=!this.isSignature(0,g.LOCAL_FILE_HEADER);throw b?new Error("Can't find end of central directory : is this a zip file ? If it is, see http://stuk.github.io/jszip/documentation/howto/read_zip.html"):new Error("Corrupted zip : can't find end of central directory")}this.reader.setIndex(a);var c=a;if(this.checkSignature(g.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===f.MAX_VALUE_16BITS||this.diskWithCentralDirStart===f.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===f.MAX_VALUE_16BITS||this.centralDirRecords===f.MAX_VALUE_16BITS||this.centralDirSize===f.MAX_VALUE_32BITS||this.centralDirOffset===f.MAX_VALUE_32BITS){if(this.zip64=!0,a=this.reader.lastIndexOfSignature(g.ZIP64_CENTRAL_DIRECTORY_LOCATOR),0>a)throw new Error("Corrupted zip : can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(a),this.checkSignature(g.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,g.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(g.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip : can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(g.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var d=this.centralDirOffset+this.centralDirSize;this.zip64&&(d+=20,d+=12+this.zip64EndOfCentralSize);var e=c-d;if(e>0)this.isSignature(c,g.CENTRAL_FILE_HEADER)||(this.reader.zero=e);else if(0>e)throw new Error("Corrupted zip: missing "+Math.abs(e)+" bytes.")},prepareReader:function(a){this.reader=e(a)},load:function(a){this.prepareReader(a),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},b.exports=d},{"./reader/readerFor":19,"./signature":20,"./support":27,"./utf8":28,"./utils":29,"./zipEntry":31}],31:[function(a,b,c){"use strict";function d(a,b){this.options=a,this.loadOptions=b}var e=a("./reader/readerFor"),f=a("./utils"),g=a("./compressedObject"),h=a("./crc32"),i=a("./utf8"),j=a("./compressions"),k=a("./support"),l=0,m=3,n=function(a){for(var b in j)if(j.hasOwnProperty(b)&&j[b].magic===a)return j[b];return null};d.prototype={isEncrypted:function(){return 1===(1&this.bitFlag)},useUTF8:function(){return 2048===(2048&this.bitFlag)},readLocalPart:function(a){var b,c;if(a.skip(22),this.fileNameLength=a.readInt(2),c=a.readInt(2),this.fileName=a.readData(this.fileNameLength),a.skip(c),-1===this.compressedSize||-1===this.uncompressedSize)throw new Error("Bug or corrupted zip : didn't get enough informations from the central directory (compressedSize === -1 || uncompressedSize === -1)");if(b=n(this.compressionMethod),null===b)throw new Error("Corrupted zip : compression "+f.pretty(this.compressionMethod)+" unknown (inner file : "+f.transformTo("string",this.fileName)+")");this.decompressed=new g(this.compressedSize,this.uncompressedSize,this.crc32,b,a.readData(this.compressedSize))},readCentralPart:function(a){this.versionMadeBy=a.readInt(2),a.skip(2),this.bitFlag=a.readInt(2),this.compressionMethod=a.readString(2),this.date=a.readDate(),this.crc32=a.readInt(4),this.compressedSize=a.readInt(4),this.uncompressedSize=a.readInt(4);var b=a.readInt(2);if(this.extraFieldsLength=a.readInt(2),this.fileCommentLength=a.readInt(2),this.diskNumberStart=a.readInt(2),this.internalFileAttributes=a.readInt(2),this.externalFileAttributes=a.readInt(4),this.localHeaderOffset=a.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");a.skip(b),this.readExtraFields(a),this.parseZIP64ExtraField(a),this.fileComment=a.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var a=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),a===l&&(this.dosPermissions=63&this.externalFileAttributes),a===m&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(a){if(this.extraFields[1]){var b=e(this.extraFields[1].value);this.uncompressedSize===f.MAX_VALUE_32BITS&&(this.uncompressedSize=b.readInt(8)),this.compressedSize===f.MAX_VALUE_32BITS&&(this.compressedSize=b.readInt(8)),this.localHeaderOffset===f.MAX_VALUE_32BITS&&(this.localHeaderOffset=b.readInt(8)),this.diskNumberStart===f.MAX_VALUE_32BITS&&(this.diskNumberStart=b.readInt(4))}},readExtraFields:function(a){var b,c,d,e=a.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});a.indexk){for(var b=0,c=h.length-j;c>b;b++)h[b]=h[b+j];h.length-=j,j=0}}h.length=0,j=0,i=!1}function e(a){var b=1,c=new l(a),d=document.createTextNode("");return c.observe(d,{characterData:!0}),function(){b=-b,d.data=b}}function f(a){return function(){function b(){clearTimeout(c),clearInterval(d),a()}var c=setTimeout(b,0),d=setInterval(b,50)}}b.exports=c;var g,h=[],i=!1,j=0,k=1024,l=a.MutationObserver||a.WebKitMutationObserver;g="function"==typeof l?e(d):f(d),c.requestFlush=g,c.makeRequestCallFromTimer=f}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],35:[function(a,b,c){},{}],36:[function(a,b,c){function d(){k=!1,h.length?j=h.concat(j):l=-1,j.length&&e()}function e(){if(!k){var a=setTimeout(d);k=!0;for(var b=j.length;b;){for(h=j,j=[];++l1)for(var c=1;ca;a+=2){var b=ca[a],c=ca[a+1];b(c),ca[a]=void 0,ca[a+1]=void 0}X=0}function q(){try{var a=b,c=a("vertx");return T=c.runOnLoop||c.runOnContext,l()}catch(d){return o()}}function r(){}function s(){return new TypeError("You cannot resolve a promise with itself")}function t(){return new TypeError("A promises callback cannot return that same promise.")}function u(a){try{return a.then}catch(b){return ga.error=b,ga}}function v(a,b,c,d){try{a.call(b,c,d)}catch(e){return e}}function w(a,b,c){Y(function(a){var d=!1,e=v(c,b,function(c){d||(d=!0,b!==c?z(a,c):B(a,c))},function(b){d||(d=!0,C(a,b))},"Settle: "+(a._label||" unknown promise"));!d&&e&&(d=!0,C(a,e))},a)}function x(a,b){b._state===ea?B(a,b._result):b._state===fa?C(a,b._result):D(b,void 0,function(b){z(a,b)},function(b){C(a,b)})}function y(a,b){if(b.constructor===a.constructor)x(a,b);else{var c=u(b);c===ga?C(a,ga.error):void 0===c?B(a,b):g(c)?w(a,b,c):B(a,b)}}function z(a,b){a===b?C(a,s()):f(b)?y(a,b):B(a,b)}function A(a){a._onerror&&a._onerror(a._result),E(a)}function B(a,b){a._state===da&&(a._result=b,a._state=ea,0!==a._subscribers.length&&Y(E,a))}function C(a,b){a._state===da&&(a._state=fa,a._result=b,Y(A,a))}function D(a,b,c,d){var e=a._subscribers,f=e.length;a._onerror=null,e[f]=b,e[f+ea]=c,e[f+fa]=d,0===f&&a._state&&Y(E,a)}function E(a){var b=a._subscribers,c=a._state;if(0!==b.length){for(var d,e,f=a._result,g=0;gg;g++)D(d.resolve(a[g]),void 0,b,c);return e}function M(a){var b=this;if(a&&"object"==typeof a&&a.constructor===b)return a;var c=new b(r);return z(c,a),c}function N(a){var b=this,c=new b(r);return C(c,a),c}function O(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function P(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function Q(a){this._id=na++,this._state=void 0,this._result=void 0,this._subscribers=[],r!==a&&(g(a)||O(),this instanceof Q||P(),I(this,a))}function R(){var a;if("undefined"!=typeof e)a=e;else if("undefined"!=typeof self)a=self;else try{a=Function("return this")()}catch(b){throw new Error("polyfill failed because global object is unavailable in this environment")}var c=a.Promise;c&&"[object Promise]"===Object.prototype.toString.call(c.resolve())&&!c.cast||(a.Promise=oa)}var S;S=Array.isArray?Array.isArray:function(a){return"[object Array]"===Object.prototype.toString.call(a)};var T,U,V,W=S,X=0,Y=({}.toString,function(a,b){ca[X]=a,ca[X+1]=b,X+=2,2===X&&(U?U(p):V())}),Z="undefined"!=typeof window?window:void 0,$=Z||{},_=$.MutationObserver||$.WebKitMutationObserver,aa="undefined"!=typeof d&&"[object process]"==={}.toString.call(d),ba="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,ca=new Array(1e3);V=aa?k():_?m():ba?n():void 0===Z&&"function"==typeof b?q():o();var da=void 0,ea=1,fa=2,ga=new F,ha=new F;J.prototype._validateInput=function(a){return W(a)},J.prototype._validationError=function(){return new Error("Array Methods must be provided an Array")},J.prototype._init=function(){this._result=new Array(this.length)};var ia=J;J.prototype._enumerate=function(){for(var a=this,b=a.length,c=a.promise,d=a._input,e=0;c._state===da&&b>e;e++)a._eachEntry(d[e],e)},J.prototype._eachEntry=function(a,b){var c=this,d=c._instanceConstructor;h(a)?a.constructor===d&&a._state!==da?(a._onerror=null,c._settledAt(a._state,b,a._result)):c._willSettleAt(d.resolve(a),b):(c._remaining--,c._result[b]=a)},J.prototype._settledAt=function(a,b,c){var d=this,e=d.promise;e._state===da&&(d._remaining--,a===fa?C(e,c):d._result[b]=c),0===d._remaining&&B(e,d._result)},J.prototype._willSettleAt=function(a,b){var c=this;D(a,void 0,function(a){c._settledAt(ea,b,a)},function(a){c._settledAt(fa,b,a)})};var ja=K,ka=L,la=M,ma=N,na=0,oa=Q;Q.all=ja,Q.race=ka,Q.resolve=la,Q.reject=ma,Q._setScheduler=i,Q._setAsap=j,Q._asap=Y,Q.prototype={constructor:Q,then:function(a,b){var c=this,d=c._state;if(d===ea&&!a||d===fa&&!b)return this;var e=new this.constructor(r),f=c._result;if(d){var g=arguments[d-1];Y(function(){H(d,e,g,f)})}else D(c,e,a,b);return e},"catch":function(a){return this.then(null,a)}};var pa=R,qa={Promise:oa,polyfill:pa};"function"==typeof a&&a.amd?a(function(){return qa}):"undefined"!=typeof c&&c.exports?c.exports=qa:"undefined"!=typeof this&&(this.ES6Promise=qa),pa()}).call(this)}).call(this,b("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:36}],38:[function(a,b,c){"use strict";var d=a("./lib/utils/common").assign,e=a("./lib/deflate"),f=a("./lib/inflate"),g=a("./lib/zlib/constants"),h={};d(h,e,f,g),b.exports=h},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(a,b,c){"use strict";function d(a){if(!(this instanceof d))return new d(a);this.options=i.assign({level:s,method:u,chunkSize:16384,windowBits:15,memLevel:8,strategy:t,to:""},a||{});var b=this.options;b.raw&&b.windowBits>0?b.windowBits=-b.windowBits:b.gzip&&b.windowBits>0&&b.windowBits<16&&(b.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new l,this.strm.avail_out=0;var c=h.deflateInit2(this.strm,b.level,b.method,b.windowBits,b.memLevel,b.strategy);if(c!==p)throw new Error(k[c]);if(b.header&&h.deflateSetHeader(this.strm,b.header),b.dictionary){var e;if(e="string"==typeof b.dictionary?j.string2buf(b.dictionary):"[object ArrayBuffer]"===m.call(b.dictionary)?new Uint8Array(b.dictionary):b.dictionary,c=h.deflateSetDictionary(this.strm,e),c!==p)throw new Error(k[c]);this._dict_set=!0}}function e(a,b){var c=new d(b);if(c.push(a,!0),c.err)throw c.msg;return c.result}function f(a,b){return b=b||{},b.raw=!0,e(a,b)}function g(a,b){return b=b||{},b.gzip=!0,e(a,b)}var h=a("./zlib/deflate"),i=a("./utils/common"),j=a("./utils/strings"),k=a("./zlib/messages"),l=a("./zlib/zstream"),m=Object.prototype.toString,n=0,o=4,p=0,q=1,r=2,s=-1,t=0,u=8;d.prototype.push=function(a,b){var c,d,e=this.strm,f=this.options.chunkSize;if(this.ended)return!1;d=b===~~b?b:b===!0?o:n,"string"==typeof a?e.input=j.string2buf(a):"[object ArrayBuffer]"===m.call(a)?e.input=new Uint8Array(a):e.input=a,e.next_in=0,e.avail_in=e.input.length;do{if(0===e.avail_out&&(e.output=new i.Buf8(f),e.next_out=0,e.avail_out=f),c=h.deflate(e,d),c!==q&&c!==p)return this.onEnd(c),this.ended=!0,!1;0!==e.avail_out&&(0!==e.avail_in||d!==o&&d!==r)||("string"===this.options.to?this.onData(j.buf2binstring(i.shrinkBuf(e.output,e.next_out))):this.onData(i.shrinkBuf(e.output,e.next_out)))}while((e.avail_in>0||0===e.avail_out)&&c!==q);return d===o?(c=h.deflateEnd(this.strm),this.onEnd(c),this.ended=!0,c===p):d===r?(this.onEnd(p),e.avail_out=0,!0):!0},d.prototype.onData=function(a){this.chunks.push(a)},d.prototype.onEnd=function(a){a===p&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=i.flattenChunks(this.chunks)),this.chunks=[],this.err=a,this.msg=this.strm.msg},c.Deflate=d,c.deflate=e,c.deflateRaw=f,c.gzip=g},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(a,b,c){"use strict";function d(a){if(!(this instanceof d))return new d(a);this.options=h.assign({chunkSize:16384,windowBits:0,to:""},a||{});var b=this.options;b.raw&&b.windowBits>=0&&b.windowBits<16&&(b.windowBits=-b.windowBits,0===b.windowBits&&(b.windowBits=-15)),!(b.windowBits>=0&&b.windowBits<16)||a&&a.windowBits||(b.windowBits+=32),b.windowBits>15&&b.windowBits<48&&0===(15&b.windowBits)&&(b.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new l,this.strm.avail_out=0;var c=g.inflateInit2(this.strm,b.windowBits);if(c!==j.Z_OK)throw new Error(k[c]);this.header=new m,g.inflateGetHeader(this.strm,this.header)}function e(a,b){var c=new d(b);if(c.push(a,!0),c.err)throw c.msg;return c.result}function f(a,b){return b=b||{},b.raw=!0,e(a,b)}var g=a("./zlib/inflate"),h=a("./utils/common"),i=a("./utils/strings"),j=a("./zlib/constants"),k=a("./zlib/messages"),l=a("./zlib/zstream"),m=a("./zlib/gzheader"),n=Object.prototype.toString;d.prototype.push=function(a,b){var c,d,e,f,k,l,m=this.strm,o=this.options.chunkSize,p=this.options.dictionary,q=!1;if(this.ended)return!1;d=b===~~b?b:b===!0?j.Z_FINISH:j.Z_NO_FLUSH,"string"==typeof a?m.input=i.binstring2buf(a):"[object ArrayBuffer]"===n.call(a)?m.input=new Uint8Array(a):m.input=a,m.next_in=0,m.avail_in=m.input.length;do{if(0===m.avail_out&&(m.output=new h.Buf8(o),m.next_out=0,m.avail_out=o),c=g.inflate(m,j.Z_NO_FLUSH),c===j.Z_NEED_DICT&&p&&(l="string"==typeof p?i.string2buf(p):"[object ArrayBuffer]"===n.call(p)?new Uint8Array(p):p,c=g.inflateSetDictionary(this.strm,l)),c===j.Z_BUF_ERROR&&q===!0&&(c=j.Z_OK,q=!1),c!==j.Z_STREAM_END&&c!==j.Z_OK)return this.onEnd(c),this.ended=!0,!1;m.next_out&&(0!==m.avail_out&&c!==j.Z_STREAM_END&&(0!==m.avail_in||d!==j.Z_FINISH&&d!==j.Z_SYNC_FLUSH)||("string"===this.options.to?(e=i.utf8border(m.output,m.next_out),f=m.next_out-e,k=i.buf2string(m.output,e),m.next_out=f,m.avail_out=o-f,f&&h.arraySet(m.output,m.output,e,f,0),this.onData(k)):this.onData(h.shrinkBuf(m.output,m.next_out)))),0===m.avail_in&&0===m.avail_out&&(q=!0)}while((m.avail_in>0||0===m.avail_out)&&c!==j.Z_STREAM_END);return c===j.Z_STREAM_END&&(d=j.Z_FINISH),d===j.Z_FINISH?(c=g.inflateEnd(this.strm),this.onEnd(c),this.ended=!0,c===j.Z_OK):d===j.Z_SYNC_FLUSH?(this.onEnd(j.Z_OK),m.avail_out=0,!0):!0},d.prototype.onData=function(a){this.chunks.push(a)},d.prototype.onEnd=function(a){a===j.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=h.flattenChunks(this.chunks)),this.chunks=[],this.err=a,this.msg=this.strm.msg},c.Inflate=d,c.inflate=e,c.inflateRaw=f,c.ungzip=e},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(a,b,c){"use strict";var d="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;c.assign=function(a){for(var b=Array.prototype.slice.call(arguments,1);b.length;){var c=b.shift();if(c){if("object"!=typeof c)throw new TypeError(c+"must be non-object");for(var d in c)c.hasOwnProperty(d)&&(a[d]=c[d])}}return a},c.shrinkBuf=function(a,b){return a.length===b?a:a.subarray?a.subarray(0,b):(a.length=b,a)};var e={arraySet:function(a,b,c,d,e){if(b.subarray&&a.subarray)return void a.set(b.subarray(c,c+d),e);for(var f=0;d>f;f++)a[e+f]=b[c+f]},flattenChunks:function(a){var b,c,d,e,f,g;for(d=0,b=0,c=a.length;c>b;b++)d+=a[b].length;for(g=new Uint8Array(d),e=0,b=0,c=a.length;c>b;b++)f=a[b],g.set(f,e),e+=f.length;return g}},f={arraySet:function(a,b,c,d,e){for(var f=0;d>f;f++)a[e+f]=b[c+f]},flattenChunks:function(a){return[].concat.apply([],a)}};c.setTyped=function(a){a?(c.Buf8=Uint8Array,c.Buf16=Uint16Array,c.Buf32=Int32Array,c.assign(c,e)):(c.Buf8=Array,c.Buf16=Array,c.Buf32=Array,c.assign(c,f))},c.setTyped(d)},{}],42:[function(a,b,c){"use strict";function d(a,b){if(65537>b&&(a.subarray&&g||!a.subarray&&f))return String.fromCharCode.apply(null,e.shrinkBuf(a,b));for(var c="",d=0;b>d;d++)c+=String.fromCharCode(a[d]);return c}var e=a("./common"),f=!0,g=!0;try{String.fromCharCode.apply(null,[0])}catch(h){f=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(h){g=!1}for(var i=new e.Buf8(256),j=0;256>j;j++)i[j]=j>=252?6:j>=248?5:j>=240?4:j>=224?3:j>=192?2:1;i[254]=i[254]=1,c.string2buf=function(a){var b,c,d,f,g,h=a.length,i=0;for(f=0;h>f;f++)c=a.charCodeAt(f),55296===(64512&c)&&h>f+1&&(d=a.charCodeAt(f+1),56320===(64512&d)&&(c=65536+(c-55296<<10)+(d-56320),f++)),i+=128>c?1:2048>c?2:65536>c?3:4;for(b=new e.Buf8(i),g=0,f=0;i>g;f++)c=a.charCodeAt(f),55296===(64512&c)&&h>f+1&&(d=a.charCodeAt(f+1),56320===(64512&d)&&(c=65536+(c-55296<<10)+(d-56320),f++)),128>c?b[g++]=c:2048>c?(b[g++]=192|c>>>6,b[g++]=128|63&c):65536>c?(b[g++]=224|c>>>12,b[g++]=128|c>>>6&63,b[g++]=128|63&c):(b[g++]=240|c>>>18,b[g++]=128|c>>>12&63,b[g++]=128|c>>>6&63,b[g++]=128|63&c);return b},c.buf2binstring=function(a){return d(a,a.length)},c.binstring2buf=function(a){for(var b=new e.Buf8(a.length),c=0,d=b.length;d>c;c++)b[c]=a.charCodeAt(c);return b},c.buf2string=function(a,b){var c,e,f,g,h=b||a.length,j=new Array(2*h);for(e=0,c=0;h>c;)if(f=a[c++],128>f)j[e++]=f;else if(g=i[f],g>4)j[e++]=65533,c+=g-1;else{for(f&=2===g?31:3===g?15:7;g>1&&h>c;)f=f<<6|63&a[c++],g--;g>1?j[e++]=65533:65536>f?j[e++]=f:(f-=65536,j[e++]=55296|f>>10&1023,j[e++]=56320|1023&f)}return d(j,e)},c.utf8border=function(a,b){var c;for(b=b||a.length,b>a.length&&(b=a.length),c=b-1;c>=0&&128===(192&a[c]);)c--;return 0>c?b:0===c?b:c+i[a[c]]>b?c:b}},{"./common":41}],43:[function(a,b,c){"use strict";function d(a,b,c,d){for(var e=65535&a|0,f=a>>>16&65535|0,g=0;0!==c;){g=c>2e3?2e3:c,c-=g;do e=e+b[d++]|0,f=f+e|0;while(--g);e%=65521,f%=65521}return e|f<<16|0}b.exports=d},{}],44:[function(a,b,c){"use strict";b.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(a,b,c){"use strict";function d(){for(var a,b=[],c=0;256>c;c++){a=c;for(var d=0;8>d;d++)a=1&a?3988292384^a>>>1:a>>>1;b[c]=a}return b}function e(a,b,c,d){var e=f,g=d+c;a^=-1;for(var h=d;g>h;h++)a=a>>>8^e[255&(a^b[h])];return-1^a}var f=d();b.exports=e},{}],46:[function(a,b,c){"use strict";function d(a,b){return a.msg=I[b],b}function e(a){return(a<<1)-(a>4?9:0)}function f(a){for(var b=a.length;--b>=0;)a[b]=0}function g(a){var b=a.state,c=b.pending;c>a.avail_out&&(c=a.avail_out),0!==c&&(E.arraySet(a.output,b.pending_buf,b.pending_out,c,a.next_out),a.next_out+=c,b.pending_out+=c,a.total_out+=c,a.avail_out-=c,b.pending-=c,0===b.pending&&(b.pending_out=0))}function h(a,b){F._tr_flush_block(a,a.block_start>=0?a.block_start:-1,a.strstart-a.block_start,b),a.block_start=a.strstart,g(a.strm)}function i(a,b){a.pending_buf[a.pending++]=b}function j(a,b){a.pending_buf[a.pending++]=b>>>8&255,a.pending_buf[a.pending++]=255&b}function k(a,b,c,d){var e=a.avail_in;return e>d&&(e=d),0===e?0:(a.avail_in-=e,E.arraySet(b,a.input,a.next_in,e,c),1===a.state.wrap?a.adler=G(a.adler,b,e,c):2===a.state.wrap&&(a.adler=H(a.adler,b,e,c)),a.next_in+=e,a.total_in+=e,e)}function l(a,b){var c,d,e=a.max_chain_length,f=a.strstart,g=a.prev_length,h=a.nice_match,i=a.strstart>a.w_size-la?a.strstart-(a.w_size-la):0,j=a.window,k=a.w_mask,l=a.prev,m=a.strstart+ka,n=j[f+g-1],o=j[f+g];a.prev_length>=a.good_match&&(e>>=2),h>a.lookahead&&(h=a.lookahead);do if(c=b,j[c+g]===o&&j[c+g-1]===n&&j[c]===j[f]&&j[++c]===j[f+1]){f+=2,c++;do;while(j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&m>f);if(d=ka-(m-f),f=m-ka,d>g){if(a.match_start=b,g=d,d>=h)break;n=j[f+g-1],o=j[f+g]}}while((b=l[b&k])>i&&0!==--e);return g<=a.lookahead?g:a.lookahead}function m(a){var b,c,d,e,f,g=a.w_size;do{if(e=a.window_size-a.lookahead-a.strstart,a.strstart>=g+(g-la)){E.arraySet(a.window,a.window,g,g,0),a.match_start-=g,a.strstart-=g,a.block_start-=g,c=a.hash_size,b=c;do d=a.head[--b],a.head[b]=d>=g?d-g:0;while(--c);c=g,b=c;do d=a.prev[--b],a.prev[b]=d>=g?d-g:0;while(--c);e+=g}if(0===a.strm.avail_in)break;if(c=k(a.strm,a.window,a.strstart+a.lookahead,e),a.lookahead+=c,a.lookahead+a.insert>=ja)for(f=a.strstart-a.insert,a.ins_h=a.window[f],a.ins_h=(a.ins_h<a.pending_buf_size-5&&(c=a.pending_buf_size-5);;){if(a.lookahead<=1){if(m(a),0===a.lookahead&&b===J)return ua;if(0===a.lookahead)break}a.strstart+=a.lookahead,a.lookahead=0;var d=a.block_start+c;if((0===a.strstart||a.strstart>=d)&&(a.lookahead=a.strstart-d,a.strstart=d,h(a,!1),0===a.strm.avail_out))return ua;if(a.strstart-a.block_start>=a.w_size-la&&(h(a,!1),0===a.strm.avail_out))return ua}return a.insert=0,b===M?(h(a,!0),0===a.strm.avail_out?wa:xa):a.strstart>a.block_start&&(h(a,!1),0===a.strm.avail_out)?ua:ua}function o(a,b){for(var c,d;;){if(a.lookahead=ja&&(a.ins_h=(a.ins_h<=ja)if(d=F._tr_tally(a,a.strstart-a.match_start,a.match_length-ja),a.lookahead-=a.match_length,a.match_length<=a.max_lazy_match&&a.lookahead>=ja){a.match_length--;do a.strstart++,a.ins_h=(a.ins_h<=ja&&(a.ins_h=(a.ins_h<4096)&&(a.match_length=ja-1)),a.prev_length>=ja&&a.match_length<=a.prev_length){e=a.strstart+a.lookahead-ja,d=F._tr_tally(a,a.strstart-1-a.prev_match,a.prev_length-ja),a.lookahead-=a.prev_length-1,a.prev_length-=2;do++a.strstart<=e&&(a.ins_h=(a.ins_h<=ja&&a.strstart>0&&(e=a.strstart-1,d=g[e],d===g[++e]&&d===g[++e]&&d===g[++e])){f=a.strstart+ka;do;while(d===g[++e]&&d===g[++e]&&d===g[++e]&&d===g[++e]&&d===g[++e]&&d===g[++e]&&d===g[++e]&&d===g[++e]&&f>e);a.match_length=ka-(f-e),a.match_length>a.lookahead&&(a.match_length=a.lookahead)}if(a.match_length>=ja?(c=F._tr_tally(a,1,a.match_length-ja),a.lookahead-=a.match_length,a.strstart+=a.match_length,a.match_length=0):(c=F._tr_tally(a,0,a.window[a.strstart]),a.lookahead--,a.strstart++),c&&(h(a,!1),0===a.strm.avail_out))return ua}return a.insert=0,b===M?(h(a,!0),0===a.strm.avail_out?wa:xa):a.last_lit&&(h(a,!1),0===a.strm.avail_out)?ua:va}function r(a,b){for(var c;;){if(0===a.lookahead&&(m(a),0===a.lookahead)){if(b===J)return ua;break}if(a.match_length=0,c=F._tr_tally(a,0,a.window[a.strstart]),a.lookahead--,a.strstart++,c&&(h(a,!1),0===a.strm.avail_out))return ua}return a.insert=0,b===M?(h(a,!0),0===a.strm.avail_out?wa:xa):a.last_lit&&(h(a,!1),0===a.strm.avail_out)?ua:va}function s(a,b,c,d,e){this.good_length=a,this.max_lazy=b,this.nice_length=c,this.max_chain=d,this.func=e}function t(a){a.window_size=2*a.w_size,f(a.head),a.max_lazy_match=D[a.level].max_lazy,a.good_match=D[a.level].good_length,a.nice_match=D[a.level].nice_length,a.max_chain_length=D[a.level].max_chain,a.strstart=0,a.block_start=0,a.lookahead=0,a.insert=0,a.match_length=a.prev_length=ja-1,a.match_available=0,a.ins_h=0}function u(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=$,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new E.Buf16(2*ha),this.dyn_dtree=new E.Buf16(2*(2*fa+1)),this.bl_tree=new E.Buf16(2*(2*ga+1)),f(this.dyn_ltree),f(this.dyn_dtree),f(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new E.Buf16(ia+1),this.heap=new E.Buf16(2*ea+1),f(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new E.Buf16(2*ea+1),f(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function v(a){var b;return a&&a.state?(a.total_in=a.total_out=0,a.data_type=Z,b=a.state,b.pending=0,b.pending_out=0,b.wrap<0&&(b.wrap=-b.wrap),b.status=b.wrap?na:sa,a.adler=2===b.wrap?0:1,b.last_flush=J,F._tr_init(b),O):d(a,Q)}function w(a){var b=v(a);return b===O&&t(a.state),b}function x(a,b){return a&&a.state?2!==a.state.wrap?Q:(a.state.gzhead=b,O):Q}function y(a,b,c,e,f,g){if(!a)return Q;var h=1;if(b===T&&(b=6),0>e?(h=0,e=-e):e>15&&(h=2,e-=16),1>f||f>_||c!==$||8>e||e>15||0>b||b>9||0>g||g>X)return d(a,Q);8===e&&(e=9);var i=new u;return a.state=i,i.strm=a,i.wrap=h,i.gzhead=null,i.w_bits=e,i.w_size=1<>1,i.l_buf=3*i.lit_bufsize,i.level=b,i.strategy=g,i.method=c,w(a)}function z(a,b){return y(a,b,$,aa,ba,Y)}function A(a,b){var c,h,k,l;if(!a||!a.state||b>N||0>b)return a?d(a,Q):Q;if(h=a.state,!a.output||!a.input&&0!==a.avail_in||h.status===ta&&b!==M)return d(a,0===a.avail_out?S:Q);if(h.strm=a,c=h.last_flush,h.last_flush=b,h.status===na)if(2===h.wrap)a.adler=0,i(h,31),i(h,139),i(h,8),h.gzhead?(i(h,(h.gzhead.text?1:0)+(h.gzhead.hcrc?2:0)+(h.gzhead.extra?4:0)+(h.gzhead.name?8:0)+(h.gzhead.comment?16:0)),i(h,255&h.gzhead.time),i(h,h.gzhead.time>>8&255),i(h,h.gzhead.time>>16&255),i(h,h.gzhead.time>>24&255),i(h,9===h.level?2:h.strategy>=V||h.level<2?4:0),i(h,255&h.gzhead.os),h.gzhead.extra&&h.gzhead.extra.length&&(i(h,255&h.gzhead.extra.length),i(h,h.gzhead.extra.length>>8&255)),h.gzhead.hcrc&&(a.adler=H(a.adler,h.pending_buf,h.pending,0)),h.gzindex=0,h.status=oa):(i(h,0),i(h,0),i(h,0),i(h,0),i(h,0),i(h,9===h.level?2:h.strategy>=V||h.level<2?4:0),i(h,ya),h.status=sa);else{var m=$+(h.w_bits-8<<4)<<8,n=-1;n=h.strategy>=V||h.level<2?0:h.level<6?1:6===h.level?2:3,m|=n<<6,0!==h.strstart&&(m|=ma),m+=31-m%31,h.status=sa,j(h,m),0!==h.strstart&&(j(h,a.adler>>>16),j(h,65535&a.adler)),a.adler=1}if(h.status===oa)if(h.gzhead.extra){for(k=h.pending;h.gzindex<(65535&h.gzhead.extra.length)&&(h.pending!==h.pending_buf_size||(h.gzhead.hcrc&&h.pending>k&&(a.adler=H(a.adler,h.pending_buf,h.pending-k,k)),g(a),k=h.pending,h.pending!==h.pending_buf_size));)i(h,255&h.gzhead.extra[h.gzindex]),h.gzindex++;h.gzhead.hcrc&&h.pending>k&&(a.adler=H(a.adler,h.pending_buf,h.pending-k,k)),h.gzindex===h.gzhead.extra.length&&(h.gzindex=0,h.status=pa)}else h.status=pa;if(h.status===pa)if(h.gzhead.name){k=h.pending;do{if(h.pending===h.pending_buf_size&&(h.gzhead.hcrc&&h.pending>k&&(a.adler=H(a.adler,h.pending_buf,h.pending-k,k)),g(a),k=h.pending,h.pending===h.pending_buf_size)){l=1;break}l=h.gzindexk&&(a.adler=H(a.adler,h.pending_buf,h.pending-k,k)),0===l&&(h.gzindex=0,h.status=qa)}else h.status=qa;if(h.status===qa)if(h.gzhead.comment){k=h.pending;do{if(h.pending===h.pending_buf_size&&(h.gzhead.hcrc&&h.pending>k&&(a.adler=H(a.adler,h.pending_buf,h.pending-k,k)),g(a),k=h.pending,h.pending===h.pending_buf_size)){l=1;break}l=h.gzindexk&&(a.adler=H(a.adler,h.pending_buf,h.pending-k,k)),0===l&&(h.status=ra)}else h.status=ra;if(h.status===ra&&(h.gzhead.hcrc?(h.pending+2>h.pending_buf_size&&g(a),h.pending+2<=h.pending_buf_size&&(i(h,255&a.adler),i(h,a.adler>>8&255),a.adler=0,h.status=sa)):h.status=sa),0!==h.pending){if(g(a),0===a.avail_out)return h.last_flush=-1,O}else if(0===a.avail_in&&e(b)<=e(c)&&b!==M)return d(a,S);if(h.status===ta&&0!==a.avail_in)return d(a,S);if(0!==a.avail_in||0!==h.lookahead||b!==J&&h.status!==ta){var o=h.strategy===V?r(h,b):h.strategy===W?q(h,b):D[h.level].func(h,b);if(o!==wa&&o!==xa||(h.status=ta),o===ua||o===wa)return 0===a.avail_out&&(h.last_flush=-1),O;if(o===va&&(b===K?F._tr_align(h):b!==N&&(F._tr_stored_block(h,0,0,!1),b===L&&(f(h.head),0===h.lookahead&&(h.strstart=0,h.block_start=0,h.insert=0))),g(a),0===a.avail_out))return h.last_flush=-1,O}return b!==M?O:h.wrap<=0?P:(2===h.wrap?(i(h,255&a.adler),i(h,a.adler>>8&255),i(h,a.adler>>16&255),i(h,a.adler>>24&255),i(h,255&a.total_in),i(h,a.total_in>>8&255),i(h,a.total_in>>16&255),i(h,a.total_in>>24&255)):(j(h,a.adler>>>16),j(h,65535&a.adler)),g(a),h.wrap>0&&(h.wrap=-h.wrap),0!==h.pending?O:P)}function B(a){var b;return a&&a.state?(b=a.state.status,b!==na&&b!==oa&&b!==pa&&b!==qa&&b!==ra&&b!==sa&&b!==ta?d(a,Q):(a.state=null,b===sa?d(a,R):O)):Q}function C(a,b){var c,d,e,g,h,i,j,k,l=b.length;if(!a||!a.state)return Q;if(c=a.state,g=c.wrap,2===g||1===g&&c.status!==na||c.lookahead)return Q;for(1===g&&(a.adler=G(a.adler,b,l,0)),c.wrap=0,l>=c.w_size&&(0===g&&(f(c.head),c.strstart=0,c.block_start=0,c.insert=0),k=new E.Buf8(c.w_size),E.arraySet(k,b,l-c.w_size,c.w_size,0),b=k,l=c.w_size),h=a.avail_in,i=a.next_in,j=a.input,a.avail_in=l,a.next_in=0,a.input=b,m(c);c.lookahead>=ja;){d=c.strstart,e=c.lookahead-(ja-1);do c.ins_h=(c.ins_h<q&&(p+=B[f++]<>>24,p>>>=w,q-=w,w=v>>>16&255,0===w)C[h++]=65535&v;else{if(!(16&w)){if(0===(64&w)){v=r[(65535&v)+(p&(1<q&&(p+=B[f++]<>>=w,q-=w),15>q&&(p+=B[f++]<>>24,p>>>=w,q-=w,w=v>>>16&255,!(16&w)){if(0===(64&w)){v=s[(65535&v)+(p&(1<q&&(p+=B[f++]<q&&(p+=B[f++]<k){a.msg="invalid distance too far back",c.mode=d;break a}if(p>>>=w,q-=w,w=h-i,y>w){if(w=y-w,w>m&&c.sane){a.msg="invalid distance too far back",c.mode=d;break a}if(z=0,A=o,0===n){if(z+=l-w,x>w){x-=w;do C[h++]=o[z++];while(--w);z=h-y,A=C}}else if(w>n){if(z+=l+n-w,w-=n,x>w){x-=w;do C[h++]=o[z++];while(--w);if(z=0,x>n){w=n,x-=w;do C[h++]=o[z++];while(--w);z=h-y,A=C}}}else if(z+=n-w,x>w){x-=w;do C[h++]=o[z++];while(--w);z=h-y,A=C}for(;x>2;)C[h++]=A[z++],C[h++]=A[z++],C[h++]=A[z++],x-=3;x&&(C[h++]=A[z++],x>1&&(C[h++]=A[z++]))}else{z=h-y;do C[h++]=C[z++],C[h++]=C[z++],C[h++]=C[z++],x-=3;while(x>2);x&&(C[h++]=C[z++],x>1&&(C[h++]=C[z++]))}break}}break}}while(g>f&&j>h);x=q>>3,f-=x,q-=x<<3,p&=(1<f?5+(g-f):5-(f-g),a.avail_out=j>h?257+(j-h):257-(h-j),c.hold=p,c.bits=q}},{}],49:[function(a,b,c){"use strict";function d(a){return(a>>>24&255)+(a>>>8&65280)+((65280&a)<<8)+((255&a)<<24)}function e(){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 s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function f(a){var b;return a&&a.state?(b=a.state,a.total_in=a.total_out=b.total=0,a.msg="",b.wrap&&(a.adler=1&b.wrap),b.mode=L,b.last=0,b.havedict=0,b.dmax=32768,b.head=null,b.hold=0,b.bits=0,b.lencode=b.lendyn=new s.Buf32(pa),b.distcode=b.distdyn=new s.Buf32(qa),b.sane=1,b.back=-1,D):G}function g(a){var b;return a&&a.state?(b=a.state,b.wsize=0,b.whave=0,b.wnext=0,f(a)):G}function h(a,b){var c,d;return a&&a.state?(d=a.state,0>b?(c=0,b=-b):(c=(b>>4)+1,48>b&&(b&=15)),b&&(8>b||b>15)?G:(null!==d.window&&d.wbits!==b&&(d.window=null),d.wrap=c,d.wbits=b,g(a))):G}function i(a,b){var c,d;return a?(d=new e,a.state=d,d.window=null,c=h(a,b),c!==D&&(a.state=null),c):G}function j(a){return i(a,sa)}function k(a){if(ta){var b;for(q=new s.Buf32(512),r=new s.Buf32(32),b=0;144>b;)a.lens[b++]=8;for(;256>b;)a.lens[b++]=9;for(;280>b;)a.lens[b++]=7;for(;288>b;)a.lens[b++]=8;for(w(y,a.lens,0,288,q,0,a.work,{bits:9}),b=0;32>b;)a.lens[b++]=5;w(z,a.lens,0,32,r,0,a.work,{bits:5}),ta=!1}a.lencode=q,a.lenbits=9,a.distcode=r,a.distbits=5}function l(a,b,c,d){var e,f=a.state;return null===f.window&&(f.wsize=1<=f.wsize?(s.arraySet(f.window,b,c-f.wsize,f.wsize,0),f.wnext=0,f.whave=f.wsize):(e=f.wsize-f.wnext,e>d&&(e=d),s.arraySet(f.window,b,c-d,e,f.wnext),d-=e,d?(s.arraySet(f.window,b,c-d,d,0),f.wnext=d,f.whave=f.wsize):(f.wnext+=e,f.wnext===f.wsize&&(f.wnext=0),f.whaven;){if(0===i)break a;i--,m+=e[g++]<>>8&255,c.check=u(c.check,Ba,2,0),m=0,n=0,c.mode=M;break}if(c.flags=0,c.head&&(c.head.done=!1),!(1&c.wrap)||(((255&m)<<8)+(m>>8))%31){a.msg="incorrect header check",c.mode=ma;break}if((15&m)!==K){a.msg="unknown compression method",c.mode=ma;break}if(m>>>=4,n-=4,wa=(15&m)+8,0===c.wbits)c.wbits=wa;else if(wa>c.wbits){a.msg="invalid window size",c.mode=ma;break}c.dmax=1<n;){if(0===i)break a;i--,m+=e[g++]<>8&1),512&c.flags&&(Ba[0]=255&m,Ba[1]=m>>>8&255,c.check=u(c.check,Ba,2,0)),m=0,n=0,c.mode=N;case N:for(;32>n;){if(0===i)break a;i--,m+=e[g++]<>>8&255,Ba[2]=m>>>16&255,Ba[3]=m>>>24&255,c.check=u(c.check,Ba,4,0)),m=0,n=0,c.mode=O;case O:for(;16>n;){if(0===i)break a;i--,m+=e[g++]<>8),512&c.flags&&(Ba[0]=255&m,Ba[1]=m>>>8&255,c.check=u(c.check,Ba,2,0)),m=0,n=0,c.mode=P;case P:if(1024&c.flags){for(;16>n;){if(0===i)break a;i--,m+=e[g++]<>>8&255,c.check=u(c.check,Ba,2,0)),m=0,n=0}else c.head&&(c.head.extra=null);c.mode=Q;case Q:if(1024&c.flags&&(q=c.length,q>i&&(q=i),q&&(c.head&&(wa=c.head.extra_len-c.length,c.head.extra||(c.head.extra=new Array(c.head.extra_len)),s.arraySet(c.head.extra,e,g,q,wa)),512&c.flags&&(c.check=u(c.check,e,q,g)),i-=q,g+=q,c.length-=q),c.length))break a;c.length=0,c.mode=R;case R:if(2048&c.flags){if(0===i)break a;q=0;do wa=e[g+q++],c.head&&wa&&c.length<65536&&(c.head.name+=String.fromCharCode(wa));while(wa&&i>q);if(512&c.flags&&(c.check=u(c.check,e,q,g)),i-=q,g+=q,wa)break a}else c.head&&(c.head.name=null);c.length=0,c.mode=S;case S:if(4096&c.flags){if(0===i)break a;q=0;do wa=e[g+q++],c.head&&wa&&c.length<65536&&(c.head.comment+=String.fromCharCode(wa));while(wa&&i>q);if(512&c.flags&&(c.check=u(c.check,e,q,g)),i-=q,g+=q,wa)break a}else c.head&&(c.head.comment=null);c.mode=T;case T:if(512&c.flags){for(;16>n;){if(0===i)break a;i--,m+=e[g++]<>9&1,c.head.done=!0),a.adler=c.check=0,c.mode=W;break;case U:for(;32>n;){if(0===i)break a;i--,m+=e[g++]<>>=7&n,n-=7&n,c.mode=ja;break}for(;3>n;){if(0===i)break a;i--,m+=e[g++]<>>=1,n-=1,3&m){case 0:c.mode=Y;break;case 1:if(k(c),c.mode=ca,b===C){m>>>=2,n-=2;break a}break;case 2:c.mode=_;break;case 3:a.msg="invalid block type",c.mode=ma}m>>>=2,n-=2;break;case Y:for(m>>>=7&n,n-=7&n;32>n;){if(0===i)break a;i--,m+=e[g++]<>>16^65535)){a.msg="invalid stored block lengths",c.mode=ma;break}if(c.length=65535&m,m=0,n=0,c.mode=Z,b===C)break a;case Z:c.mode=$;case $:if(q=c.length){if(q>i&&(q=i),q>j&&(q=j),0===q)break a;s.arraySet(f,e,g,q,h),i-=q,g+=q,j-=q,h+=q,c.length-=q;break}c.mode=W;break;case _:for(;14>n;){if(0===i)break a;i--,m+=e[g++]<>>=5,n-=5,c.ndist=(31&m)+1,m>>>=5,n-=5,c.ncode=(15&m)+4,m>>>=4,n-=4,c.nlen>286||c.ndist>30){a.msg="too many length or distance symbols",c.mode=ma;break}c.have=0,c.mode=aa;case aa:for(;c.haven;){if(0===i)break a;i--,m+=e[g++]<>>=3,n-=3}for(;c.have<19;)c.lens[Ca[c.have++]]=0;if(c.lencode=c.lendyn,c.lenbits=7,ya={bits:c.lenbits},xa=w(x,c.lens,0,19,c.lencode,0,c.work,ya),c.lenbits=ya.bits,xa){a.msg="invalid code lengths set",c.mode=ma;break}c.have=0,c.mode=ba;case ba:for(;c.have>>24,ra=Aa>>>16&255,sa=65535&Aa,!(n>=qa);){if(0===i)break a;i--,m+=e[g++]<sa)m>>>=qa,n-=qa,c.lens[c.have++]=sa;else{if(16===sa){for(za=qa+2;za>n;){if(0===i)break a;i--,m+=e[g++]<>>=qa,n-=qa,0===c.have){a.msg="invalid bit length repeat",c.mode=ma;break}wa=c.lens[c.have-1],q=3+(3&m),m>>>=2,n-=2}else if(17===sa){for(za=qa+3;za>n;){if(0===i)break a;i--,m+=e[g++]<>>=qa,n-=qa,wa=0,q=3+(7&m),m>>>=3,n-=3}else{for(za=qa+7;za>n;){if(0===i)break a;i--,m+=e[g++]<>>=qa,n-=qa,wa=0,q=11+(127&m),m>>>=7,n-=7}if(c.have+q>c.nlen+c.ndist){a.msg="invalid bit length repeat",c.mode=ma;break}for(;q--;)c.lens[c.have++]=wa}}if(c.mode===ma)break;if(0===c.lens[256]){a.msg="invalid code -- missing end-of-block",c.mode=ma;break}if(c.lenbits=9,ya={bits:c.lenbits},xa=w(y,c.lens,0,c.nlen,c.lencode,0,c.work,ya),c.lenbits=ya.bits,xa){a.msg="invalid literal/lengths set",c.mode=ma;break}if(c.distbits=6,c.distcode=c.distdyn,ya={bits:c.distbits},xa=w(z,c.lens,c.nlen,c.ndist,c.distcode,0,c.work,ya),c.distbits=ya.bits,xa){a.msg="invalid distances set",c.mode=ma;break}if(c.mode=ca,b===C)break a;case ca:c.mode=da;case da:if(i>=6&&j>=258){a.next_out=h,a.avail_out=j,a.next_in=g,a.avail_in=i,c.hold=m,c.bits=n,v(a,p),h=a.next_out,f=a.output,j=a.avail_out,g=a.next_in,e=a.input,i=a.avail_in,m=c.hold,n=c.bits,c.mode===W&&(c.back=-1);break}for(c.back=0;Aa=c.lencode[m&(1<>>24,ra=Aa>>>16&255,sa=65535&Aa,!(n>=qa);){if(0===i)break a;i--,m+=e[g++]<>ta)],qa=Aa>>>24,ra=Aa>>>16&255,sa=65535&Aa,!(n>=ta+qa);){if(0===i)break a;i--,m+=e[g++]<>>=ta,n-=ta,c.back+=ta}if(m>>>=qa,n-=qa,c.back+=qa,c.length=sa,0===ra){c.mode=ia;break}if(32&ra){c.back=-1,c.mode=W;break}if(64&ra){a.msg="invalid literal/length code",c.mode=ma;break}c.extra=15&ra,c.mode=ea;case ea:if(c.extra){for(za=c.extra;za>n;){if(0===i)break a;i--,m+=e[g++]<>>=c.extra,n-=c.extra,c.back+=c.extra}c.was=c.length,c.mode=fa;case fa:for(;Aa=c.distcode[m&(1<>>24,ra=Aa>>>16&255,sa=65535&Aa,!(n>=qa);){if(0===i)break a;i--,m+=e[g++]<>ta)],qa=Aa>>>24,ra=Aa>>>16&255,sa=65535&Aa,!(n>=ta+qa);){if(0===i)break a;i--,m+=e[g++]<>>=ta,n-=ta,c.back+=ta}if(m>>>=qa,n-=qa,c.back+=qa,64&ra){a.msg="invalid distance code",c.mode=ma;break}c.offset=sa,c.extra=15&ra,c.mode=ga;case ga:if(c.extra){for(za=c.extra;za>n;){if(0===i)break a;i--,m+=e[g++]<>>=c.extra,n-=c.extra,c.back+=c.extra}if(c.offset>c.dmax){a.msg="invalid distance too far back",c.mode=ma;break}c.mode=ha;case ha:if(0===j)break a;if(q=p-j,c.offset>q){if(q=c.offset-q,q>c.whave&&c.sane){a.msg="invalid distance too far back",c.mode=ma;break}q>c.wnext?(q-=c.wnext,r=c.wsize-q):r=c.wnext-q,q>c.length&&(q=c.length),pa=c.window}else pa=f,r=h-c.offset,q=c.length;q>j&&(q=j),j-=q,c.length-=q;do f[h++]=pa[r++];while(--q);0===c.length&&(c.mode=da);break;case ia:if(0===j)break a;f[h++]=c.length,j--,c.mode=da;break;case ja:if(c.wrap){for(;32>n;){if(0===i)break a;i--,m|=e[g++]<n;){if(0===i)break a;i--,m+=e[g++]<=D;D++)P[D]=0;for(E=0;o>E;E++)P[b[c+E]]++;for(H=C,G=e;G>=1&&0===P[G];G--);if(H>G&&(H=G),0===G)return p[q++]=20971520,p[q++]=20971520,s.bits=1,0;for(F=1;G>F&&0===P[F];F++);for(F>H&&(H=F),K=1,D=1;e>=D;D++)if(K<<=1,K-=P[D],0>K)return-1;if(K>0&&(a===h||1!==G))return-1;for(Q[1]=0,D=1;e>D;D++)Q[D+1]=Q[D]+P[D];for(E=0;o>E;E++)0!==b[c+E]&&(r[Q[b[c+E]]++]=E);if(a===h?(N=R=r,y=19):a===i?(N=k,O-=257,R=l,S-=257,y=256):(N=m,R=n,y=-1),M=0,E=0,D=F,x=q,I=H,J=0,v=-1,L=1<f||a===j&&L>g)return 1;for(var T=0;;){T++,z=D-J,r[E]y?(A=R[S+r[E]],B=N[O+r[E]]):(A=96,B=0),t=1<>J)+u]=z<<24|A<<16|B|0;while(0!==u);for(t=1<>=1;if(0!==t?(M&=t-1,M+=t):M=0,E++,0===--P[D]){if(D===G)break;D=b[c+r[E]]}if(D>H&&(M&w)!==v){for(0===J&&(J=H),x+=F,I=D-J,K=1<I+J&&(K-=P[I+J],!(0>=K));)I++,K<<=1;if(L+=1<f||a===j&&L>g)return 1;v=M&w,p[v]=H<<24|I<<16|x-q|0}}return 0!==M&&(p[x+M]=D-J<<24|64<<16|0),s.bits=H,0}},{"../utils/common":41}],51:[function(a,b,c){"use strict";b.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(a,b,c){"use strict";function d(a){for(var b=a.length;--b>=0;)a[b]=0}function e(a,b,c,d,e){this.static_tree=a,this.extra_bits=b,this.extra_base=c,this.elems=d,this.max_length=e,this.has_stree=a&&a.length}function f(a,b){this.dyn_tree=a,this.max_code=0,this.stat_desc=b}function g(a){return 256>a?ia[a]:ia[256+(a>>>7)]}function h(a,b){a.pending_buf[a.pending++]=255&b,a.pending_buf[a.pending++]=b>>>8&255}function i(a,b,c){a.bi_valid>X-c?(a.bi_buf|=b<>X-a.bi_valid,a.bi_valid+=c-X):(a.bi_buf|=b<>>=1,c<<=1;while(--b>0);return c>>>1}function l(a){16===a.bi_valid?(h(a,a.bi_buf),a.bi_buf=0,a.bi_valid=0):a.bi_valid>=8&&(a.pending_buf[a.pending++]=255&a.bi_buf,a.bi_buf>>=8,a.bi_valid-=8)}function m(a,b){var c,d,e,f,g,h,i=b.dyn_tree,j=b.max_code,k=b.stat_desc.static_tree,l=b.stat_desc.has_stree,m=b.stat_desc.extra_bits,n=b.stat_desc.extra_base,o=b.stat_desc.max_length,p=0;for(f=0;W>=f;f++)a.bl_count[f]=0;for(i[2*a.heap[a.heap_max]+1]=0,c=a.heap_max+1;V>c;c++)d=a.heap[c],f=i[2*i[2*d+1]+1]+1,f>o&&(f=o,p++),i[2*d+1]=f,d>j||(a.bl_count[f]++,g=0,d>=n&&(g=m[d-n]),h=i[2*d],a.opt_len+=h*(f+g),l&&(a.static_len+=h*(k[2*d+1]+g)));if(0!==p){do{for(f=o-1;0===a.bl_count[f];)f--;a.bl_count[f]--,a.bl_count[f+1]+=2,a.bl_count[o]--,p-=2}while(p>0);for(f=o;0!==f;f--)for(d=a.bl_count[f];0!==d;)e=a.heap[--c],e>j||(i[2*e+1]!==f&&(a.opt_len+=(f-i[2*e+1])*i[2*e],i[2*e+1]=f),d--)}}function n(a,b,c){var d,e,f=new Array(W+1),g=0;for(d=1;W>=d;d++)f[d]=g=g+c[d-1]<<1;for(e=0;b>=e;e++){var h=a[2*e+1];0!==h&&(a[2*e]=k(f[h]++,h))}}function o(){var a,b,c,d,f,g=new Array(W+1);for(c=0,d=0;Q-1>d;d++)for(ka[d]=c,a=0;a<1<d;d++)for(la[d]=f,a=0;a<1<>=7;T>d;d++)for(la[d]=f<<7,a=0;a<1<=b;b++)g[b]=0;for(a=0;143>=a;)ga[2*a+1]=8,a++,g[8]++;for(;255>=a;)ga[2*a+1]=9,a++,g[9]++;for(;279>=a;)ga[2*a+1]=7,a++,g[7]++;for(;287>=a;)ga[2*a+1]=8,a++,g[8]++;for(n(ga,S+1,g),a=0;T>a;a++)ha[2*a+1]=5,ha[2*a]=k(a,5);ma=new e(ga,ba,R+1,S,W),na=new e(ha,ca,0,T,W),oa=new e(new Array(0),da,0,U,Y)}function p(a){var b;for(b=0;S>b;b++)a.dyn_ltree[2*b]=0;for(b=0;T>b;b++)a.dyn_dtree[2*b]=0;for(b=0;U>b;b++)a.bl_tree[2*b]=0;a.dyn_ltree[2*Z]=1,a.opt_len=a.static_len=0,a.last_lit=a.matches=0}function q(a){a.bi_valid>8?h(a,a.bi_buf):a.bi_valid>0&&(a.pending_buf[a.pending++]=a.bi_buf),a.bi_buf=0,a.bi_valid=0}function r(a,b,c,d){q(a),d&&(h(a,c),h(a,~c)),G.arraySet(a.pending_buf,a.window,b,c,a.pending),a.pending+=c}function s(a,b,c,d){var e=2*b,f=2*c;return a[e]c;c++)0!==f[2*c]?(a.heap[++a.heap_len]=j=c,a.depth[c]=0):f[2*c+1]=0;for(;a.heap_len<2;)e=a.heap[++a.heap_len]=2>j?++j:0,f[2*e]=1,a.depth[e]=0,a.opt_len--,h&&(a.static_len-=g[2*e+1]);for(b.max_code=j,c=a.heap_len>>1;c>=1;c--)t(a,f,c);e=i;do c=a.heap[1],a.heap[1]=a.heap[a.heap_len--],t(a,f,1),d=a.heap[1],a.heap[--a.heap_max]=c,a.heap[--a.heap_max]=d,f[2*e]=f[2*c]+f[2*d],a.depth[e]=(a.depth[c]>=a.depth[d]?a.depth[c]:a.depth[d])+1,f[2*c+1]=f[2*d+1]=e,a.heap[1]=e++,t(a,f,1);while(a.heap_len>=2);a.heap[--a.heap_max]=a.heap[1],m(a,b),n(f,j,a.bl_count)}function w(a,b,c){var d,e,f=-1,g=b[1],h=0,i=7,j=4;for(0===g&&(i=138,j=3),b[2*(c+1)+1]=65535,d=0;c>=d;d++)e=g,g=b[2*(d+1)+1], 15 | ++hh?a.bl_tree[2*e]+=h:0!==e?(e!==f&&a.bl_tree[2*e]++,a.bl_tree[2*$]++):10>=h?a.bl_tree[2*_]++:a.bl_tree[2*aa]++,h=0,f=e,0===g?(i=138,j=3):e===g?(i=6,j=3):(i=7,j=4))}function x(a,b,c){var d,e,f=-1,g=b[1],h=0,k=7,l=4;for(0===g&&(k=138,l=3),d=0;c>=d;d++)if(e=g,g=b[2*(d+1)+1],!(++hh){do j(a,e,a.bl_tree);while(0!==--h)}else 0!==e?(e!==f&&(j(a,e,a.bl_tree),h--),j(a,$,a.bl_tree),i(a,h-3,2)):10>=h?(j(a,_,a.bl_tree),i(a,h-3,3)):(j(a,aa,a.bl_tree),i(a,h-11,7));h=0,f=e,0===g?(k=138,l=3):e===g?(k=6,l=3):(k=7,l=4)}}function y(a){var b;for(w(a,a.dyn_ltree,a.l_desc.max_code),w(a,a.dyn_dtree,a.d_desc.max_code),v(a,a.bl_desc),b=U-1;b>=3&&0===a.bl_tree[2*ea[b]+1];b--);return a.opt_len+=3*(b+1)+5+5+4,b}function z(a,b,c,d){var e;for(i(a,b-257,5),i(a,c-1,5),i(a,d-4,4),e=0;d>e;e++)i(a,a.bl_tree[2*ea[e]+1],3);x(a,a.dyn_ltree,b-1),x(a,a.dyn_dtree,c-1)}function A(a){var b,c=4093624447;for(b=0;31>=b;b++,c>>>=1)if(1&c&&0!==a.dyn_ltree[2*b])return I;if(0!==a.dyn_ltree[18]||0!==a.dyn_ltree[20]||0!==a.dyn_ltree[26])return J;for(b=32;R>b;b++)if(0!==a.dyn_ltree[2*b])return J;return I}function B(a){pa||(o(),pa=!0),a.l_desc=new f(a.dyn_ltree,ma),a.d_desc=new f(a.dyn_dtree,na),a.bl_desc=new f(a.bl_tree,oa),a.bi_buf=0,a.bi_valid=0,p(a)}function C(a,b,c,d){i(a,(L<<1)+(d?1:0),3),r(a,b,c,!0)}function D(a){i(a,M<<1,3),j(a,Z,ga),l(a)}function E(a,b,c,d){var e,f,g=0;a.level>0?(a.strm.data_type===K&&(a.strm.data_type=A(a)),v(a,a.l_desc),v(a,a.d_desc),g=y(a),e=a.opt_len+3+7>>>3,f=a.static_len+3+7>>>3,e>=f&&(e=f)):e=f=c+5,e>=c+4&&-1!==b?C(a,b,c,d):a.strategy===H||f===e?(i(a,(M<<1)+(d?1:0),3),u(a,ga,ha)):(i(a,(N<<1)+(d?1:0),3),z(a,a.l_desc.max_code+1,a.d_desc.max_code+1,g+1),u(a,a.dyn_ltree,a.dyn_dtree)),p(a),d&&q(a)}function F(a,b,c){return a.pending_buf[a.d_buf+2*a.last_lit]=b>>>8&255,a.pending_buf[a.d_buf+2*a.last_lit+1]=255&b,a.pending_buf[a.l_buf+a.last_lit]=255&c,a.last_lit++,0===b?a.dyn_ltree[2*c]++:(a.matches++,b--,a.dyn_ltree[2*(ja[c]+R+1)]++,a.dyn_dtree[2*g(b)]++),a.last_lit===a.lit_bufsize-1}var G=a("../utils/common"),H=4,I=0,J=1,K=2,L=0,M=1,N=2,O=3,P=258,Q=29,R=256,S=R+1+Q,T=30,U=19,V=2*S+1,W=15,X=16,Y=7,Z=256,$=16,_=17,aa=18,ba=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],ca=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],da=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],ea=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],fa=512,ga=new Array(2*(S+2));d(ga);var ha=new Array(2*T);d(ha);var ia=new Array(fa);d(ia);var ja=new Array(P-O+1);d(ja);var ka=new Array(Q);d(ka);var la=new Array(T);d(la);var ma,na,oa,pa=!1;c._tr_init=B,c._tr_stored_block=C,c._tr_flush_block=E,c._tr_tally=F,c._tr_align=D},{"../utils/common":41}],53:[function(a,b,c){"use strict";function d(){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}b.exports=d},{}]},{},[10])(10)}); -------------------------------------------------------------------------------- /js/content/keysync.js: -------------------------------------------------------------------------------- 1 | 2 | window.ACCESS_TOKEN_COOKIE_NAME = '_gitzip_token'; 3 | 4 | function _getCookie(name) { 5 | var value = "; " + document.cookie; 6 | var parts = value.split("; " + name + "="); 7 | if (parts.length == 2) return parts.pop().split(";").shift(); 8 | return null; 9 | } 10 | 11 | chrome.runtime.sendMessage({action: "getKey"}, function(response){ 12 | if(typeof response == 'string' && !response){ 13 | // means not exist in extension 14 | var val = _getCookie(window.ACCESS_TOKEN_COOKIE_NAME); 15 | if(val){ 16 | // exist 17 | chrome.runtime.sendMessage({action: "setKey", value: val}, function(response){ 18 | window.alert(response || "Token has sync to GitZip Extension"); 19 | }); 20 | }else{ 21 | // not exist in kinolien.github.io/gitzip/ 22 | } 23 | } 24 | }); 25 | -------------------------------------------------------------------------------- /js/content/main.js: -------------------------------------------------------------------------------- 1 | // It would work on github.com 2 | var repoExp = new RegExp("^https://github.com/([^/]+)/([^/]+)(/(tree|blob)/([^/]+)(/(.*))?)?"); 3 | // For the request callback end point detection 4 | var repoCommitExp = new RegExp("^https://github.com/([^/]+)/([^/]+)/commit/.*"); 5 | 6 | var isStorageCallback = false; 7 | 8 | var isDark = window.matchMedia('(prefers-color-scheme: dark)').matches; 9 | 10 | // default 11 | // var selectBehaviour = "both"; 12 | var isOnlyDoubleClick = false; 13 | var isOnlySingleCheck = false; 14 | var isBoth = true; 15 | 16 | const defaultOptions = { 17 | selectBehaviour: 'both', 18 | theme: 'default' 19 | }; 20 | 21 | /** 22 | * Resolve the github repo url for recognize author, project name, branch name, and so on. 23 | * @private 24 | * @param {string} repoUrl - The github repo url. 25 | * @param {ResolvedURL} 26 | */ 27 | function resolveUrl(repoUrl){ 28 | if(typeof repoUrl != 'string') return false; 29 | var matches = repoUrl.match(repoExp); 30 | if(matches && matches.length > 0){ 31 | var rootUrl = (matches[5])? 32 | "https://github.com/" + matches[1] + "/" + matches[2] + "/tree/" + matches[5] : 33 | "https://github.com/" + matches[1] + "/" + matches[2]; 34 | 35 | var strType = matches[4]; 36 | if ( !strType && (repoUrl.length - rootUrl.length > 1) ) { // means no type and url different with root 37 | return false; 38 | } 39 | 40 | return { 41 | author: matches[1], 42 | project: matches[2], 43 | branch: matches[5], 44 | type: matches[4], 45 | path: matches[7] || '', 46 | inputUrl: repoUrl, 47 | rootUrl: rootUrl 48 | }; 49 | } 50 | return false; 51 | } 52 | 53 | // https://api.github.com/repos/peers/peerjs/git/trees/bfd406219ffd35f4ad870638f2180b27b4e9c374 54 | function getGitUrl(author, project, type, sha){ 55 | if(type == "blob" || type == "tree"){ 56 | type += "s"; 57 | return ["https://api.github.com/repos", author, project, "git", type, sha].join('/'); 58 | }else return false; 59 | } 60 | 61 | function getInfoUrl(author, project, path, branch) { 62 | return "https://api.github.com/repos/" 63 | + author + "/" + project + "/contents/" 64 | + path + (branch ? ("?ref=" + branch) : ""); 65 | } 66 | 67 | function base64toBlob(base64Data, contentType) { 68 | contentType = contentType || ''; 69 | var sliceSize = 1024; 70 | var byteCharacters = atob(base64Data); 71 | var bytesLength = byteCharacters.length; 72 | var slicesCount = Math.ceil(bytesLength / sliceSize); 73 | var byteArrays = new Array(slicesCount); 74 | 75 | for (var sliceIndex = 0; sliceIndex < slicesCount; ++sliceIndex) { 76 | var begin = sliceIndex * sliceSize; 77 | var end = Math.min(begin + sliceSize, bytesLength); 78 | 79 | var bytes = new Array(end - begin); 80 | for (var offset = begin, i = 0; offset < end; ++i, ++offset) { 81 | bytes[i] = byteCharacters[offset].charCodeAt(0); 82 | } 83 | byteArrays[sliceIndex] = new Uint8Array(bytes); 84 | } 85 | return new Blob(byteArrays, { type: contentType }); 86 | } 87 | 88 | function zipContents(filename, contents){ 89 | var currDate = new Date(); 90 | var dateWithOffset = new Date(currDate.getTime() - currDate.getTimezoneOffset() * 60000); 91 | // replace the default date with dateWithOffset 92 | JSZip.defaults.date = dateWithOffset; 93 | 94 | var zip = new JSZip(); 95 | contents.forEach(function(item){ 96 | zip.file(item.path, item.content, {createFolders:true,base64:true}); 97 | }); 98 | return new Promise(function(res, rej){ 99 | zip.generateAsync({type:"blob"}) 100 | .then(function (content) { 101 | saveAs(content, filename + ".zip"); 102 | res(); 103 | }, function(error){ 104 | console.log(error); 105 | rej(error); 106 | }); 107 | }); 108 | }; 109 | 110 | function callAjax(url, token){ 111 | return new Promise(function(resolve, reject){ 112 | var xmlhttp; 113 | // compatible with IE7+, Firefox, Chrome, Opera, Safari 114 | xmlhttp = new XMLHttpRequest(); 115 | xmlhttp.onreadystatechange = function(){ 116 | if (xmlhttp.readyState == 4){ 117 | if(xmlhttp.status == 200){ 118 | resolve(xmlhttp); 119 | }else if(xmlhttp.status >= 400){ 120 | reject(xmlhttp); 121 | } 122 | } 123 | } 124 | xmlhttp.responseType = "json"; 125 | xmlhttp.open("GET", url, true); 126 | if ( token ) xmlhttp.setRequestHeader("Authorization", "token " + token); 127 | xmlhttp.send(); 128 | }); 129 | } 130 | 131 | 132 | // var reposSplitContentSelector = "[data-selector='repos-split-pane-content']"; 133 | var upfolderItemSelector = "table tbody tr.react-directory-row > td[class$='cell-large-screen']"; 134 | var itemCollectSelector = "div.js-navigation-item, " + upfolderItemSelector; 135 | 136 | var closestRowFromItemSelector = ".js-navigation-item, tr"; 137 | 138 | function getSelectorConcat(baseSelector, appendSelector) { 139 | return baseSelector.split(",") 140 | .map(function(single) { 141 | return single + appendSelector; 142 | }) 143 | .join(","); 144 | } 145 | 146 | var Pool = { 147 | _locked: false, 148 | _el: null, 149 | _dashBody: null, 150 | _arrow: null, 151 | init: function(){ 152 | // create dom 153 | // Make the dom on right bottom 154 | var self = this; 155 | 156 | if(!self._el){ 157 | var wrap = document.createElement('div'), 158 | arrow = document.createElement('div'), 159 | dash = document.createElement('div'), 160 | down = document.createElement('p'), 161 | tip = document.createElement('p'); 162 | 163 | wrap.className = "gitzip-collect-wrap" + (isDark ? " gitzip-dark" : ""); 164 | dash.className = "gitzip-collect-dash"; 165 | arrow.className = "gitzip-collect-arrow"; 166 | down.className = "gitzip-collect-down"; 167 | tip.className = "gitzip-collect-tip"; 168 | 169 | tip.appendChild(document.createTextNode("Download checked items")); 170 | 171 | down.appendChild(document.createTextNode("\u27A0")); 172 | 173 | dash.appendChild( 174 | (function(){ 175 | var c = document.createElement("div"); 176 | c.className = "gitzip-header"; 177 | c.appendChild(document.createTextNode("Progress Dashboard")); 178 | 179 | var close = document.createElement("span"); 180 | close.className = "gitzip-close"; 181 | close.appendChild(document.createTextNode("\u2715")); 182 | close.addEventListener('click', function(){ self.reset(); }); 183 | 184 | c.appendChild(close); 185 | return c; 186 | })() 187 | ); 188 | 189 | dash.appendChild( 190 | (function(){ 191 | var c = document.createElement("div"); 192 | c.className = "gitzip-body"; 193 | return c; 194 | })() 195 | ); 196 | 197 | // arrow 198 | arrow.appendChild(down); 199 | arrow.appendChild(tip); 200 | 201 | // wrap 202 | wrap.appendChild(arrow); 203 | wrap.appendChild(dash); 204 | 205 | document.body.appendChild(wrap); 206 | 207 | self._el = wrap; 208 | self._dashBody = dash.querySelector(".gitzip-body"); 209 | self._arrow = arrow; 210 | 211 | // hook events 212 | down.addEventListener('click', function(){ self.download(); }); 213 | tip.addEventListener('click', function(){ self.download(); }); 214 | } 215 | 216 | self.reset(); 217 | }, 218 | show: function(){ this._arrow && this._arrow.classList.add("gitzip-show"); }, 219 | hide: function(){ this._arrow && this._arrow.classList.remove("gitzip-show"); }, 220 | reset: function(){ 221 | var self = this; 222 | checkHaveAnyCheck()? self.show() : self.hide(); 223 | self._el.classList.remove("gitzip-downloading"); 224 | self._el.classList.remove("gitzip-fail"); 225 | while (self._dashBody.firstChild) { 226 | self._dashBody.removeChild(self._dashBody.firstChild); 227 | } 228 | self._locked = false; 229 | }, 230 | checkTokenAndScope: function(){ 231 | var self = this; 232 | var checkUrl = "https://api.github.com/rate_limit"; 233 | var isPrivate = !!document.querySelector(".flex-auto .octicon-lock"); 234 | 235 | return new Promise(function(res, rej){ 236 | chrome.runtime.sendMessage({action: "getKey"}, function(response){ res(response); }); 237 | }).then(function(key){ 238 | 239 | if ( !key ) { 240 | if ( isPrivate ) return Promise.reject("You should have token with `repo` scope."); 241 | else { 242 | self.log("Running in the rate limit.", "warn"); 243 | return key; 244 | } 245 | } 246 | 247 | self.log("Check token and scopes..."); 248 | 249 | return callAjax(checkUrl, key) 250 | .then(function(xmlResponse){ 251 | // return status 200 means token is valid 252 | if ( isPrivate ) { 253 | var strScopes = xmlResponse.getResponseHeader("X-OAuth-Scopes"); 254 | var scopes = strScopes ? strScopes.split(",").map(function(str){ return str.trim(); }) : null; 255 | if ( !scopes || scopes.indexOf("repo") == -1 ) { 256 | return Promise.reject("Your token cannot access private repo."); 257 | } 258 | } 259 | return key; 260 | }); 261 | }).catch(function(err){ 262 | if ( typeof err == "string" ) { 263 | self.log(err, "error"); 264 | self.log("Please click GitZip extension icon to get private token.", "warn"); 265 | return Promise.reject(); 266 | } else return Promise.reject(err); 267 | }); 268 | }, 269 | handleApiError: function(xmlResponse){ 270 | var self = this; 271 | if ( xmlResponse ) { 272 | var status = xmlResponse.status; 273 | var response = xmlResponse.response; 274 | var message = (response && response.message) ? response.message : xmlResponse.statusText; 275 | self.log(message, "error"); 276 | if (message.indexOf("rate limit exceeded") >= 0){ 277 | self.log("Please click GitZip extension icon to get token or input your token.", "warn"); 278 | } 279 | if ( status == 401 ) { 280 | self.log("Your token is invalid, please re-login github and get token again.", "warn"); 281 | } 282 | } 283 | }, 284 | downloadPromiseProcess: function(resolvedUrl, infoAjaxItems){ 285 | var self = this, 286 | fileContents = [], 287 | currentKey = ""; 288 | 289 | var treeAjaxItems = []; 290 | var blobAjaxCollection = []; 291 | 292 | // start progress 293 | self.checkTokenAndScope().then(function(key){ 294 | currentKey = key || ""; 295 | var infoUrl = getInfoUrl(resolvedUrl.author, resolvedUrl.project, resolvedUrl.path, resolvedUrl.branch); 296 | return callAjax(infoUrl, currentKey).then(function(xmlResponse){ 297 | var listRes = xmlResponse.response; 298 | listRes 299 | .filter(function(item){ 300 | return infoAjaxItems.some(function(info){ 301 | return (info.title === item.name || info.alias === item.name) && ( 302 | (info.type == 'tree' && item.type == 'dir') || 303 | (info.type == 'blob' && item.type == 'file') 304 | ); 305 | }); 306 | }) 307 | .forEach(function(item){ 308 | if(item.type == "dir"){ 309 | treeAjaxItems.push({ title: item.name, url: item.git_url }); 310 | }else{ 311 | blobAjaxCollection.push({ path: item.name, blobUrl: item.git_url }); 312 | self.log(item.name + " url fetched.") 313 | } 314 | }); 315 | }); 316 | }).then(function(){ 317 | var promises = treeAjaxItems.map(function(item){ 318 | var fetchedUrl = item.url + "?recursive=1"; 319 | return callAjax(fetchedUrl, currentKey).then(function(xmlResponse){ 320 | var treeRes = xmlResponse.response; 321 | treeRes.tree.forEach(function(blobItem){ 322 | if(blobItem.type == "blob"){ 323 | var path = item.title + "/" + blobItem.path; 324 | blobAjaxCollection.push({ path: path, blobUrl: blobItem.url }); 325 | self.log(path + " url fetched."); 326 | } 327 | }); 328 | }); 329 | }); 330 | return Promise.all(promises); 331 | }).then(function(){ 332 | self.log("Collect blob contents..."); 333 | var promises = blobAjaxCollection.map(function(item){ 334 | var fetchedUrl = item.blobUrl; 335 | return callAjax(fetchedUrl, currentKey).then(function(xmlResponse){ 336 | var blobRes = xmlResponse.response; 337 | fileContents.push({ path: item.path, content: blobRes.content }); 338 | self.log(item.path + " content has collected."); 339 | }); 340 | }); 341 | return Promise.all(promises); 342 | }).then(function(){ 343 | if ( treeAjaxItems.length == 0 && blobAjaxCollection.length == 1) { 344 | self.log("Trigger download..."); 345 | // to save as file 346 | var singleItem = fileContents[0]; 347 | return saveAs(base64toBlob(singleItem.content), singleItem.path); 348 | } else { 349 | self.log("Zip contents and trigger download..."); 350 | return zipContents([resolvedUrl.project].concat(resolvedUrl.path.split('/')).join('-'), fileContents); 351 | } 352 | }).then(function(){ 353 | self.reset(); 354 | }).catch(function(err){ 355 | self.handleApiError(err); 356 | }); 357 | }, 358 | downloadItems: function(items){ 359 | var self = this; 360 | if(self._locked || !items.length) return; 361 | 362 | self._locked = true; 363 | 364 | self._el.classList.add("gitzip-downloading"); 365 | 366 | var infoAjaxItems = []; 367 | var resolvedUrl = resolveUrl(window.location.href); 368 | 369 | self.log("Collect blob urls..."); 370 | 371 | for(var idx = 0, len = items.length; idx < len; idx++){ 372 | var item = isOnlyDoubleClick ? items[idx] : items[idx].closest("div.gitzip-check-wrap"), 373 | type = item.getAttribute('gitzip-type'), 374 | title = item.getAttribute('gitzip-title'), 375 | href = item.getAttribute('gitzip-href'); 376 | 377 | var itemInfo = { 378 | type: type, 379 | title: title, 380 | href: href 381 | }, titleSplits; 382 | 383 | if ( (titleSplits = title.split("/")).length > 1 ) itemInfo.alias = titleSplits[0]; 384 | 385 | infoAjaxItems.push(itemInfo); 386 | } 387 | 388 | self.downloadPromiseProcess(resolvedUrl, infoAjaxItems); 389 | }, 390 | downloadSingle: function(selectedEl){ 391 | this.downloadItems( selectedEl.querySelectorAll(isOnlyDoubleClick ? "p.gitzip-check-mark" : "div.gitzip-check-wrap") ); 392 | }, 393 | downloadAll: function(){ 394 | this.downloadItems(document.querySelectorAll( getSelectorConcat(itemCollectSelector, isOnlyDoubleClick ? " p.gitzip-check-mark" : " div.gitzip-check-wrap") )); 395 | }, 396 | download: function(){ 397 | this.downloadItems(document.querySelectorAll( getSelectorConcat(itemCollectSelector, isOnlyDoubleClick ? " p.gitzip-show" : " div.gitzip-check-wrap input:checked") )); 398 | }, 399 | downloadFile: function(resolvedUrl){ 400 | var self = this; 401 | if(self._locked) return; 402 | 403 | self._locked = true; 404 | 405 | self._el.classList.add("gitzip-downloading"); 406 | 407 | var breadcrumb = document.querySelector(".file-navigation .js-path-segment"), 408 | rootAnchor = breadcrumb ? breadcrumb.querySelector("a") : null; 409 | if ( rootAnchor && rootAnchor.href ) { 410 | // for the cases like this: https://github.com/Microsoft/CNTK/blob/aayushg/autoencoder/Tools/build-and-test 411 | // to find the branch in the case of branch has slash charactor. 412 | var hrefSplits = rootAnchor.href.split("/tree/"); 413 | if ( hrefSplits.length > 1 && resolvedUrl.branch != hrefSplits[1] ) { 414 | var newBranch = hrefSplits[1]; 415 | var inputSplits = resolvedUrl.inputUrl.split(newBranch); 416 | var newPath = inputSplits[1].slice(1); 417 | var newRoot = "https://github.com/" + resolvedUrl.author + "/" + resolvedUrl.project + "/tree/" + newBranch; 418 | 419 | resolvedUrl.branch = newBranch; 420 | resolvedUrl.path = newPath; 421 | resolvedUrl.rootUrl = newRoot; 422 | } 423 | } 424 | 425 | self.checkTokenAndScope().then(function(key){ 426 | self.log("Collect blob content..."); 427 | 428 | currentKey = key || ""; 429 | var params = []; 430 | var fetchedUrl = "https://api.github.com/repos/" + resolvedUrl.author + "/" + resolvedUrl.project + "/contents/" + resolvedUrl.path; 431 | 432 | if ( resolvedUrl.branch ) params.push("ref=" + resolvedUrl.branch); 433 | if ( params.length ) fetchedUrl += "?" + params.join('&'); 434 | 435 | return callAjax(fetchedUrl, currentKey); 436 | }).then(function(xmlResponse){ 437 | var treeRes = xmlResponse.response; 438 | self.log(treeRes.name + " content has collected."); 439 | self.log("Trigger download..."); 440 | return saveAs(base64toBlob(treeRes.content), treeRes.name); 441 | }).then(function(){ 442 | self.reset(); 443 | }).catch(function(err){ 444 | self.handleApiError(err); 445 | }); 446 | }, 447 | log: function(message, type){ 448 | var self = this, 449 | pNode = document.createElement("p"), 450 | textNode = document.createTextNode(message); 451 | 452 | type && pNode.classList.add(type); 453 | if (type == "error") self._el.classList.add("gitzip-fail"); 454 | 455 | pNode.appendChild(textNode); 456 | 457 | self._dashBody.appendChild(pNode); 458 | self._dashBody.scrollTop = self._dashBody.scrollHeight - self._dashBody.clientHeight; 459 | } 460 | }; 461 | 462 | function applyTheme() { 463 | if (Pool._el) { 464 | isDark && Pool._el.classList.add("gitzip-dark"); 465 | !isDark && Pool._el.classList.remove("gitzip-dark"); 466 | } 467 | var markers = document.querySelectorAll("p.gitzip-check-mark"); 468 | var markersLength = markers.length; 469 | for(var i = 0; i < markersLength; i++){ 470 | isDark && markers[i].classList.add("gitzip-dark"); 471 | !isDark && markers[i].classList.remove("gitzip-dark"); 472 | } 473 | } 474 | 475 | chrome.storage.local.get(defaultOptions, function(items){ 476 | if (items) { 477 | if (items.theme == "default") isDark = window.matchMedia('(prefers-color-scheme: dark)').matches; 478 | else isDark = items.theme == "dark"; 479 | applyTheme(); 480 | 481 | isOnlyDoubleClick = items.selectBehaviour == "double-click"; 482 | isOnlySingleCheck = items.selectBehaviour == "single-check"; 483 | isBoth = items.selectBehaviour == "both"; 484 | 485 | isStorageCallback = true; 486 | var callbackEvent = new CustomEvent("storagecallback", {}); 487 | window.dispatchEvent(callbackEvent); 488 | } 489 | }); 490 | 491 | chrome.storage.onChanged.addListener(function(changes, area){ 492 | if (area == "local") { 493 | if (changes.theme) { 494 | var newValue = changes.theme.newValue; 495 | if (newValue == "default") isDark = window.matchMedia('(prefers-color-scheme: dark)').matches; 496 | else isDark = newValue == "dark"; 497 | applyTheme(); 498 | } 499 | 500 | if (changes.selectBehaviour) { 501 | var newValue = changes.selectBehaviour.newValue; 502 | 503 | isOnlyDoubleClick = newValue == "double-click"; 504 | isOnlySingleCheck = newValue == "single-check"; 505 | isBoth = newValue == "both"; 506 | 507 | // rebind 508 | var items = document.querySelectorAll(itemCollectSelector); 509 | var itemLen = items.length; 510 | if(itemLen){ 511 | // means in new UI 512 | var isNewUI = items[0].tagName.toLowerCase() === "td"; 513 | for(var i = 0; i < itemLen; i++){ 514 | var item = items[i]; 515 | // reset 516 | item._hasBind = false; 517 | 518 | var eventBindItem = isNewUI ? item.closest("tr") : item; 519 | // remove events 520 | eventBindItem.removeEventListener("dblclick", onItemDblClick); 521 | eventBindItem.removeEventListener("mouseenter", onItemEnter); 522 | eventBindItem.removeEventListener("mouseleave", onItemLeave); 523 | 524 | // remove custom markers 525 | var toRemoveMark = item.querySelector("p.gitzip-check-mark"); 526 | var toRemoveWrap = item.querySelector("div.gitzip-check-wrap"); 527 | toRemoveMark && toRemoveMark.remove(); 528 | toRemoveWrap && toRemoveWrap.remove(); 529 | } 530 | } 531 | appendToIcons(true); 532 | } 533 | } 534 | }); 535 | 536 | function createMark(parent, height, title, type, href){ 537 | var target = parent.querySelector(isOnlyDoubleClick ? "p.gitzip-check-mark" : "div.gitzip-check-wrap"); 538 | if (parent && !target) { 539 | if (isOnlyDoubleClick) { 540 | var checkp = document.createElement('p'); 541 | 542 | checkp.setAttribute("gitzip-title", title); 543 | checkp.setAttribute("gitzip-type", type); 544 | checkp.setAttribute("gitzip-href", href); 545 | checkp.className = (isDark ? "gitzip-dark " : "") + "gitzip-check-mark"; 546 | checkp.appendChild(document.createTextNode("\u2713")); 547 | checkp.style.cssText = "line-height:" + height + "px;"; 548 | 549 | parent.appendChild(checkp); 550 | 551 | target = checkp; 552 | } else { 553 | var checkw = document.createElement('div'); 554 | var cb = document.createElement("input"); 555 | 556 | cb.type = "checkbox"; 557 | 558 | checkw.setAttribute("gitzip-title", title); 559 | checkw.setAttribute("gitzip-type", type); 560 | checkw.setAttribute("gitzip-href", href); 561 | 562 | checkw.className = "gitzip-check-wrap"; 563 | 564 | checkw.appendChild(cb); 565 | parent.appendChild(checkw); 566 | 567 | target = checkw; 568 | } 569 | } 570 | return target; 571 | } 572 | 573 | function checkHaveAnyCheck(){ 574 | var checkItems = document.querySelectorAll( getSelectorConcat(itemCollectSelector, isOnlyDoubleClick ? " p.gitzip-show" : " div.gitzip-check-wrap input:checked") ); 575 | return checkItems.length > 0; 576 | } 577 | 578 | function onItemDblClick(e){ 579 | if (isBoth) { 580 | var markTarget = e.target.closest(closestRowFromItemSelector).querySelector('div.gitzip-check-wrap'); 581 | if(markTarget) { 582 | var cb = markTarget.querySelector('input'); 583 | cb.click(); 584 | } 585 | } else if (isOnlyDoubleClick) { 586 | var markTarget = e.target.closest(closestRowFromItemSelector).querySelector('p.gitzip-check-mark'); 587 | if(markTarget) markTarget.classList.toggle("gitzip-show"); 588 | checkHaveAnyCheck()? Pool.show() : Pool.hide(); 589 | applyItemsContext(); 590 | } 591 | } 592 | 593 | function onItemEnter(e) { 594 | var markTarget = e.target.closest(closestRowFromItemSelector).querySelector('div.gitzip-check-wrap'); 595 | if (markTarget && !markTarget.style.display) { 596 | markTarget.style.display = "flex"; 597 | } 598 | } 599 | 600 | function onItemLeave(e) { 601 | var markTarget = e.target.closest(closestRowFromItemSelector).querySelector('div.gitzip-check-wrap'); 602 | if (markTarget && !markTarget.querySelector('input:checked')) { 603 | markTarget.style.display = ""; 604 | } 605 | } 606 | 607 | var cacheSelectEl = null; 608 | var currentSelectEl = null; 609 | function generateEnterItemHandler(title, type){ 610 | return function(){ 611 | applySelectedContext(title, type); 612 | cacheSelectEl = this; 613 | } 614 | } 615 | 616 | function leaveItemHandler() { 617 | applySelectedContext(); 618 | cacheSelectEl = null; 619 | } 620 | 621 | function applyItemsContext() { 622 | chrome.runtime.sendMessage({ 623 | action: "updateContextNested", 624 | target: "items", 625 | enabled: checkHaveAnyCheck() 626 | }); 627 | } 628 | 629 | function applySelectedContext(name, type) { 630 | var enabled = !!name && !!type; 631 | chrome.runtime.sendMessage({ 632 | action: "updateContextNested", 633 | urlName: name, 634 | urlType: type, 635 | enabled: enabled, 636 | target: "selected" 637 | }); 638 | } 639 | 640 | function applyCurrentContext(name, type) { 641 | chrome.runtime.sendMessage({ 642 | action: "updateContextNested", 643 | urlName: name, 644 | urlType: type, 645 | enabled: !!(name || type), 646 | target: "current" 647 | }); 648 | } 649 | 650 | function restoreContextStatus(){ 651 | var resolvedUrl = resolveUrl(window.location.href); 652 | var baseRepo = [resolvedUrl.author, resolvedUrl.project].join("/"); 653 | var isRoot = !resolvedUrl.path; 654 | var pathText = resolvedUrl.path.split('/').pop(); 655 | var urlType = resolvedUrl.type; 656 | 657 | if ( isRoot ) { 658 | // in root 659 | applyCurrentContext(); 660 | } else if ( urlType === "tree" ) { 661 | // in tree view 662 | applyCurrentContext(pathText, urlType); 663 | } else if ( urlType === "blob" ) { 664 | // in file view 665 | applyCurrentContext(pathText, urlType); 666 | applySelectedContext(); 667 | } 668 | 669 | // the checked items 670 | applyItemsContext(); 671 | } 672 | 673 | // Check is in available view 674 | function isAvailableView(){ 675 | return !!document.querySelector("head meta[value=repo_source]") && resolveUrl(window.location.href) !== false; 676 | } 677 | 678 | function isItemsBind() { 679 | var items = document.querySelectorAll(itemCollectSelector); 680 | var itemLen = items.length; 681 | return itemLen ? !!items[itemLen-1]._hasBind : false; 682 | } 683 | 684 | function appendToIcons(isRebind){ 685 | var items = document.querySelectorAll(itemCollectSelector); 686 | var itemLen = items.length; 687 | if(itemLen){ 688 | // means in new UI 689 | var isNewUI = items[0].tagName.toLowerCase() === "td"; 690 | if (isNewUI) { 691 | var td = document.querySelector(upfolderItemSelector); 692 | if (td) { 693 | td.style["padding-left"] = "24px"; 694 | td.style["position"] = "relative"; 695 | } 696 | } 697 | for(var i = 0; i < itemLen; i++){ 698 | var item = items[i], 699 | link = item.querySelector("a[href]"), 700 | blob = item.querySelector(".octicon-file-text, .octicon-file") || (link && resolveUrl(link.href).type === "blob"), 701 | tree = item.querySelector(".octicon-file-directory, .octicon-file-directory-fill") || (link && resolveUrl(link.href).type === "tree"); 702 | 703 | if(!item._hasBind && link && (tree || blob)){ 704 | var title = link.textContent, 705 | type = tree? "tree" : "blob"; 706 | 707 | if (isBoth || isOnlySingleCheck) { 708 | // reset status if not checked 709 | onItemLeave({ target: item }); 710 | } 711 | 712 | var markParent = link.closest("td"); 713 | 714 | if ( markParent ) { 715 | // change the style 716 | markParent.style["padding-left"] = "24px"; 717 | markParent.style["position"] = "relative"; 718 | } else { 719 | markParent = item; 720 | } 721 | 722 | var markTarget = createMark(markParent, item.offsetHeight, title, type, link.href); 723 | if (isBoth || isOnlySingleCheck) { 724 | markTarget.querySelector("input").addEventListener('change', function(){ 725 | checkHaveAnyCheck()? Pool.show() : Pool.hide(); 726 | applyItemsContext(); 727 | }); 728 | } 729 | 730 | var eventBindItem = isNewUI ? item.closest("tr") : item; 731 | 732 | if (isBoth || isOnlyDoubleClick) { 733 | eventBindItem.addEventListener("dblclick", onItemDblClick); 734 | } 735 | 736 | if (isRebind !== true) { 737 | eventBindItem.addEventListener("mouseenter", generateEnterItemHandler(title, type, link.href) ); 738 | eventBindItem.addEventListener("mouseleave", leaveItemHandler); 739 | } 740 | 741 | if (isBoth || isOnlySingleCheck) { 742 | eventBindItem.addEventListener("mouseenter", onItemEnter); 743 | eventBindItem.addEventListener("mouseleave", onItemLeave); 744 | } 745 | 746 | item._hasBind = true; 747 | } 748 | } 749 | } 750 | } 751 | 752 | function isAnyItemExist() { 753 | return !!document.querySelector(itemCollectSelector); 754 | } 755 | 756 | function hookItemEvents(){ 757 | 758 | var theInterval = null; 759 | 760 | function waitStorageHandler() { 761 | appendToIcons(); 762 | Pool._el && Pool.reset(); 763 | currentSelectEl = cacheSelectEl = null; 764 | 765 | if (!theInterval) { 766 | theInterval = setInterval(function(){ 767 | if (!isAnyItemExist() || isItemsBind()) { 768 | clearInterval(theInterval); 769 | theInterval = null; 770 | } else { 771 | appendToIcons(); 772 | } 773 | }, 100); 774 | } 775 | } 776 | 777 | if (isAnyItemExist()) { 778 | if (isStorageCallback) waitStorageHandler(); 779 | else window.addEventListener("storagecallback", waitStorageHandler); 780 | } 781 | 782 | function doObserverHandler( keepListening ) { 783 | var lazyCaseObserver = new MutationObserver(function(mutations) { 784 | mutations.forEach(function(mutation) { 785 | var addNodes = mutation.addedNodes; 786 | addNodes && addNodes.length && addNodes.forEach(function(el){ 787 | if (el.querySelector && el.querySelector(itemCollectSelector)) { 788 | !keepListening && lazyCaseObserver.disconnect(); 789 | waitStorageHandler(); 790 | } 791 | }); 792 | }); 793 | }); 794 | lazyCaseObserver.observe(document, { childList: true, subtree: true } ); 795 | } 796 | 797 | window.addEventListener('popstate', (ev) => { 798 | if (isAnyItemExist()) { 799 | waitStorageHandler(); 800 | } else { 801 | // wait for 802 | doObserverHandler(); 803 | } 804 | }); 805 | 806 | window.addEventListener('contextmenu', (ev) => { 807 | currentSelectEl = cacheSelectEl; 808 | }) 809 | 810 | function onRequestsObserved( batch ) { 811 | var entries = batch.getEntries(); 812 | if (entries.some(resource => repoCommitExp.test(resource.name)) && isAnyItemExist()) { 813 | if (isStorageCallback) waitStorageHandler(); 814 | else window.addEventListener("storagecallback", waitStorageHandler); 815 | } 816 | } 817 | 818 | var requestObserver = new PerformanceObserver( onRequestsObserved ); 819 | requestObserver.observe({ type: 'resource' }); 820 | 821 | doObserverHandler(true); 822 | 823 | Pool.init(); 824 | } 825 | 826 | function hookChromeEvents(){ 827 | 828 | chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) { 829 | switch (request.action){ 830 | case "getCurrentPath": 831 | sendResponse(window.location.href); 832 | case "github-tab-active": 833 | // from the background event 834 | // means tab active changed. 835 | // if it is in github.com now 836 | chrome.runtime.sendMessage({action: "showIcon"}, function(response) {}); 837 | if ( isAvailableView() ) { 838 | chrome.runtime.sendMessage({action: "createContextNested"}); 839 | restoreContextStatus(); 840 | } else { 841 | chrome.runtime.sendMessage({action: "removeContext"}); 842 | } 843 | return true; 844 | case "gitzip-nested-items-clicked": 845 | Pool.download(); 846 | return true; 847 | case "gitzip-nested-selected-clicked": 848 | Pool.downloadSingle(currentSelectEl); 849 | return true; 850 | case "gitzip-nested-current-clicked": 851 | var resolvedUrl = resolveUrl(window.location.href); 852 | var urlType = resolvedUrl.type; 853 | 854 | if ( urlType === "tree" ) { 855 | // in tree view 856 | Pool.downloadAll(); 857 | } else if ( urlType === "blob" ) { 858 | // in file view 859 | Pool.downloadFile(resolvedUrl); 860 | } else { 861 | alert("Unknown Operation"); 862 | } 863 | 864 | return true; 865 | } 866 | }); 867 | } 868 | 869 | hookItemEvents(); 870 | hookChromeEvents(); 871 | -------------------------------------------------------------------------------- /js/content/show.js: -------------------------------------------------------------------------------- 1 | 2 | // just show the icon 3 | chrome.runtime.sendMessage({action: "showIcon"}, function(response) {}); 4 | 5 | -------------------------------------------------------------------------------- /js/popup.js: -------------------------------------------------------------------------------- 1 | 2 | let isDark = true; 3 | 4 | const defaultOptions = { 5 | selectBehaviour: 'both', 6 | theme: 'default' 7 | }; 8 | 9 | function applyTheme() { 10 | isDark && document.body.classList.add("dark-theme"); 11 | !isDark && document.body.classList.remove("dark-theme"); 12 | } 13 | 14 | chrome.storage.local.get(defaultOptions, function(items){ 15 | if (items) { 16 | if (items.theme == "default") isDark = window.matchMedia('(prefers-color-scheme: dark)').matches; 17 | else isDark = items.theme == "dark"; 18 | applyTheme(); 19 | } 20 | }); 21 | 22 | chrome.storage.onChanged.addListener(function(changes, area){ 23 | if (area == "local" && changes.theme) { 24 | var newValue = changes.theme.newValue; 25 | if (newValue == "default") isDark = window.matchMedia('(prefers-color-scheme: dark)').matches; 26 | else isDark = newValue == "dark"; 27 | applyTheme(); 28 | } 29 | }); 30 | 31 | // The DOMContentLoaded means the popup.html page has load. (trigger this event after click the ext icon) 32 | document.addEventListener('DOMContentLoaded', function() { 33 | // alert("has loaded"); 34 | var form = document.getElementById('tokenForm'); 35 | var input = document.getElementById('tokenInput'); 36 | var tokenlinks = form.querySelectorAll('.gettoken-link'); 37 | var tip = form.querySelector('.tip-left'); 38 | var referrer = ""; 39 | form.addEventListener('submit', function(){ 40 | chrome.runtime.sendMessage({action: "setKey", value: input.value}) 41 | .then(function() { 42 | window.close(); 43 | }); 44 | }); 45 | 46 | input.addEventListener('input', function(){ 47 | if(tip) tip.style.cssText += "display:block;"; 48 | }); 49 | 50 | chrome.runtime.sendMessage({action: "getKey"}, function(response){ 51 | input.value = response; 52 | }); 53 | 54 | chrome.runtime.sendMessage({action: "getCurrentPath"}, function(response){ 55 | referrer = response; 56 | }); 57 | 58 | chrome.tabs.query({currentWindow: true, active: true}, function(tabs){ 59 | var tab = tabs[0]; 60 | if(tab){ 61 | function onTokenLinkClick(e){ 62 | e.preventDefault(); 63 | chrome.tabs.update(tab.id, {url: this.href + encodeURIComponent(referrer)}); 64 | window.close(); 65 | } 66 | tokenlinks.forEach(function(link){ 67 | link.addEventListener('click', onTokenLinkClick); 68 | }); 69 | } 70 | }); 71 | 72 | applyTheme(); 73 | }, false); 74 | -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest_version": 3, 3 | 4 | "name": "GitZip for github", 5 | "description": "It can make the sub-directories and files of github repository as zip and download it", 6 | "version": "1.0.4", 7 | 8 | "icons": { 9 | "128": "images/icon-128px.png" 10 | }, 11 | 12 | "action": { 13 | "default_popup": "popup.html" 14 | }, 15 | 16 | "options_ui": { 17 | "page": "options.html", 18 | "open_in_tab": false 19 | }, 20 | 21 | "background": { 22 | "service_worker": "js/background.js" 23 | }, 24 | 25 | "permissions": [ 26 | "storage", 27 | "contextMenus" 28 | ], 29 | 30 | "host_permissions": [ 31 | "https://api.github.com/*" 32 | ], 33 | 34 | "content_scripts": [ 35 | { 36 | "matches": ["*://github.com/*"], 37 | "js": ["js/content/jszip.min.js","js/content/FileSaver.min.js","js/content/main.js"], 38 | "css": ["css/main.css"] 39 | }, 40 | { 41 | "matches": ["*://kinolien.github.io/gitzip/*"], 42 | "js": ["js/content/keysync.js"] 43 | }, 44 | { 45 | "matches": ["*://gitzip.org/gettoken/success"], 46 | "js": ["js/content/autosave.js"] 47 | } 48 | ], 49 | 50 | "content_security_policy": { 51 | "extension_pages": "script-src 'self'; object-src 'self'; worker-src 'self'" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /options.html: -------------------------------------------------------------------------------- 1 | Gitzip Options
-------------------------------------------------------------------------------- /popup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | GitZip plugin 5 | 6 | 7 | 8 | 9 |
10 |
Github API Access Token
11 |
12 |
13 | 14 |
15 | 16 | 17 | 18 | Get Token: 19 | Normal 20 | / 21 | Private 22 |
23 |
Enter to save
24 |
25 |
26 |
27 | 28 | -------------------------------------------------------------------------------- /static/js/main.b7f29431.js.LICENSE.txt: -------------------------------------------------------------------------------- 1 | /* 2 | object-assign 3 | (c) Sindre Sorhus 4 | @license MIT 5 | */ 6 | 7 | /** 8 | * A better abstraction over CSS. 9 | * 10 | * @copyright Oleg Isonen (Slobodskoi) / Isonen 2014-present 11 | * @website https://github.com/cssinjs/jss 12 | * @license MIT 13 | */ 14 | 15 | /** @license React v0.20.2 16 | * scheduler.production.min.js 17 | * 18 | * Copyright (c) Facebook, Inc. and its affiliates. 19 | * 20 | * This source code is licensed under the MIT license found in the 21 | * LICENSE file in the root directory of this source tree. 22 | */ 23 | 24 | /** @license React v16.13.1 25 | * react-is.production.min.js 26 | * 27 | * Copyright (c) Facebook, Inc. and its affiliates. 28 | * 29 | * This source code is licensed under the MIT license found in the 30 | * LICENSE file in the root directory of this source tree. 31 | */ 32 | 33 | /** @license React v17.0.2 34 | * react-dom.production.min.js 35 | * 36 | * Copyright (c) Facebook, Inc. and its affiliates. 37 | * 38 | * This source code is licensed under the MIT license found in the 39 | * LICENSE file in the root directory of this source tree. 40 | */ 41 | 42 | /** @license React v17.0.2 43 | * react-jsx-runtime.production.min.js 44 | * 45 | * Copyright (c) Facebook, Inc. and its affiliates. 46 | * 47 | * This source code is licensed under the MIT license found in the 48 | * LICENSE file in the root directory of this source tree. 49 | */ 50 | 51 | /** @license React v17.0.2 52 | * react.production.min.js 53 | * 54 | * Copyright (c) Facebook, Inc. and its affiliates. 55 | * 56 | * This source code is licensed under the MIT license found in the 57 | * LICENSE file in the root directory of this source tree. 58 | */ 59 | --------------------------------------------------------------------------------