// var window.mode_env = 'development'; window.mode_env = 'production'; let API_URL=window.themeConfig.api; // if ( // window.location.href.indexOf('localhost') >= 0 || // window.location.href.indexOf('192.168.1.') >= 0 || // window.location.href.indexOf('192.168.11.') >= 0 || // window.location.href.indexOf('10.10.100.') >= 0 || // window.location.href.indexOf('bigwinga.me') >= 0 || // window.location.href.indexOf('thekongfu.com') >= 0 || // window.location.href.indexOf('kysdkllc.com') >= 0 // ) { // window.mode_env = 'development'; // } else { // window.mode_env = 'production'; // } // 初始化 渠道信息 var SingletonChannelInfo = (function () { // 存储单例实例的变量 var instance; // 初始化实例的函数 function init(newh2, newh3, newh4) { var h2 = newh2 || 'h5'; var h3 = newh3 || 'web'; var h4 = newh4 || ''; return { // 公有方法和属性 h2, h3, h4 }; } return { // 获取单例的实例的方法 getInstance: function (...args) { if (!instance && args.length > 0) { instance = init(...args); // 如果实例不存在,创建它 } if (!instance && args.length === 0) { instance = init(); } return instance; // 返回单例实例 } }; })(); // function getCookie(key) { // const cookie = document.cookie; // const cookieArr = cookie.split(";"); // const cookieObj = {}; // cookieArr.forEach((item) => { // const [key, value] = item.split("="); // cookieObj[key.trim()] = value; // }); // return key ? cookieObj[key] : cookieObj; // } window.hasFixexpire = false; function getCookie(key) { const cookie = document.cookie; const cookieArr = cookie.split(';'); const cookieObj = {}; cookieArr.forEach(item => { const [k, v] = item.split('='); const trimmedKey = k ? k.trim() : ''; const trimmedValue = v ? v.trim() : ''; if (trimmedKey && trimmedValue) cookieObj[trimmedKey] = trimmedValue; }); if (!window.hasFixexpire) { if (cookieObj['winus_uuid']) { setCookie('winus_uuid', cookieObj['winus_uuid']); } if (cookieObj['us_h5_sourceurl_key']) { setCookie('us_h5_sourceurl_key', cookieObj['us_h5_sourceurl_key']); } window.hasFixexpire = true; } return key ? cookieObj[key] : cookieObj; } function setCookie(key, value, expires = 365 * 24 * 60 * 60 * 1000) { const date = new Date(); date.setTime(date.getTime() + expires); document.cookie = `${key}=${value};path=/;domain=.${window.location.hostname.split('.').slice(-2).join('.')};expires=${date.toUTCString()};SameSite=None;Secure;`; } function isInApk() { if (!window.android) return false; if (!window.android?.getDeviceID || !window.android?.saveUserID) return false; return true; } function getSubscriptionInfo() { var installed = isPwaInstall(); var cacheKey = 'submit_subscription_' + udatadict.channel + '_' + udatadict.userid + '_' + installed; return localStorage.getItem(cacheKey) === '1'; } function getIsPostData() { var installed = isPwaInstall(); var cacheKey = 'submit_subscription_post_' + udatadict.channel + '_' + udatadict.userid + '_' + installed; return localStorage.getItem(cacheKey) === '1'; } function setIsPostData() { var installed = isPwaInstall(); var cacheKey = 'submit_subscription_post_' + udatadict.channel + '_' + udatadict.userid + '_' + installed; localStorage.setItem(cacheKey, '1'); } // 获取全局唯一标识 var getUniqueID = (function () { // 缓存全局唯一标识 let __global_unique_ID; // 缓存 promise 避免多次执行 let promiseInProgress = null; return function () { if (__global_unique_ID) { return Promise.resolve(__global_unique_ID); } // 如果已经有全局唯一标识, 直接返回 var cookie_md5_val = getCookie('winus_uuid'); // if(!cookie_md5_val){ // cookie_md5_val=getLocalUUID(); // if(cookie_md5_val){ // setCookie('winus_uuid', cookie_md5_val, 604800000); // } // } if (cookie_md5_val) { __global_unique_ID = cookie_md5_val; return Promise.resolve(__global_unique_ID); } if (promiseInProgress) { return promiseInProgress; } if (isInApk()) { // apk 环境下, 直接返回 promiseInProgress = new Promise(resolve => { try { // IPA 环境 if (window?.android?.isIpa) { // 确保回调函数在调用 getDeviceID 之前就绑定好 window.android.deviceIdCallback = function (deviceId) { console.log('deviceIdCallback', deviceId); // 如果禁止了第三方cookie, 则将全局唯一标识保存到 当前域名下 cookie 中 if (deviceId) setCookie('winus_uuid', deviceId, 604800000); resolve(deviceId); }; window.android.getDeviceID?.(); return; } // 普通 APK 环境 const deviceId = window?.android?.getDeviceID?.(); if (deviceId) { // 如果禁止了第三方cookie, 则将全局唯一标识保存到 当前域名下 cookie 中 setCookie('winus_uuid', deviceId, 604800000); resolve(deviceId); } } catch (error) { console.log(error); } }); return promiseInProgress; } promiseInProgress = new Promise(function (resolve) { var iframe = document.createElement('iframe'); iframe.src = window.location.protocol + '//' + 'cen.greatus777.com' + '/storage'; // iframe.src = window.location.protocol + '//' + 'dev.winus777.com' + '/storage'; iframe.style.display = 'none'; document.body.appendChild(iframe); iframe.addEventListener('load', function () { iframe.contentWindow.postMessage('getUniqueID', '*'); }); function messageHandler(event) { if (event && event.data && event.data !== 'undefined') { const data = event.data; __global_unique_ID = data.md5val; // 如果禁止了第三方cookie, 则将全局唯一标识保存到 当前域名下 cookie 中 setCookie('winus_uuid', __global_unique_ID, 604800000); resolve(__global_unique_ID); window.removeEventListener('message', messageHandler); document.body.removeChild(iframe); } } // 监听 iframe 的消息 window.addEventListener('message', messageHandler); }); return promiseInProgress; }; })(); /** * 上报订阅信息 * @param {*} data * { * userid: 1, // 用户ID * result: 1, // 1 接受 2未接受 3 不支持 4 拒绝 * machineserial 机器码 * ish5 0:app(w2a),1:h5(pwa) * p_source * } */ function uploadSubscription(data) { if (+data.ish5 !== 0 && +data.ish5 !== 1) return; const ajax = new XMLHttpRequest(); const callback = data.callback; ajax.open('POST', API_URL+"/api/upload_subscribe_state", true); ajax.setRequestHeader('Content-Type', 'application/json'); ajax.onreadystatechange = function () { if (ajax.readyState === 4 && ajax.status === 200) { setIsPostData(); } callback && callback(); }; ajax.onerror = function () { callback && callback(); }; ajax.send(JSON.stringify(data)); } function isIOS() { try { let u = navigator.userAgent; let isIOS = false; // 检查是否包含 iPhone, iPad, iPod 或 Mac OS X (通常Safari在iOS上运行) if (/(iPhone|iPad|iPod|iOS)/i.test(u)) { isIOS = true; } // 排除 Android,避免误判 if (u.indexOf('Android') > -1 || u.indexOf('Adr') > -1) { isIOS = false; } return isIOS } catch (t) { return false } } function openUrlUseSafari(url = "", isNewTab = true, isBFP = true) { if (url == null || url === "") url = window.location.href; if (global.BFP != null && global.BFP !== "" && isBFP) { if (url.indexOf("?") === -1) url += "?bfp=" + global.BFP; else url += "&bfp=" + global.BFP; } if (isIOS()) { const safariUrl = url.startsWith('https') ? url.replace('https://', 'x-safari-https://') : url.replace('http://', 'x-safari-https://'); if (isNewTab) { window.open(safariUrl, '_blank'); } else { window.location.href = safariUrl; } } } function openChrome() { var url = location.href; if (isIOS()) { let r = "googlechromes://" + url.replace(/^https?:\/\//, ""); window.open(r, "_blank"); } else { url = url.replace('https://', ''); url = url.replace('http://', ''); var newLink = 'intent://' + url + '#Intent;scheme=https;action=android.intent.action.VIEW;component=com.android.chrome;end'; var a = document.getElementById('pwaIFrame'); a || (((a = document.createElement('iframe')).id = 'pwaIFrame'), (a.style.width = '0'), (a.style.height = '0'), (a.style.opacity = '0'), (a.name = 'pwaIFrame'), document.body.appendChild(a)), (a.src = newLink); } setTimeout(() => { if (!document.hidden) { uploadSubscription({ userid: udatadict.userid || '', result: 3, machineserial: udatadict.machineserial, ish5: 1, p_source: udatadict.channel }); } }, 1000); document.body.removeEventListener('click', openChrome); } // 判断是否在 chrome 浏览器中 function isInChromeBrowser() { return /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor); } var pushOfFingerprint = ''; var udatadict = {}; var pushLogOpen = true; function pushmlog(...args) { if (pushLogOpen) { console.log('Push log:', ...args); } } function errorpushlog(...args) { if (true) { console.error('Push error log:', ...args); } } // 将URL Base64编码的字符串转换为Uint8Array function urlBase64ToUint8Array(base64String) { var padding = '='.repeat((4 - (base64String.length % 4)) % 4); var base64 = (base64String + padding).replace(/\-/g, '+').replace(/_/g, '/'); var rawData = window.atob(base64); var outputArray = new Uint8Array(rawData.length); for (var i = 0; i < rawData.length; ++i) { outputArray[i] = rawData.charCodeAt(i); } return outputArray; } // 判断是否在PWA模式下运行 function isPwaInstall() { if ( window.matchMedia('(display-mode: standalone)').matches || window.navigator.standalone || document.referrer.includes('android-app://') ) { return 1; } else { return 0; } } // 获取平台 function getPlatform() { var ua = navigator.userAgent; if (ua.match(/Android/i)) { return 'Android'; } else if (ua.match(/iPhone|iPad|iPod/i)) { return 'iOS'; } else { return 'Other'; } } // 将订阅信息发送到服务器 function submitSubscription(subscription, channel, userid) { // 注意落地页和游戏内的指纹算法保持一致!!! var fingerprint = pushOfFingerprint; var website = window.location.href; // 发送订阅信息到服务器 // xmlhttprequest var xhr = new XMLHttpRequest(); // 墨西哥订阅地址 if (window.mode_env === 'development') { xhr.open('POST', API_URL+'/api/push_subscribe', true); } else { xhr.open('POST', API_URL+'/api/push_subscribe', true); } xhr.setRequestHeader('Content-Type', 'application/json'); var contentData = { fingerprint: fingerprint, userid: userid, // 如果有用户登录,可以传用户ID subscibe_info: JSON.stringify(subscription), channel: channel, web_site: website, platform: getPlatform(), installed: isPwaInstall() }; xhr.onreadystatechange = function () { if (xhr.readyState === 4 && xhr.status === 200) { pushmlog('Subscription info sent to server:', xhr.responseText); var installed = isPwaInstall(); var cacheKey = 'submit_subscription_' + channel + '_' + userid + '_' + installed; localStorage.setItem(cacheKey, '1'); } }; xhr.onerror = function () { errorpushlog('Failed to send subscription info'); }; xhr.send(JSON.stringify(contentData)); } // 埋点日志 function recordEvent(eventName, channel, remark, userid) { var info = SingletonChannelInfo.getInstance(); var h2 = info.h2; var h3 = info.h3; var h4 = info.h4 || channel; var host = 'us_' + h2 + '_' + h3 + '_' + h4; var url = API_URL+'/api/weblog?host=' + host + '&act=' + eventName + '&remark=' + remark + '&orderid=' + userid; var xhr = new XMLHttpRequest(); xhr.open('GET', url, true); xhr.send(); } // 请求用户授权订阅推送通知 function requestNotificationPermission(registration, channel, userid, machineserial, ish5) { // 检查浏览器是否支持Notification API if ('Notification' in window) { // 请求授权 Notification.requestPermission().then(function (permission) { if (permission === 'granted') { pushmlog('User has authorized push notifications'); // 注册Service Worker registration.pushManager .subscribe({ userVisibleOnly: true, applicationServerKey: urlBase64ToUint8Array( 'BEKE0qlrGMp-XyUHppeFMscDiJg-sL98jr4b51glbvicHnD69oNZ9JiLHKIQ9_3K0ImSZlo0Ggw-RE3FxYOUwJo' ) }) .then(function (subscription) { var saveSubScription = JSON.stringify(subscription); localStorage.setItem('subscription', saveSubScription); pushmlog('User has subscribed to push notifications:', subscription); // 将订阅信息发送到服务器 submitSubscription(subscription, channel, userid); uploadSubscription({ userid: userid || '', result: 1, machineserial, ish5, p_source: channel, callback: function () { if (+ish5 === 1 || +ish5 === 0) { // 如果是H5游戏, 则打开网址 if (+ish5 === 1) { if (udatadict.returnurl) { setTimeout(() => { location.href = udatadict.returnurl; }, 1000); } } else { // 打开游戏 const div = document.createElement('div'); div.style = 'position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.5); z-index: 9999;'; div.innerHTML = `
Go back to the game
`; document.body.appendChild(div); setTimeout(function () { document.body.removeChild(div); }, 3000); } } } }); }); recordEvent('push_permission', channel, 'allow', userid); } else if (permission === 'denied') { pushmlog('User denied push notifications', userid, machineserial, ish5, channel); recordEvent('push_permission', channel, 'deny', userid); uploadSubscription({ userid: userid || '', result: 4, machineserial, ish5, p_source: channel, callback: function () { if (+ish5 === 1 || +ish5 === 0) { // 如果是H5游戏, 则打开网址 if (+ish5 === 1) { if (udatadict.returnurl) { setTimeout(() => { location.href = udatadict.returnurl; }, 1000); } } else { // 打开游戏 const div = document.createElement('div'); div.style = 'position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.5); z-index: 9999;'; div.innerHTML = `
Go back to the game
`; document.body.appendChild(div); setTimeout(function () { document.body.removeChild(div); }, 3000); } } } }); } else { pushmlog('User has not decided whether to authorize push notifications'); uploadSubscription({ userid: userid || '', result: 2, machineserial, ish5, p_source: channel, callback: function () { if (+ish5 === 1 || +ish5 === 0) { // 如果是H5游戏, 则打开网址 if (+ish5 === 1) { if (udatadict.returnurl) { setTimeout(() => { location.href = udatadict.returnurl; }, 1000); } } else { // 打开游戏 const div = document.createElement('div'); div.style = 'position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.5); z-index: 9999;'; div.innerHTML = `
Go back to the game
`; document.body.appendChild(div); setTimeout(function () { document.body.removeChild(div); }, 3000); } } } }); recordEvent('push_permission', channel, 'pending', userid); } }); } } var isCheckingPushPermission = false; // 如果正在检查推送权限, 则不再检查, 避免在未收到结果前再次调用,会有多个订阅上报 /** * 外部调用 检查推送权限 * @param {string} channel 渠道标识 * @param {number} userid 用户ID * @param {string} machineserial 机器码 * @param {number} type 0:app(w2a),1:h5(pwa) * @param {object} options 其他参数 * */ function checkPushPermission(channel, userid, machineserial, type, options) { var returnurl = options && options.returnurl; var endCallback = options && options.endCallback; try { if (userid == undefined) { userid = 0; } if (channel == undefined) { channel = 'default'; } getUniqueID().then(fingerprint => { pushOfFingerprint = fingerprint; // 先记录下来 // 如果有连续调用, 那么只记录最后一次的 udatadict udatadict.userid = userid; udatadict.channel = channel; udatadict.fingerprint = fingerprint; udatadict.machineserial = machineserial; udatadict.type = type; udatadict.returnurl = returnurl; // 保存到 localstorage localStorage.setItem('pushudatadict', JSON.stringify(udatadict)); if ('serviceWorker' in navigator) navigator.serviceWorker.ready .then(function (registration) { if (isCheckingPushPermission) { return; } isCheckingPushPermission = true; // 检查是否支持service worker if (registration == undefined || registration == null || registration.pushManager == undefined) { !isInApk() && setTimeout(() => { document.body.addEventListener('click', openChrome); }, 500); errorpushlog('registration or pushManager is undefined'); return; } var installed = isPwaInstall(); var cacheKey = 'submit_subscription_' + udatadict.channel + '_' + udatadict.userid + '_' + installed; registration.pushManager.getSubscription().then(function (subscription) { isCheckingPushPermission = false; // 已经有结果了 if (subscription) { var subscriptionOld = localStorage.getItem('subscription'); endCallback && endCallback('subscription'); // 用户已经订阅推送通知 pushmlog('User has already subscribed to push notifications'); // 判断 当前渠道+当前用户 是否已经上报过授权. 如果未上报过, 则上报一次 var cacheValue = localStorage.getItem(cacheKey); if (cacheValue && subscriptionOld && subscriptionOld == JSON.stringify(subscription)) { pushmlog('User has already reported subscription info'); return; } recordEvent('push_permission', udatadict.channel, 'update', udatadict.userid); localStorage.setItem('subscription', JSON.stringify(subscription)); // 更新 submitSubscription(subscription, udatadict.channel, udatadict.userid); // 已经授权过就再上报一次 如果未上报 var ispost = getIsPostData(); if (!ispost) { uploadSubscription({ userid: udatadict.userid || '', result: 1, machineserial: udatadict.machineserial, ish5: udatadict.type, p_source: udatadict.channel }); } return; } else { // 用户尚未订阅推送通知 pushmlog('User has not yet subscribed to push notifications'); localStorage.removeItem(cacheKey); // 判断 通知状态 if (Notification.permission === 'denied') { endCallback && endCallback('denied'); var ispost = getIsPostData(); if (!ispost) { uploadSubscription({ userid: udatadict.userid || '', result: 4, machineserial: udatadict.machineserial, ish5: udatadict.type, p_source: udatadict.channel }); } pushmlog('User has already denied push notifications'); } else { endCallback && endCallback('pending'); // 状态是授权或者用户未决定, 但是拿不到订阅信息, 重新请求授权 requestNotificationPermission(registration, udatadict.channel, udatadict.userid, machineserial, type); } } }); }) .catch(e => { console.log(e); }); }); } catch (error) { errorpushlog('Failed to check push permission:', error); isCheckingPushPermission = false; } } // 外部调用。每次 function checkAlive(userid, vippoint, channel, score) { try { if (udatadict.fingerprint == undefined) { var udatadictstr = localStorage.getItem('pushudatadict'); if (udatadictstr) { udatadict = JSON.parse(udatadictstr); } if (udatadict.fingerprint == undefined) { errorpushlog('udatadict.fingerprint is undefined'); return; } } if (userid == undefined) { errorpushlog('userid is undefined'); return; } // 1 小时最多上报一次 var isInstalled = isPwaInstall(); var reportkey = 'lastreporttime_' + userid + '_' + channel + '_' + isInstalled; var lastreporttime = localStorage.getItem(reportkey); var now = new Date().getTime(); if (lastreporttime) { var last = parseInt(lastreporttime); if (now - last < 1000 * 60 * 60) { return; } } localStorage.setItem(reportkey, now); // 请求用户活跃接口 var xhr = new XMLHttpRequest(); xhr.open('POST', 'https://pushme.us3slot77.com/alive', true); xhr.setRequestHeader('Content-Type', 'application/json'); var contentData = { userid: userid, vippoint: vippoint, channel: channel, fingerprint: udatadict.fingerprint, installed: isInstalled, platform: getPlatform(), score: score, client_active_time: new Date().toISOString() }; xhr.send(JSON.stringify(contentData)); xhr.onreadystatechange = function () { if (xhr.readyState === 4 && xhr.status === 200) { pushmlog('User activity info sent to server:', xhr.responseText); } }; } catch (error) { errorpushlog('Failed to check user activity:', error); } } //简单加密 const encrypt = (str, pwd) => { if (str == '') { return ''; } str = encodeURIComponent(str); if (!pwd || pwd == '') { pwd = 'xbd4jl'; } pwd = encodeURIComponent(pwd); if (pwd == '' || pwd.length <= 0) { return ''; } var prand = ''; for (var i = 0, len = pwd.length; i < len; i += 1) { prand += pwd.charCodeAt(i).toString(); } var sPos = Math.floor(prand.length / 5); var mult = parseInt(prand.charAt(sPos) + prand.charAt(sPos * 2) + prand.charAt(sPos * 3) + prand.charAt(sPos * 4) + prand.charAt(sPos * 5)); var incr = Math.ceil(pwd.length / 2); var modu = Math.pow(2, 31) - 1; if (mult < 2) { return ''; } var salt = Math.round(Math.random() * 1000000000) % 100000000; prand += salt; while (prand.length > 10) { let left = prand; let num = 0; while (left.length > 0) { let temp = parseInt(left.substring(0, 10)); num = num + temp; left = left.substring(10, left.length); } prand = num.toString(); } prand = (mult * prand + incr) % modu; var encChr = ''; var encStr = ''; for (var i = 0, len = str.length; i < len; i += 1) { encChr = parseInt(str.charCodeAt(i) ^ Math.floor((prand / modu) * 255)); if (encChr < 16) { encStr += '0' + encChr.toString(16); } else { encStr += encChr.toString(16); } prand = (mult * prand + incr) % modu; } salt = salt.toString(16); while (salt.length < 8) { salt = "0" + salt; } encStr += salt; return encStr; } //简单解密 const decrypt = (str, pwd) => { if (str == '') { return ''; } if (!pwd || pwd == '') { pwd = 'xbd4jl'; } pwd = encodeURIComponent(pwd); if (str == undefined || str.length < 8) { return ''; } if (pwd == undefined || pwd.length <= 0) { return ''; } var prand = ''; for (var i = 0, len = pwd.length; i < len; i += 1) { prand += pwd.charCodeAt(i).toString(); } var sPos = Math.floor(prand.length / 5); // console.log(prand.length+"sPos____"+sPos+"prand"+prand); var mult = parseInt(prand.charAt(sPos) + prand.charAt(sPos * 2) + prand.charAt(sPos * 3) + prand.charAt(sPos * 4) + prand.charAt(sPos * 5)); var incr = Math.round(pwd.length / 2); var modu = Math.pow(2, 31) - 1; var salt = parseInt(str.substring(str.length - 8, str.length), 16); str = str.substring(0, str.length - 8); // console.log("prand"+prand); prand += salt; // console.log("prand"+prand); while (prand.length > 10) { let left = prand; let num = 0; while (left.length > 0) { let temp = parseInt(left.substring(0, 10)); num = num + temp; left = left.substring(10, left.length); } prand = num.toString(); } // console.log("prand"+prand); prand = (mult * prand + incr) % modu; var encChr = ''; var encStr = ''; for (var i = 0, len = str.length; i < len; i += 2) { encChr = parseInt(parseInt(str.substring(i, i + 2), 16) ^ Math.floor((prand / modu) * 255)); encStr += String.fromCharCode(encChr); prand = (mult * prand + incr) % modu; } return decodeURIComponent(encStr); } const LOCAL_VISTOR_ID = "LOCAL_VISTOR_ID"; const head = "a6072637"; const isenc = true; const localStorageGet = (key, defaultValue = "") => { let value = localStorage.getItem(key); if (value == null) value = defaultValue; else { if (value.startsWith(head)) { try { value = decrypt(value.substring(head.length)); } catch (err) { //如果出错返回空 value = ""; } } } return value; } const localStorageSet = (key, value) => { if (isenc) { if (value != null && value !== "") { if (typeof value !== "string") value = value.toString(); try { value = head + encrypt(value); } catch (err) { } } } localStorage.setItem(key, value); } const localStorageRemove = (key) => { localStorage.removeItem(key); } const getLocalUUID = () => { let bfp=localStorageGet(LOCAL_VISTOR_ID, ""); if(!bfp){ localStorageSet(LOCAL_VISTOR_ID, generateUUIDv7()); bfp=localStorageGet(LOCAL_VISTOR_ID, "") } return bfp; } let params={} let urlParams=new URLSearchParams(window.location.search) for (const [key, value] of urlParams.entries()) { params[key] = value } const LOCAL_ACTIVITY_C = "LOCAL_ACTIVITY_C"; const DEFAULT_CHANNEL = "100"; function ProcessChannel() { let storedChannel = localStorageGet(LOCAL_ACTIVITY_C, ""); let channelFromUrl = params["c"] || ""; let finalChannel = channelFromUrl || storedChannel || DEFAULT_CHANNEL; // 保存渠道号(如有变化) if (finalChannel && finalChannel !== storedChannel) { localStorageSet(LOCAL_ACTIVITY_C, finalChannel); } window.APKCHSource = finalChannel; window.channel = finalChannel; }/** * 生成 UUID v7 (基于时间排序) * 格式: 48位时间戳 | 4位版本(7) | 12位随机数 | 2位变体(10) | 62位随机数 */ function generateUUIDv7() { const bytes = new Uint8Array(16); // 1. 填充随机数 (16 字节) crypto.getRandomValues(bytes); // 2. 写入 48 位毫秒时间戳 (大端序) const now = Date.now(); bytes[0] = (now / 0x10000000000) & 0xff; bytes[1] = (now / 0x100000000) & 0xff; bytes[2] = (now / 0x1000000) & 0xff; bytes[3] = (now / 0x10000) & 0xff; bytes[4] = (now / 0x100) & 0xff; bytes[5] = now & 0xff; // 3. 设置版本号 (Version 7) // 清除前 4 位并设为 0111 (0x70) bytes[6] = (bytes[6] & 0x0f) | 0x70; // 4. 设置变体号 (Variant 10xx) // 清除前 2 位并设为 10 (0x80) bytes[8] = (bytes[8] & 0x3f) | 0x80; // 5. 转换为 8-4-4-4-12 字符串格式 return Array.from(bytes) .map((b, i) => { let s = b.toString(16).padStart(2, '0'); // 在特定位置添加连字符 if (i === 3 || i === 5 || i === 7 || i === 9) return s + '-'; return s; }) .join(''); } if (isIOS()) { window.location.href = window.location.origin + '/' + window.location.search; }