lester-tools
Version:
lester's js tool library
1 lines • 14.2 kB
JavaScript
var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};e.d(t,{FN:()=>a,Mi:()=>Te,YN:()=>_,JG:()=>i,_o:()=>Se,x5:()=>r,ej:()=>d,l7:()=>p,Ph:()=>u,kD:()=>f,tq:()=>l,oE:()=>Ce,UG:()=>c,Y2:()=>o,Td:()=>s,gz:()=>De});var n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},r=function(){var e=document.body,t=document.documentElement;return e.clientWidth||t.clientWidth||window.innerWidth||375},o=r()/375,a={info:function(e,t,n){void 0===t&&(t=2);var r=n||document.body,o=document.createElement("div");o.innerText=e,o.style.position=n?"absolute":"fixed",o.style.left="50%",o.style.top="50%",o.style.maxWidth="150px",o.style.lineHeight="20px",o.style.transform="translate(-50%, -50%)",o.style.backgroundColor="rgba(0, 0, 0, 0.8)",o.style.padding="8px 15px",o.style.borderRadius="5px",o.style.fontSize="12px",o.style.color="#ffffff",o.style.zIndex="99999",r.appendChild(o),setTimeout((function(){r.removeChild(o)}),1e3*t)},success:function(e,t){void 0===t&&(t=2),this.info(e,t)},fail:function(e,t){void 0===t&&(t=2),this.info(e,t)}},i=function(e,t){void 0===t&&(t=!0);var n=document.createElement("textarea");n.value=e,document.body.appendChild(n),n.select(),document.execCommand("copy"),document.body.removeChild(n),t&&a.info("\u590d\u5236\u6210\u529f")},s=function(e){document.title=e;var t=document.createElement("iframe");t.style.cssText="display: none; width: 0; height: 0;",t.src="";var n=function(){setTimeout((function(){t.removeEventListener("load",n),setTimeout((function(){document.body.removeChild(t)}),0)}),0)};t.addEventListener("load",n),document.body.appendChild(t)},c=function(e){void 0===e&&(e=window.location.search);var t=e.indexOf("?"),n=(t>-1?e.slice(t+1):e).split("&"),r={};return n.forEach((function(e){var t=e.split("=");r[t[0]]=t[1]})),r},u=function(e){var t=window.location,r=t.hash,o=t.search,a=r.indexOf("?"),i={};return a>-1&&(i=c(r.slice(a))),o&&(i=n(n({},i),c(o))),e?i[e]||null:i},l=function(){return/Android|webOS|iPhone|iPod|BlackBerry/i.test(window.navigator.userAgent)},d=function(e){if(!document.cookie||!window.navigator.cookieEnabled)return"";var t=new RegExp("".concat(e,"=([\\w]+)"));return(document.cookie.match(t)||[])[1]},f=function(){return Math.random().toString(36).slice(2)},p=function(e){var t=e||window.navigator.userAgent.toLowerCase();return/windows/.test(t)?"windows":/iphone|ipod/.test(t)?"ios":/ipad/.test(t)?"ipad":/android/.test(t)?"android":/mac/.test(t)?"mac":"others"},v=[19416,19168,42352,21717,53856,55632,91476,22176,39632,21970,19168,42422,42192,53840,119381,46400,54944,44450,38320,84343,18800,42160,46261,27216,27968,109396,11104,38256,21234,18800,25958,54432,59984,28309,23248,11104,100067,37600,116951,51536,54432,120998,46416,22176,107956,9680,37584,53938,43344,46423,27808,46416,86869,19872,42448,83315,21200,43432,59728,27296,44710,43856,19296,43748,42352,21088,62051,55632,23383,22176,38608,19925,19152,42192,54484,53840,54616,46400,46496,103846,38320,18864,43380,42160,45690,27216,27968,44870,43872,38256,19189,18800,25776,29859,59984,27480,21952,43872,38613,37600,51552,55636,54432,55888,30034,22176,43959,9680,37584,51893,43344,46240,47780,44368,21977,19360,42416,86390,21168,43312,31060,27296,44368,23378,19296,42726,42208,53856,60005,54576,23200,30371,38608,19415,19152,42192,118966,53840,54560,56645,46496,22224,21938,18864,42359,42160,43600,111189,27936,44448],y=["\u7532","\u4e59","\u4e19","\u4e01","\u620a","\u5df1","\u5e9a","\u8f9b","\u58ec","\u7678"],h=["\u5b50","\u4e11","\u5bc5","\u536f","\u8fb0","\u5df3","\u5348","\u672a","\u7533","\u9149","\u620c","\u4ea5"],m=new Date,g=m.getFullYear(),w=m.getMonth(),b=m.getDate(),x=m.getFullYear(),C=m.getMonth()+1,D=m.getDate(),T=m.getHours(),S=m.getMinutes(),E=m.getSeconds(),k=C.toString().padStart(2,"0"),M=D.toString().padStart(2,"0"),O=T.toString().padStart(2,"0"),A=S.toString().padStart(2,"0"),U=E.toString().padStart(2,"0");function P(e){return 15&v[e-1900]}function Y(e){return P(e)?65536&v[e-1900]?30:29:0}function L(e){var t,n=348;for(t=32768;t>8;t>>=1)n+=v[e-1900]&t?1:0;return n+Y(e)}function R(e,t){return v[e-1900]&65536>>t?30:29}function j(e,t){var n,r,o=["\u65e5","\u4e00","\u4e8c","\u4e09","\u56db","\u4e94","\u516d","\u4e03","\u516b","\u4e5d","\u5341"];switch(n=e>10?"\u5341"+o[e-10]:o[e],n+="\u6708",t){case 10:r="\u521d\u5341";break;case 20:r="\u4e8c\u5341";break;case 30:r="\u4e09\u5341";break;default:r=["\u521d","\u5341","\u5eff","\u5345",""][Math.floor(t/10)]+o[t%10]}return{lunarMonthCn:n,lunarDayCn:r}}var z={};z.gregorianYear=x,z.gregorianMonth=k,z.gregorianDay=M,z.weekday=["\u661f\u671f\u65e5","\u661f\u671f\u4e00","\u661f\u671f\u4e8c","\u661f\u671f\u4e09","\u661f\u671f\u56db","\u661f\u671f\u4e94","\u661f\u671f\u516d"][m.getDay()],z.weekdayEn=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][m.getDay()],z.hours=O,z.minutes=A,z.seconds=U;var B,I,N,W,F,G=function(e){var t,n=0,r=new Date(1900,0,31),o=Math.floor((e.getTime()-r.getTime())/864e5),a=o+40,i=14;for(t=1900;t<2050&&o>0;t++)o-=n=L(t),i+=12;o<0&&(o+=n,t--,i-=12);var s=t,c=t-1864,u=P(t),l=!1;for(t=1;t<13&&o>0;t++)u>0&&t===u+1&&!1===l?(--t,l=!0,n=Y(s)):n=R(s,t),!0===l&&t===u+1&&(l=!1),o-=n,!1===l&&i++;return 0===o&&u>0&&t===u+1&&(l?l=!1:(l=!0,--t,--i)),o<0&&(o+=n,--t,--i),{year:s,month:t,day:o+1,isLeap:l,leap:u,yearCyl:c,dayCyl:a,monCyl:i}}(new Date(g,w,b));z.lunarYear=G.year,z.lunarMonth=G.month,z.lunarDay=G.day,z.zodiacYear=["\u9f20","\u725b","\u864e","\u5154","\u9f99","\u86c7","\u9a6c","\u7f8a","\u7334","\u9e21","\u72d7","\u732a"][(g-4)%12],z.lunarYearCn=y[(B=g-1900+36)%10]+h[B%12],z.lunarMonthCn=j(G.month,G.day).lunarMonthCn,z.lunarDayCn=j(G.month,G.day).lunarDayCn,z.solarTerm=(I=[0,21208,42467,63836,85337,107014,128867,150921,173149,195551,218072,240693,263343,285989,308563,331033,353350,375494,397447,419210,440795,462224,483532,504758],N=["\u5c0f\u5bd2","\u5927\u5bd2","\u7acb\u6625","\u96e8\u6c34","\u60ca\u86f0","\u6625\u5206","\u6e05\u660e","\u8c37\u96e8","\u7acb\u590f","\u5c0f\u6ee1","\u8292\u79cd","\u590f\u81f3","\u5c0f\u6691","\u5927\u6691","\u7acb\u79cb","\u5904\u6691","\u767d\u9732","\u79cb\u5206","\u5bd2\u9732","\u971c\u964d","\u7acb\u51ac","\u5c0f\u96ea","\u5927\u96ea","\u51ac\u81f3"],W="",F=new Date(31556925974.7*(g-1900)+6e4*I[2*w+1]+Date.UTC(1900,0,6,2,5)),F.getUTCDate()===b&&(W=N[2*w+1]),(F=new Date(31556925974.7*(g-1900)+6e4*I[2*w]+Date.UTC(1900,0,6,2,5))).getUTCDate()===b&&(W=N[2*w]),W);const _=z;function q(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}c((r=r.apply(e,t||[])).next())}))}function H(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}}var J=function(e){};function Q(e){J(e)}var K=!0;function V(){return K}(function(){(console.warn||console.log).apply(console,arguments)}).bind("[clipboard-polyfill]");var X,Z,$,ee,te="undefined"==typeof navigator?void 0:navigator,ne=null==te?void 0:te.clipboard,re=(null===(X=null==ne?void 0:ne.read)||void 0===X||X.bind(ne),null===(Z=null==ne?void 0:ne.readText)||void 0===Z||Z.bind(ne),null===($=null==ne?void 0:ne.write)||void 0===$?void 0:$.bind(ne)),oe=(null===(ee=null==ne?void 0:ne.writeText)||void 0===ee||ee.bind(ne),"undefined"==typeof window?void 0:window),ae=null==oe?void 0:oe.ClipboardItem,ie=oe;function se(){return"undefined"==typeof ClipboardEvent&&void 0!==ie.clipboardData&&void 0!==ie.clipboardData.setData}var ce=function(){this.success=!1};function ue(e,t,n){for(var r in Q("listener called"),e.success=!0,t){var o=t[r],a=n.clipboardData;a.setData(r,o),"text/plain"===r&&a.getData(r)!==o&&(Q("setting text/plain failed"),e.success=!1)}n.preventDefault()}function le(e){var t=new ce,n=ue.bind(this,t,e);document.addEventListener("copy",n);try{document.execCommand("copy")}finally{document.removeEventListener("copy",n)}return t.success}function de(e,t){fe(e);var n=le(t);return pe(),n}function fe(e){var t=document.getSelection();if(t){var n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}}function pe(){var e=document.getSelection();e&&e.removeAllRanges()}function ve(e){return q(this,void 0,void 0,(function(){var t;return H(this,(function(n){if(t="text/plain"in e,se()){if(!t)throw new Error("No `text/plain` value was specified.");if(r=e["text/plain"],ie.clipboardData.setData("Text",r))return[2,!0];throw new Error("Copying failed, possibly because the user rejected it.")}var r;return le(e)?(Q("regular execCopy worked"),[2,!0]):navigator.userAgent.indexOf("Edge")>-1?(Q('UA "Edge" => assuming success'),[2,!0]):de(document.body,e)?(Q("copyUsingTempSelection worked"),[2,!0]):function(e){var t=document.createElement("div");t.setAttribute("style","-webkit-user-select: text !important"),t.textContent="temporary element",document.body.appendChild(t);var n=de(t,e);return document.body.removeChild(t),n}(e)?(Q("copyUsingTempElem worked"),[2,!0]):function(e){Q("copyTextUsingDOM");var t=document.createElement("div");t.setAttribute("style","-webkit-user-select: text !important");var n=t;t.attachShadow&&(Q("Using shadow DOM."),n=t.attachShadow({mode:"open"}));var r=document.createElement("span");r.innerText=e,n.appendChild(r),document.body.appendChild(t),fe(r);var o=document.execCommand("copy");return pe(),document.body.removeChild(t),o}(e["text/plain"])?(Q("copyTextUsingDOM worked"),[2,!0]):[2,!1]}))}))}function ye(e,t){for(var n=0,r=e;n<r.length;n++)if(-1!==r[n].types.indexOf(t))return!0;return!1}var he=function(){function e(e,t){var n;for(var r in void 0===t&&(t={}),this.types=Object.keys(e),this._items={},e){var o=e[r];this._items[r]="string"==typeof o?me(r,o):o}this.presentationStyle=null!==(n=null==t?void 0:t.presentationStyle)&&void 0!==n?n:"unspecified"}return e.prototype.getType=function(e){return q(this,void 0,void 0,(function(){return H(this,(function(t){return[2,this._items[e]]}))}))},e}();function me(e,t){return new Blob([t],{type:e})}function ge(e){return q(this,void 0,void 0,(function(){return H(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){var e=r.result;"string"==typeof e?t(e):n("could not convert blob to string")})),r.readAsText(e)}))]}))}))}function we(e){return q(this,void 0,void 0,(function(){var t,n,r,o,a,i,s;return H(this,(function(c){switch(c.label){case 0:t={},n=0,r=e.types,c.label=1;case 1:return n<r.length?(o=r[n],a=t,i=o,[4,e.getType(o)]):[3,4];case 2:a[i]=c.sent(),c.label=3;case 3:return n++,[3,1];case 4:return s={},e.presentationStyle&&(s.presentationStyle=e.presentationStyle),[2,new ae(t,s)]}}))}))}function be(e,t){return q(this,void 0,void 0,(function(){return H(this,(function(n){switch(n.label){case 0:return[4,e.getType(t)];case 1:return[4,ge(n.sent())];case 2:return[2,n.sent()]}}))}))}function xe(e){return q(this,void 0,void 0,(function(){var t,n,r,o,a,i;return H(this,(function(s){switch(s.label){case 0:t={},n=0,r=e.types,s.label=1;case 1:return n<r.length?(o=r[n],a=t,i=o,[4,be(e,o)]):[3,4];case 2:a[i]=s.sent(),s.label=3;case 3:return n++,[3,1];case 4:return[2,t]}}))}))}var Ce=function(){var e=new IntersectionObserver((function(e){e.forEach((function(e){e.isIntersecting&&e.target.dataset.src&&(e.target.src=e.target.dataset.src)}))}));Array.from(document.getElementsByTagName("img")).filter((function(e){return!e.getAttribute("src")})).forEach((function(t){e.observe(t)}))},De="IntersectionObserver"in window,Te=function(e,t,n){void 0===t&&(t="image/png"),void 0===n&&(n=512);for(var r=window.atob(e.split(",")[1]),o=[],a=0;a<r.length;a+=n){for(var i=r.slice(a,a+n),s=new Array(i.length),c=0;c<i.length;c++)s[c]=i.charCodeAt(c);var u=new Uint8Array(s);o.push(u)}return new Blob(o,{type:t})},Se=function(e,t){!function(e){q(this,void 0,void 0,(function(){var t,n,r,o;return H(this,(function(a){switch(a.label){case 0:return re&&ae?(Q("Using `navigator.clipboard.write()`."),[4,Promise.all(e.map(we))]):[3,5];case 1:t=a.sent(),a.label=2;case 2:return a.trys.push([2,4,,5]),[4,re(t)];case 3:return[2,a.sent()];case 4:if(n=a.sent(),!ye(e,"text/plain")&&!ye(e,"text/html"))throw n;return[3,5];case 5:return r=ye(e,"text/plain"),V&&!r&&Q("clipboard.write() was called without a `text/plain` data type. On some platforms, this may result in an empty clipboard. Call suppressWarnings() to suppress this warning."),o=ve,[4,xe(e[0])];case 6:if(!o.apply(void 0,[a.sent()]))throw new Error("write() failed");return[2]}}))}))}([new he({"image/png":Te(e)})]),t&&a.success("\u590d\u5236\u6210\u529f")},Ee=t.FN,ke=t.Mi,Me=t.YN,Oe=t.JG,Ae=t._o,Ue=t.x5,Pe=t.ej,Ye=t.l7,Le=t.Ph,Re=t.kD,je=t.tq,ze=t.oE,Be=t.UG,Ie=t.Y2,Ne=t.Td,We=t.gz;export{Ee as Toast,ke as b64toBlob,Me as calendar,Oe as copy,Ae as copyBase64Img,Ue as getClientWidth,Pe as getCookie,Ye as getDeviceType,Le as getQueryParam,Re as getRandomStr,je as isMobile,ze as lazyLoadImg,Be as parseSearch,Ie as screenRate,Ne as setTitle,We as supportLazy};