1 line
7.5 KiB
JavaScript
1 line
7.5 KiB
JavaScript
!function(f){"use strict";function i(e){return!!e&&("Symbol"in f&&"iterator"in f.Symbol&&"function"==typeof e[Symbol.iterator]||!!Array.isArray(e))}function o(e){return"from"in Array?Array.from(e):Array.prototype.slice.call(e)}!function(){var u,l=f.URL;try{if(l){if("searchParams"in(u=new f.URL("http://example.com"))){var e=new n("http://example.com");if(e.search="a=1&b=2","http://example.com/?a=1&b=2"===e.href&&(e.search="","http://example.com/"===e.href))return}"href"in u||(u=void 0),u=void 0}}catch(e){}function a(e){var r="",a=!0;return e.forEach(function(e){var t=encodeURIComponent(e.name),n=encodeURIComponent(e.value);a||(r+="&"),r+=t+"="+n,a=!1}),r.replace(/%20/g,"+")}function c(e,t){var n=e.split("&");t&&-1===n[0].indexOf("=")&&(n[0]="="+n[0]);var a=[];n.forEach(function(e){if(0!==e.length){var t=e.indexOf("=");if(-1!==t)var n=e.substring(0,t),r=e.substring(t+1);else n=e,r="";n=n.replace(/\+/g," "),r=r.replace(/\+/g," "),a.push({name:n,value:r})}});var r=[];return a.forEach(function(e){r.push({name:decodeURIComponent(e.name),value:decodeURIComponent(e.value)})}),r}function s(t){var n=this;this._list=[],null==t||(t instanceof s?this._list=c(String(t)):"object"==typeof t&&i(t)?o(t).forEach(function(e){if(!i(e))throw TypeError();var t=o(e);if(2!==t.length)throw TypeError();n._list.push({name:String(t[0]),value:String(t[1])})}):"object"==typeof t&&t?Object.keys(t).forEach(function(e){n._list.push({name:String(e),value:String(t[e])})}):("?"===(t=String(t)).substring(0,1)&&(t=t.substring(1)),this._list=c(t))),this._url_object=null;var r=!(this._setList=function(e){r||(n._list=e)});this._update_steps=function(){r||(r=!0,n._url_object&&("about:"===n._url_object.protocol&&-1!==n._url_object.pathname.indexOf("?")&&(n._url_object.pathname=n._url_object.pathname.split("?")[0]),n._url_object.search=a(n._list),r=!1))}}function t(t,n){var r=0;this.next=function(){if(r>=t.length)return{done:!0,value:void 0};var e=t[r++];return{done:!1,value:"key"===n?e.name:"value"===n?e.value:[e.name,e.value]}}}function n(a,i){if(!(this instanceof f.URL))throw new TypeError("Failed to construct 'URL': Please use the 'new' operator.");i&&(a=function(){if(u)return new l(a,i).href;var e;try{var t;if("[object OperaMini]"===Object.prototype.toString.call(window.operamini)?((e=document.createElement("iframe")).style.display="none",document.documentElement.appendChild(e),t=e.contentWindow.document):document.implementation&&document.implementation.createHTMLDocument?t=document.implementation.createHTMLDocument(""):document.implementation&&document.implementation.createDocument?((t=document.implementation.createDocument("http://www.w3.org/1999/xhtml","html",null)).documentElement.appendChild(t.createElement("head")),t.documentElement.appendChild(t.createElement("body"))):window.ActiveXObject&&((t=new window.ActiveXObject("htmlfile")).write("<head></head><body></body>"),t.close()),!t)throw Error("base not supported");var n=t.createElement("base");n.href=i,t.getElementsByTagName("head")[0].appendChild(n);var r=t.createElement("a");return r.href=a,r.href}finally{e&&e.parentNode.removeChild(e)}}());var t=function(e){if(u)return new l(e);var t=document.createElement("a");return t.href=e,t}(a||""),e=function(){if(!("defineProperties"in Object))return!1;try{var e={};return Object.defineProperties(e,{prop:{get:function(){return!0}}}),e.prop}catch(e){return!1}}()?this:document.createElement("a"),n=new s(t.search?t.search.substring(1):null);function r(){var e=t.href.replace(/#$|\?$|\?(?=#)/g,"");t.href!==e&&(t.href=e)}function o(){n._setList(t.search?c(t.search.substring(1)):[]),n._update_steps()}return n._url_object=e,Object.defineProperties(e,{href:{get:function(){return t.href},set:function(e){t.href=e,r(),o()},enumerable:!0,configurable:!0},origin:{get:function(){return"origin"in t?t.origin:this.protocol+"//"+this.host},enumerable:!0,configurable:!0},protocol:{get:function(){return t.protocol},set:function(e){t.protocol=e},enumerable:!0,configurable:!0},username:{get:function(){return t.username},set:function(e){t.username=e},enumerable:!0,configurable:!0},password:{get:function(){return t.password},set:function(e){t.password=e},enumerable:!0,configurable:!0},host:{get:function(){var e={"http:":/:80$/,"https:":/:443$/,"ftp:":/:21$/}[t.protocol];return e?t.host.replace(e,""):t.host},set:function(e){t.host=e},enumerable:!0,configurable:!0},hostname:{get:function(){return t.hostname},set:function(e){t.hostname=e},enumerable:!0,configurable:!0},port:{get:function(){return t.port},set:function(e){t.port=e},enumerable:!0,configurable:!0},pathname:{get:function(){return"/"!==t.pathname.charAt(0)?"/"+t.pathname:t.pathname},set:function(e){t.pathname=e},enumerable:!0,configurable:!0},search:{get:function(){return t.search},set:function(e){t.search!==e&&(t.search=e,r(),o())},enumerable:!0,configurable:!0},searchParams:{get:function(){return n},enumerable:!0,configurable:!0},hash:{get:function(){return t.hash},set:function(e){t.hash=e,r()},enumerable:!0,configurable:!0},toString:{value:function(){return t.toString()},enumerable:!1,configurable:!0},valueOf:{value:function(){return t.valueOf()},enumerable:!1,configurable:!0}}),e}if(Object.defineProperties(s.prototype,{append:{value:function(e,t){this._list.push({name:e,value:t}),this._update_steps()},writable:!0,enumerable:!0,configurable:!0},delete:{value:function(e){for(var t=0;t<this._list.length;)this._list[t].name===e?this._list.splice(t,1):++t;this._update_steps()},writable:!0,enumerable:!0,configurable:!0},get:{value:function(e){for(var t=0;t<this._list.length;++t)if(this._list[t].name===e)return this._list[t].value;return null},writable:!0,enumerable:!0,configurable:!0},getAll:{value:function(e){for(var t=[],n=0;n<this._list.length;++n)this._list[n].name===e&&t.push(this._list[n].value);return t},writable:!0,enumerable:!0,configurable:!0},has:{value:function(e){for(var t=0;t<this._list.length;++t)if(this._list[t].name===e)return!0;return!1},writable:!0,enumerable:!0,configurable:!0},set:{value:function(e,t){for(var n=!1,r=0;r<this._list.length;)this._list[r].name===e?n?this._list.splice(r,1):(this._list[r].value=t,n=!0,++r):++r;n||this._list.push({name:e,value:t}),this._update_steps()},writable:!0,enumerable:!0,configurable:!0},entries:{value:function(){return new t(this._list,"key+value")},writable:!0,enumerable:!0,configurable:!0},keys:{value:function(){return new t(this._list,"key")},writable:!0,enumerable:!0,configurable:!0},values:{value:function(){return new t(this._list,"value")},writable:!0,enumerable:!0,configurable:!0},forEach:{value:function(t){var n=1<arguments.length?arguments[1]:void 0;this._list.forEach(function(e){t.call(n,e.value,e.name)})},writable:!0,enumerable:!0,configurable:!0},toString:{value:function(){return a(this._list)},writable:!0,enumerable:!1,configurable:!0}}),"Symbol"in f&&"iterator"in f.Symbol&&(Object.defineProperty(s.prototype,f.Symbol.iterator,{value:s.prototype.entries,writable:!0,enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,f.Symbol.iterator,{value:function(){return this},writable:!0,enumerable:!0,configurable:!0})),l)for(var r in l)l.hasOwnProperty(r)&&"function"==typeof l[r]&&(n[r]=l[r]);f.URL=n,f.URLSearchParams=s}(),function(){if("1"!==new f.URLSearchParams([["a",1]]).get("a")||"1"!==new f.URLSearchParams({a:1}).get("a")){var e=f.URLSearchParams;f.URLSearchParams=function(t){if(t&&"object"==typeof t&&i(t)){var n=new e;return o(t).forEach(function(e){if(!i(e))throw TypeError();var t=o(e);if(2!==t.length)throw TypeError();n.append(t[0],t[1])}),n}return t&&"object"==typeof t?(n=new e,Object.keys(t).forEach(function(e){n.set(e,t[e])}),n):new e(t)}}}()}(self); |