young-call-app
Version:
3 lines (2 loc) • 6.46 kB
JavaScript
;function d(e){let o;if(e.nodeName==="SELECT")e.focus(),o=e.value;else if(e.nodeName==="INPUT"||e.nodeName==="TEXTAREA"){var r=e.hasAttribute("readonly");r||e.setAttribute("readonly",""),e.select(),e.setSelectionRange(0,e.value.length),r||e.removeAttribute("readonly"),o=e.value}else{e.hasAttribute("contenteditable")&&e.focus();const t=window.getSelection(),i=document.createRange();i.selectNodeContents(e),t.removeAllRanges(),t.addRange(i),o=t.toString()}return o}function f(e,o){let r,t,i=!1;o=o||{},r=o.debug||!1;try{const s=document.documentElement.getAttribute("dir")=="rtl";t=document.createElement("textarea"),t.style.fontSize="12pt",t.style.border="0",t.style.padding="0",t.style.margin="0",t.style.position="absolute",t.style[s?"right":"left"]="-9999px";let n=window.pageYOffset||document.documentElement.scrollTop;if(t.style.top=`${n}px`,t.setAttribute("readonly",""),t.value=e,document.body.appendChild(t),d(t),!document.execCommand("copy"))throw new Error("copy command was unsuccessful");i=!0}catch(s){r&&console.error("unable to copy using execCommand: ",s),r&&console.warn("trying IE specific stuff");try{window.clipboardData.setData("text",e),i=!0}catch(n){r&&console.error("unable to copy using clipboardData: ",n)}}finally{t&&document.body.removeChild(t)}return i}function u(e){return function(o){return Object.prototype.toString.call(o)==="[object "+e+"]"}}function p(e,o){for(let r=0,t=e.length;r<t&&o.call(e,e[r],r)!==!1;r++);}class w{constructor(o){this._rules=o}_detect(o,r,t){const i=u("Function")(r)?r.call(null,t):r;if(!i)return null;const s={name:o,version:"0",codename:""};if(i===!0)return s;if(u("String")(i)){if(t.indexOf(i)!==-1)return s}else{if(u("Object")(i))return i.hasOwnProperty("version")&&(s.version=i.version),s;if(u("RegExp")(i)){const n=i.exec(t);if(n)return n.length>=2&&n[1]&&(s.version=n[1].replace(/_/g,".")),s}}}_parseItem(o,r,t,i){let s=this,n={name:"na",version:"0"};p(r,function(a){const l=s._detect(a[0],a[1],o);if(l)return n=l,!1}),t.call(i,n.name,n.version)}parse(o){o=(o||"").toLowerCase();const r={};return this._parseItem(o,this._rules.os,function(t,i){const s=parseFloat(i);r.os={name:t,version:s,fullVersion:i},r.os[t]=s},r),this._parseItem(o,this._rules.browser,function(t,i){let s=i;const n=parseFloat(i);r.browser={name:t,version:n,fullVersion:i,mode:parseFloat(s),fullMode:s},r.browser[t]=n},r),r}}const m=[["ios",function(e){return/\bcpu(?: iphone)? os /.test(e)?/\bcpu(?: iphone)? os ([0-9._]+)/:e.indexOf("iph os ")!==-1?/\biph os ([0-9_]+)/:/\bios\b/}],["android",function(e){return e.indexOf("android")>=0?/\bandroid[ \/-]?([0-9.x]+)?/:e.indexOf("adr")>=0?e.indexOf("mqqbrowser")>=0?/\badr[ ]\(linux; u; ([0-9.]+)?/:/\badr(?:[ ]([0-9.]+))?/:"android"}],["wp",function(e){return e.indexOf("windows phone ")!==-1?/\bwindows phone (?:os )?([0-9.]+)/:e.indexOf("xblwp")!==-1?/\bxblwp([0-9.]+)/:e.indexOf("zunewp")!==-1?/\bzunewp([0-9.]+)/:"windows phone"}],["symbian",/\bsymbian(?:os)?\/([0-9.]+)/],["chromeos",/\bcros i686 ([0-9.]+)/],["linux","linux"],["windowsce",/\bwindows ce(?: ([0-9.]+))?/]],h=[["micromessenger",/\bmicromessenger\/([\d.]+)/],["qq",/\bqq/i],["qzone",/qzone\/.*_qz_([\d.]+)/i],["qqbrowser",/\bm?qqbrowser\/([0-9.]+)/],["tt",/\btencenttraveler ([0-9.]+)/],["weibo",/weibo__([0-9.]+)/],["uc",function(e){return e.indexOf("ucbrowser/")>=0?/\bucbrowser\/([0-9.]+)/:e.indexOf("ubrowser/")>=0?/\bubrowser\/([0-9.]+)/:/\buc\/[0-9]/.test(e)?/\buc\/([0-9.]+)/:e.indexOf("ucweb")>=0?/\bucweb([0-9.]+)?/:/\b(?:ucbrowser|uc)\b/}],["360",function(e){return e.indexOf("360 aphone browser")!==-1?/\b360 aphone browser \(([^\)]+)\)/:/\b360(?:se|ee|chrome|browser)\b/}],["baidu",function(e){let o=0,r;return/ baiduboxapp\//i.test(e)?((r=/([\d+.]+)_(?:diordna|enohpi)_/.exec(e))?(r=r[1].split("."),o=r.reverse().join(".")):(r=/baiduboxapp\/([\d+.]+)/.exec(e))&&(o=r[1]),{version:o}):!1}],["baidubrowser",/\b(?:ba?idubrowser|baiduhd)[ \/]([0-9.x]+)/],["bdminivideo",/bdminivideo\/([0-9.]+)/],["sogou",function(e){return e.indexOf("sogoumobilebrowser")>=0?/sogoumobilebrowser\/([0-9.]+)/:e.indexOf("sogoumse")>=0?!0:/ se ([0-9.x]+)/}],["ali-ap",function(e){return e.indexOf("aliapp")>0?/\baliapp\(ap\/([0-9.]+)\)/:/\balipayclient\/([0-9.]+)\b/}],["ali-tb",/\baliapp\(tb\/([0-9.]+)\)/],["ali-tm",/\baliapp\(tm\/([0-9.]+)\)/],["tao",/\btaobrowser\/([0-9.]+)/],["mi",/\bmiuibrowser\/([0-9.]+)/],["oppo",/\boppobrowser\/([0-9.]+)/],["vivo",/\bvivobrowser\/([0-9.]+)/],["meizu",/\bmzbrowser\/([0-9.]+)/],["nokia",/\bnokiabrowser\/([0-9.]+)/],["samsung",/\bsamsungbrowser\/([0-9.]+)/],["maxthon",/\b(?:maxthon|mxbrowser)(?:[ \/]([0-9.]+))?/],["opera",function(e){const o=/\bopera.+version\/([0-9.ab]+)/,r=/\bopr\/([0-9.]+)/;return o.test(e)?o:r}],["edge",/edge\/([0-9.]+)/],["firefox",/\bfirefox\/([0-9.ab]+)/],["chrome",/ (?:chrome|crios|crmo)\/([0-9.]+)/],["android",function(e){if(e.indexOf("android")!==-1)return/\bversion\/([0-9.]+(?: beta)?)/}],["safari",/\bversion\/([0-9.]+(?: beta)?)(?: mobile(?:\/[a-z0-9]+)?)? safari\//],["webview",/\bcpu(?: iphone)? os (?:[0-9._]+).+\bapplewebkit\b/]],g=new w({os:m,browser:h}),x=navigator.userAgent+" "+navigator.appVersion+" "+navigator.vendor,b=g.parse(x),y=b.os.name==="ios",c=b.browser.name==="micromessenger",v={timeout:2500,mask:{wechat:()=>null},startCall:()=>console.log("---\u5F00\u59CB\u5524\u7AEF---"),callFail:()=>console.log("---\u5524\u8D77\u5931\u8D25\uFF0C\u8DF3\u8F6C\u4E0B\u8F7D---")};class O{constructor(o,r={}){this.options=Object.assign(v,r),this.generateScheme(o)}generateScheme(o){var s,n;let r="",t="",i="(\u590D\u5236\u6B64\u6D88\u606F\u6253\u5F00app)|";if(y?(r+=`${o.ios_shceme}://`,t=(o==null?void 0:o.download.ios)||o.landpage):(r+=`${o.android_shceme}://`,t=((s=o==null?void 0:o.download)==null?void 0:s.yyb)||o.landpage,c&&((n=o==null?void 0:o.download)==null?void 0:n.yyb)&&(t=o.download.yyb)),o.path&&(r+=o.path),o.params){const a=new URLSearchParams(o.params).toString();r+=`?${a}`,i+=a}this.scheme=r,this.download=t,this.info=i}call(){const{mask:o,startCall:r}=this.options;if(c&&o.wechat){o.wechat();return}this.copyInfo(),r==null||r(),window.location.href=this.scheme,this.fallback()}copyInfo(){f(this.info)}fallback(){const o=setTimeout(()=>{var r,t;(t=(r=this.options).callFail)==null||t.call(r),window.location.href=this.download},this.options.timeout);setTimeout(()=>{window.addEventListener("blur",()=>clearTimeout(o))},this.options.timeout-500)}}module.exports=O;
//# sourceMappingURL=index.cjs.js.map