vart=function(t){"use strict";varr,e=Object.prototype,n=e.hasOwnProperty,o="function"==typeofSymbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";functionu(t,r,e,n){varo=r&&r.prototypeinstanceofv?r:v,i=Object.create(o.prototype),a=newk(n||[]);returni._invoke=function(t,r,e){varn=f;returnfunction(o,i){if(n===l)thrownewError("Generator is already running");if(n===p){if("throw"===o)throwi;returnN()}for(e.method=o,e.arg=i;;){vara=e.delegate;if(a){varc=_(a,e);if(c){if(c===y)continue;returnc}}if("next"===e.method)e.sent=e._sent=e.arg;elseif("throw"===e.method){if(n===f)thrown=p,e.arg;e.dispatchException(e.arg)}else"return"===e.method&&e.abrupt("return",e.arg);n=l;varu=h(t,r,e);if("normal"===u.type){if(n=e.done?p:s,u.arg===y)continue;return{value:u.arg,done:e.done}}"throw"===u.type&&(n=p,e.method="throw",e.arg=u.arg)}}}(t,e,a),i}functionh(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(n){return{type:"throw",arg:n}}}t.wrap=u;varf="suspendedStart",s="suspendedYield",l="executing",p="completed",y={};functionv(){}functiond(){}functiong(){}varm={};m[i]=function(){returnthis};varw=Object.getPrototypeOf,L=w&&w(w(G([])));L&&L!==e&&n.call(L,i)&&(m=L);varx=g.prototype=v.prototype=Object.create(m);functionE(t){["next","throw","return"].forEach(function(r){t[r]=function(t){returnthis._invoke(r,t)}})}functionb(t,r){vare;this._invoke=function(o,i){functiona(){returnnewr(function(e,a){!functione(o,i,a,c){varu=h(t[o],t,i);if("throw"!==u.type){varf=u.arg,s=f.value;returns&&"object"==typeofs&&n.call(s,"__await")?r.resolve(s.__await).then(function(t){e("next",t,a,c)},function(t){e("throw",t,a,c)}):r.resolve(s).then(function(t){f.value=t,a(f)},function(t){returne("throw",t,a,c)})}c(u.arg)}(o,i,e,a)})}returne=e?e.then(a,a):a()}}function_(t,e){varn=t.iterator[e.method];if(n===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=r,_(t,e),"throw"===e.method))returny;e.method="throw",e.arg=newTypeError("The iterator does not provide a 'throw' method")}returny}varo=h(n,t.iterator,e.arg);if("throw"===o.type)returne.method="throw",e.arg=o.arg,e.delegate=null,y;vari=o.arg;returni?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=r),e.delegate=null,y):i:(e.method="throw",e.arg=newTypeError("iterator result is not an object"),e.delegate=null,y)}functionj(t){varr={tryLoc:t[0]};1int&&(r.catchLoc=t[1]),2int&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}functionO(t){varr=t.completion||{};r.type="normal",deleter.arg,t.completion=r}functionk(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(j,this),this.reset(!0)}functionG(t){if(t){vare=t[i];if(e)returne.call(t);if("function"==typeoft.next)returnt;if(!isNaN(t.length)){varo=-1,a=functione(){for(;++o<t.length;)if(n.call(t,o))returne.value=t[o],e.done=!1,e;returne.value=r,e.done=!0,e};returna.next=a}}return{next:N}}functionN(){return{value:r,done:!0}}returnd.prototype=x.constructor=g,g.constructor=d,g[c]=d.displayName="GeneratorFunction",t.isGeneratorFunction=function(t){varr="function"==typeoft&&t.constructor;return!!r&&(r===d||"GeneratorFunction"===(r.displayName||r.name))},t.mark=function(t){returnObject.setPrototypeOf?Object.setPrototypeOf(t,g):(t.__proto__=g,cint||(t[c]="GeneratorFunction")),t.prototype=Object.create(x),t},t.awrap=function(t){return{__await:t}},E(b.prototype),b.prototype[a]=function(){returnthis},t.AsyncIterator=b,t.async=function(r,e,n,o,i){void0===i&&(i=Promise);vara=newb(u(r,e,n,o),i);returnt.isGeneratorFunction(e)?a:a.next().then(function(t){returnt.done?t.value:a.next()})},E(x),x[c]="Generator",x[i]=function(){returnthis},x.toString=function(){return"[object Generator]"},t.keys=function(t){varr=[];for(vareint)r.push(e);returnr.reverse(),functione(){for(;r.length;){varn=r.pop();if(nint)returne.value=n,e.done=!1,e}returne.done=!0,e}},t.values=G,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=r
"use strict";functione(e){if("undefined"==typeofSymbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(e=t(e))){varn=0,r=function(){};return{s:r,n:function(){returnn>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throwe},f:r}}thrownewTypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}varo,a,c=!0,i=!1;return{s:function(){o=e[Symbol.iterator]()},n:function(){vare=o.next();returnc=e.done,e},e:function(e){i=!0,a=e},f:function(){try{c||null==o.return||o.return()}finally{if(i)throwa}}}}functiont(e,t){if(e){if("string"==typeofe)returnn(e,t);varr=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(r):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void0}}functionn(e,t){(null==t||t>e.length)&&(t=e.length);for(varn=0,r=newArray(t);n<t;n++)r[n]=e[n];returnr}functionr(e,t,n,r,o,a,c){try{vari=e[a](c),l=i.value}catch(u){returnvoidn(u)}i.done?t(l):Promise.resolve(l).then(r,o)}functiono(e){returnfunction(){vart=this,n=arguments;returnnewPromise(function(o,a){varc=e.apply(t,n);functioni(e){r(c,o,a,i,l,"next",e)}functionl(e){r(c,o,a,i,l,"throw",e)}i(void0)})}}require("regenerator-runtime/runtime"),require("unfetch/polyfill");vara=document.createElement("script");a.src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.3.0/jszip.min.js",document.head.appendChild(a);varc=function(){vart=o(regeneratorRuntime.mark(functiont(){varn,r,o,a,c,i,l,u,s,d,f,p,m,h,v,b,x;returnregeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case0:returnt.prev=0,alert("This is the McGraw-Hill Education Textbook Downloader. Click OK to start downloading the files."),t.next=4,fetch("https://player-api.mheducation.com/lti",{credentials:"include"});case4:returnt.next=6,t.sent.json();case6:returnn=t.sent.custom_epub_url,r=newJSZip,o=r.folder("META-INF"),t.t0=o,t.next=12,fetch(n+"META-INF/container.xml",{credentials:"include"});case12:returnt.next=14,t.sent.text();case14:returnt.t1=t.sent,t.t0.file.call(t.t0,"container.xml",t.t1),a=r.folder("OPS"),t.next=19,fetch(n+"OPS/content.opf",{credentials:"include"});case19:returnt.next=21,t.sent.text();case21:c=t.sent,a.file("content.opf",c),i=(newDOMParser).parseFromString(c,"application/xml"),l=e(i.querySelector("manifest").children),t.prev=25,l.s();case27:if((u=l.n()).done){t.next=45;break}returns=u.value,d=s.getAttribute("href"),t.prev=30,t.next=33,fetch("".concat(n,"OPS/").concat(d),{credentials:"include"});case33:returnt.next=35,t.sent.arrayBuffer();case35:f=t.sent,a.file(d,f),console.log("Finished downloading",d),t.next=43;break;case40:t.prev=40,t.t2=t.catch(30),console.error("Failed to download ".concat(d,": ").concat(t.t2));case43:t.next=27;break;case45:t.next=50;break;case47:t.prev=47,t.t3=t.catch(25),l.e(t.t3);case50:returnt.prev=50,l.f(),t.finish(50);case53:returnalert("Finished downloading data! Click OK to start compression."),window.__savedTextbook=r,p=0,t.next=58,r.generateInternalStream({type:"blob"}).accumulate(function(e){vart=e.percent,n=Math.floor(t);n>p&&(console.log(n+"% complete"),p=n)});case58:m=t.sent,alert("Finished compressing textbook! Click OK to start download."),window.__savedTextbookEpub=m,h=URL.createObjectURL(m),(v=document.createElement("a")).href=h,b=i.querySelector("metadata title"),x=b?b.innerHTML:"textbook",v.download=x+".epub",v.click(),URL.revokeObjectURL(h),t.next=74;break;case71:t.prev=71,t.t4=t.catch(0),alert("Textbook download failed because an error occurred: "+t.t4);case74:case"end":returnt.stop()}},t,null,[[0,71],[25,47,50,53],[30,40]])}));returnfunction(){returnt.apply(this,arguments)}}();c();