diff --git a/dist/xhook.js b/dist/xhook.js index dd117ab..6bc40a3 100644 --- a/dist/xhook.js +++ b/dist/xhook.js @@ -7,6 +7,8 @@ WINDOW = null; if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) { WINDOW = self; +} else if (typeof global !== 'undefined') { + WINDOW = global; } else { WINDOW = window; } diff --git a/dist/xhook.min.js b/dist/xhook.min.js index aedf933..8504a76 100644 --- a/dist/xhook.min.js +++ b/dist/xhook.min.js @@ -1,3 +1,3 @@ // XHook - v1.4.1 - https://github.com/jpillora/xhook // Jaime Pillora - MIT Copyright 2017 -(function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G=[].indexOf||function(a){for(var b=0,c=this.length;b=0||(f=f===b?d[a].length:f,d[a].splice(f,0,c))},c[m]=function(a,c){var f;if(a===b)return void(d={});c===b&&(d[a]=[]),f=e(a).indexOf(c),f!==-1&&e(a).splice(f,1)},c[h]=function(){var b,d,f,g,h,i,j,k;for(b=C(arguments),d=b.shift(),a||(b[0]=z(b[0],y(d))),g=c["on"+d],g&&g.apply(c,b),k=e(d).concat(e("*")),f=i=0,j=k.length;i2)throw"invalid hook";return E[n](d,a,b)},E[c]=function(a,b){if(a.length<2||a.length>3)throw"invalid hook";return E[n](c,a,b)},E.enable=function(){q[u]=t,"function"==typeof r&&(q[g]=r),k&&(q[i]=s)},E.disable=function(){q[u]=E[u],q[g]=E[g],k&&(q[i]=k)},v=E.headers=function(a,b){var c,d,e,f,g,h,i,j,k;switch(null==b&&(b={}),typeof a){case"object":d=[];for(e in a)g=a[e],f=e.toLowerCase(),d.push(f+":\t"+g);return d.join("\n");case"string":for(d=a.split("\n"),i=0,j=d.length;ib&&b<4;)k[o]=++b,1===b&&k[h]("loadstart",{}),2===b&&F(),4===b&&(F(),D()),k[h]("readystatechange",{}),4===b&&setTimeout(g,0)},g=function(){l||k[h]("load",{}),k[h]("loadend",{}),l&&(k[o]=0)},b=0,x=function(a){var b,d;if(4!==a)return void i(a);b=E.listeners(c),(d=function(){var a;return b.length?(a=b.shift(),2===a.length?(a(t,w),d()):3===a.length&&t.async?a(t,w,d):d()):i(4)})()},k=t.xhr=f(),H.onreadystatechange=function(a){try{2===H[o]&&r()}catch(a){}4===H[o]&&(C=!1,r(),q()),x(H[o])},m=function(){l=!0},k[n]("error",m),k[n]("timeout",m),k[n]("abort",m),k[n]("progress",function(){b<3?x(3):k[h]("readystatechange",{})}),("withCredentials"in H||E.addWithCredentials)&&(k.withCredentials=!1),k.status=0,K=e.concat(p);for(I=0,J=K.length;I=0||(f=f===b?d[a].length:f,d[a].splice(f,0,c))},c[m]=function(a,c){var f;if(a===b)return void(d={});c===b&&(d[a]=[]),f=e(a).indexOf(c),f!==-1&&e(a).splice(f,1)},c[h]=function(){var b,d,f,g,h,i,j,k;for(b=C(arguments),d=b.shift(),a||(b[0]=z(b[0],y(d))),g=c["on"+d],g&&g.apply(c,b),k=e(d).concat(e("*")),f=i=0,j=k.length;i2)throw"invalid hook";return E[n](d,a,b)},E[c]=function(a,b){if(a.length<2||a.length>3)throw"invalid hook";return E[n](c,a,b)},E.enable=function(){q[u]=t,"function"==typeof r&&(q[g]=r),k&&(q[i]=s)},E.disable=function(){q[u]=E[u],q[g]=E[g],k&&(q[i]=k)},v=E.headers=function(a,b){var c,d,e,f,g,h,i,j,k;switch(null==b&&(b={}),typeof a){case"object":d=[];for(e in a)g=a[e],f=e.toLowerCase(),d.push(f+":\t"+g);return d.join("\n");case"string":for(d=a.split("\n"),i=0,j=d.length;ib&&b<4;)k[o]=++b,1===b&&k[h]("loadstart",{}),2===b&&F(),4===b&&(F(),D()),k[h]("readystatechange",{}),4===b&&setTimeout(g,0)},g=function(){l||k[h]("load",{}),k[h]("loadend",{}),l&&(k[o]=0)},b=0,x=function(a){var b,d;if(4!==a)return void i(a);b=E.listeners(c),(d=function(){var a;return b.length?(a=b.shift(),2===a.length?(a(t,w),d()):3===a.length&&t.async?a(t,w,d):d()):i(4)})()},k=t.xhr=f(),k.response=H.response,k.responseText=H.responseText,k.responseXML=H.responseXML,k.responseURL=H.responseURL,k.readyState=H.readyState,k.status=H.status,k.statusText=H.statusText,H.onreadystatechange=function(a){try{2===H[o]&&r()}catch(a){}4===H[o]&&(C=!1,r(),q()),x(H[o])},m=function(){l=!0},k[n]("error",m),k[n]("timeout",m),k[n]("abort",m),k[n]("progress",function(){b<3?x(3):k[h]("readystatechange",{})}),("withCredentials"in H||E.addWithCredentials)&&(k.withCredentials=!1),k.status=0,K=e.concat(p);for(I=0,J=K.length;I