const config = { "PATH_IMG_V2_PRO": "https://cdn-image.gandart.com/", "RUN_TYPE": 1, "BOTTOM_LOAD_MORE_THROTTLE": 100, "BASE_API": "https://api.gandart.com/base", "RESALE_API": "https://api.gandart.com/market", "RESALE_API_V2": "https://api2.gandart.com/market/api/v2", "RESALE_API_V3": "https://api2.gandart.com/market/api/v3", "SALE_API": "https://api.gandart.com/read/api", "ORDER_API": "https://api.gandart.com", "WALLET_API": "https://api.gandart.com/api", "HXT_API": "https://api.gandart.com/wallet", "PATH_IMG_V2": "https://cdn-image.gandart.com/", "SAND_RECHARGE_ACTION": "https://cap.sandpay.com.cn/v4/front-electrans/ceas.elec.trans.quick.deposit.apply", "GAME_ElF_API": "https://elf.pentajam.cn/api", "GAME_ELF_URL": "https://elf.pentajam.cn", "CORECENTER_URL": "https://api.gandart.com/corecenter" }; const lk = new ToolKit(`光予首发手`, `GandartGrabber`, `gandartGrab.js`); const GandartConstKey = { // -----通用助手相关的----- Token: 'lkGandartToken', UserData: 'lkGandartUserData', PrivCollectionBrief: 'lkGandartPrivCollectionBrief', PrivCollectionDetail: 'lkGandartPrivCollectionDetail', CollectionName: 'lkGandartCollectionName', CastingId: 'lkGandartCastingId', LimitPrice: 'lkGandartLimitPrice', TransactionRecordId: 'lkGandartTransactionRecordId', CollectionCateLst: 'lkGandartCollectionCateLst', FloatPriceIntaval: 'lkGandartFloatPriceIntaval', IsCollectionWatchLocked: 'lkIsGandartCollectionWatchLocked', PrivWalletListInUse: 'lkGandartPrivWalletListInUse', IsCollectionMaxNumLimit: 'lkGandartIsCollectionMaxNumLimit', CollectionLockMaxNum: 'lkGandartCollectionLockMaxNum', PasswordPlainText: 'lkGandartPasswordPlainText', PrivPayWalletList: 'lkGandartPrivPayWalletList', // -----抢首发相关的----- IsNewCastingMaxNumLimit: 'lkGandartIsNewCastingMaxNumLimit', NewCastingLockMaxNum: 'lkGandartNewCastingLockMaxNum', NewCastingPayWalletList: 'lkGandartNewCastingPayWalletList', NewCastingId: 'lkGandartNewCollectionCastingId', NewCastingSearchKey: 'lkGandartNewCollectionCastingSearchKey', }; let gandartToken = lk.getVal(GandartConstKey.Token, ''); let gandartUserAgent = `Mozilla/5.0 (iPhone; CPU iPhone OS 16_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.3 Mobile/15E148 Safari/604.1`; const GCommonGandartHeads = { 'Accept': `application/json, text/plain, */*`, 'Origin': `https://www.gandart.com`, 'Accept-Encoding': `gzip, deflate, br`, 'Content-Type': `application/x-www-form-urlencoded;charset=UTF-8`, 'Connection': `keep-alive`, 'Host': `api2.gandart.com`, 'User-Agent': gandartUserAgent, 'Referer': `https://www.gandart.com/`, 'Accept-Language': `zh-CN,zh-Hans;q=0.9`, 'token': gandartToken }; let gandartWalletList = 'A,B,C'; let gandartPasswordPlaintext = ''; if (!lk.isExecComm) { if (!lk.isRequest()) { all(); } } function getMyPasswordPlainText() { let str = lk.getVal(GandartConstKey.PasswordPlainText); let ret = ''; if (!lk.isEmpty(str)) { ret = str; } return ret; } function getCollectionMInfoById(castingId) { let ret; try { let clst = JSON.parse(lk.getVal(GandartConstKey.CollectionCateLst, "[]")); for (const d of clst) { if (d.castingId == castingId) { ret = d; break; } } } catch (error) { lk.logErr(error); } return ret; } function getCollectionNameById(castingId) { let name = '未获取'; let info = getCollectionMInfoById(castingId); if (info) { name = info.collectionName; } return name; } function isCollectionMaxNumLimitEnable() { let isEnabled = lk.getVal(GandartConstKey.IsNewCastingMaxNumLimit); isEnabled = lk.isEmpty(isEnabled) ? false : JSON.parse(isEnabled); return isEnabled; } function getCollectionLockMaxNum() { let num = lk.getVal(GandartConstKey.NewCastingLockMaxNum, 6); return Number(num); } function getMyPasswordPlainText() { let str = lk.getVal(GandartConstKey.PasswordPlainText); let ret = ''; if (!lk.isEmpty(str)) { ret = str; } return ret; } function getMyPayWalletList() { let str = lk.getVal(GandartConstKey.NewCastingPayWalletList); let ret = 'C'; if (!lk.isEmpty(str)) { ret = str; } return ret; } async function all() { let hasNeedSendNotify = true; if (gandartToken == '') { lk.execFail(); lk.appendNotifyInfo(`⚠️请先获取光予token`); } else { let isPass = true; if (isCollectionMaxNumLimitEnable()) { let maxLockNum = getCollectionLockMaxNum(); let orderLstInfo = await getNftOrderList(0); if (orderLstInfo.total >= maxLockNum) { lk.log('当前未支付订单达到预设的限制单量'); lk.prependNotifyInfo(`⚠️当前未支付订单达到限制${maxLockNum}单`); isPass = false; hasNeedSendNotify = true; } } if (isPass) { let nftSeriesItem = await getNewCollectionCastingData(); if (nftSeriesItem) { // let userInfo = await getUser(); let stockNum = 0; let isBlindBox = false; let nftSeriesItemPrice = 0; if (nftSeriesItem.bsType == 2 || nftSeriesItem.castingCount > 1) { stockNum = await getStock(nftSeriesItem); stockNum = await getBlindBoxStock(nftSeriesItem); isBlindBox = true; nftSeriesItemPrice = nftSeriesItem.price; } else { stockNum = await getStock(nftSeriesItem); nftSeriesItemPrice = nftSeriesItem.castingList[0].price; } if (stockNum > 0) { gandartWalletList = getMyPayWalletList(); let myWalletList = await getMyWalletListDetail(); let usedWalletInfo = myWalletList[0]; for (let i = myWalletList.length - 1; i >= 0; i--) { let walletInfo = myWalletList[i]; if (checkIsInPrivWalletList(walletInfo) && walletInfo.availableMoney >= nftSeriesItemPrice) { usedWalletInfo = walletInfo; break; } } if (usedWalletInfo) { let genOrderRet = await generate(nftSeriesItem, isBlindBox); if (genOrderRet) { let orderNum; if (isBlindBox) { orderNum = await submitBlindBoxOrder(nftSeriesItem); } else { orderNum = await submitOrder(nftSeriesItem); } if (orderNum) { let isCreated = await checkIsOrderCreated(orderNum); let msgTips = ''; if (isCreated) { msgTips = '抢购下单成功'; lk.appendNotifyInfo(`🎉${msgTips}`); let orderInfo = { seriesId: nftSeriesItem.id, collectionName: nftSeriesItem.seriesName, orderNo: orderNum, orderTotal: nftSeriesItemPrice, payTotal: nftSeriesItemPrice, castingId: null, }; if (nftSeriesItem.castingCount == 1) { orderInfo.castingId = nftSeriesItem.castingList[0].id; } // orderInfo = await getByOrderNo(orderNum); let isSuccess = await checkPay(usedWalletInfo.channel, orderNum, nftSeriesItemPrice, orderInfo); if (isSuccess) { msgTips += ',并支付成功!'; } else { msgTips += ',请去我的订单支付!'; } } else { msgTips = '未能正常获得订单创建情况,请去我的订单查看!'; lk.appendNotifyInfo(`⚠️${msgTips}`); } lk.pushWxMsg('光予首发手', msgTips, 'https://www.gandart.com/#/pagesA/user/myOrderList'); } } } else { lk.log('无匹配钱包进行支付'); } } else { lk.log('产品库存不足'); } hasNeedSendNotify = true; } else { lk.log('暂无匹配的首发产品发售'); hasNeedSendNotify = false; } } } if (hasNeedSendNotify) { lk.msg(``); } lk.done(); } function checkIsInPrivWalletList(walletInfo) { if (gandartWalletList.indexOf(walletInfo.channel) > -1) { return true; } return false; } async function getNewCollectionCastingData() { let allNftSeriesLst = []; let nftSeriesDetail = await findAllFirstNftSeries(1, 5); if (nftSeriesDetail && nftSeriesDetail.success) { allNftSeriesLst = allNftSeriesLst.concat(allNftSeriesLst.obj); for (let i = 2; i < nftSeriesDetail.totalPage + 1; i++) { nftSeriesDetail = await findAllFirstNftSeries(i, 5); if (nftSeriesDetail && nftSeriesDetail.success) { allNftSeriesLst = allNftSeriesLst.concat(allNftSeriesLst.obj); } } } let tNftCollection; let retNftSeriesLst = []; let retFinalNftSeries; if (allNftSeriesLst && allNftSeriesLst.length > 0) { let newCastingId = lk.getVal(GandartConstKey.NewCastingId, 0); newCastingId = Number(newCastingId); let nowDate = new Date(); if (newCastingId > 0) { lk.log('通过产品铸造ID进行匹配'); for (let i = 0; i < allNftSeriesLst.length; i++) { let nftSeries = allNftSeriesLst[i]; let castingList = nftSeries.castingList; for (let cItem of castingList) { if (cItem.id == newCastingId) { tNftCollection = cItem; retNftSeriesLst.push(nftSeries); break; } } } } else { let castingSearchKey = lk.getVal(GandartConstKey.NewCastingSearchKey); lk.log('通过产品名称关键字进行匹配'); if (!lk.isEmpty(castingSearchKey)) { for (let i = 0; i < allNftSeriesLst.length; i++) { let nftSeries = allNftSeriesLst[i]; if (nftSeries.seriesName.indexOf(castingSearchKey)) { retNftSeriesLst.push(nftSeries); break; } let castingList = nftSeries.castingList; for (let cItem of castingList) { if (cItem.collectionName.indexOf(castingSearchKey) > -1) { tNftCollection = cItem; retNftSeriesLst.push(nftSeries); break; } } } } } lk.log(`找到相关产品数量:${retNftSeriesLst.length}`); retFinalNftSeries = retNftSeriesLst[0]; for (let i = 0; i < retNftSeriesLst.length; i++) { let nftSeries = retNftSeriesLst[i]; let startDate = new Date(nftSeries.startDate); if (nowDate.getTime() >= startDate.getTime() - 1000 && nftSeries.status == 1) { retFinalNftSeries = nftSeries; break; } } } else { lk.log('首发上线产品列表为空'); } return retFinalNftSeries; } async function getNftOrderList(status, orderType = 0, page = 1, pageSize = 6) { return new Promise((resolve, _reject) => { try { const headers = GCommonGandartHeads; headers.Host = "api.gandart.com"; headers['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'; // status 0:进行中 1:已完成 2:已取消 let body = `orderNo=&status=${status}&orderType=${orderType}&page=${page}&pageSize=${pageSize}`; let url = { url: `${config.BASE_API}/order/nftorder/list`, headers: headers, body: body }; lk.log(`请求个人订单列表:${body}`); lk.post(url, async (error, _response, data) => { let rows; let total = 0; try { if (error) { lk.log(`获取订单列表数据发生错误`); lk.execFail(); // lk.appendNotifyInfo(`❌获取订单列表失败,请稍后再试`); } else { let info = JSON.parse(data); rows = info.rows; total = info.total || info.recordsTotal; } } catch (e) { lk.log(`获取订单列表数据发生错误`); lk.logErr(e); lk.execFail(); } finally { resolve({ total: total, rows: rows }); } }); } catch (e) { lk.log(`获取订单列表数据发生错误`); lk.logErr(e); resolve({ total: 0 }); } }); } async function findAllFirstNftSeries(page = 1, pageSize = 5) { return new Promise((resolve, _reject) => { try { const headers = GCommonGandartHeads; headers.Host = "api.gandart.com"; headers['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'; let body = `page=${page}&pageSize=${pageSize}`; let url = { url: `${config.BASE_API}/casting/nftseries/findAll`, headers: headers, body: body }; lk.log(`请求首发全部产品列表:${body}`); lk.post(url, async (error, _response, data) => { let ret; let retItemLst = []; try { if (error) { lk.log(`获取首发全部列表数据发生错误`); lk.execFail(); lk.appendNotifyInfo(`❌获取首发全部列表失败,请稍后再试`); } else { ret = JSON.parse(data); if (ret.success) { retItemLst = ret.obj; } else { lk.log(`获取首发全部列表失败,响应:${data}`); } } } catch (e) { lk.log(`获取首发全部列表数据发生错误`); lk.logErr(e); lk.execFail(); } finally { resolve(ret); } }); } catch (e) { lk.log(`获取首发全部列表数据发生错误`); lk.logErr(e); resolve(); } }); } async function findNotSellFirstNftSeries(page = 1, pageSize = 5) { return new Promise((resolve, _reject) => { try { const headers = GCommonGandartHeads; headers.Host = "api.gandart.com"; headers['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'; let body = `page=${page}&pageSize=${pageSize}`; let url = { url: `${config.BASE_API}/casting/nftseries/findNotSell`, headers: headers, body: body }; lk.log(`请求首发未在售产品列表:${body}`); lk.post(url, async (error, _response, data) => { let ret; let retItemLst = []; try { if (error) { lk.log(`获取首发未在售列表数据发生错误`); lk.execFail(); lk.appendNotifyInfo(`❌获取首发未在售列表失败,请稍后再试`); } else { ret = JSON.parse(data); if (ret.rows) { retItemLst = ret.rows; } else { lk.log(`获取首发未在售列表失败,响应:${data}`); } } } catch (e) { lk.log(`获取首发未在售列表数据发生错误`); lk.logErr(e); lk.execFail(); } finally { resolve(ret); } }); } catch (e) { lk.log(`获取首发未在售列表数据发生错误`); lk.logErr(e); resolve(); } }); } async function getUser() { return new Promise((resolve, _reject) => { try { const headers = GCommonGandartHeads; headers.Host = "api.gandart.com"; headers['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'; let body = ``; let url = { url: `${config.BASE_API}/user/getUser`, headers: headers, body: body }; collectionName = collectionName || getCollectionNameById(castingId); lk.log(`请求用户信息:${body}`); lk.post(url, async (error, _response, data) => { let userInfo; try { if (error) { lk.log(`获取用户信息发生错误`); lk.execFail(); } else { let ret = JSON.parse(data); if (ret.success) { lk.log(`获取用户信息成功`); let obj = ret.obj; userInfo = obj.user; } else { lk.log(`获取用户信息失败,响应:${data}`); } } } catch (e) { lk.log(`获取用户信息发生错误`); lk.logErr(e); lk.execFail(); } finally { resolve(userInfo); } }); } catch (e) { lk.log(`获取用户信息发生错误`); lk.logErr(e); resolve(); } }); } async function getBlindBoxStock(seriesItem) { return new Promise((resolve, _reject) => { try { let castingId = seriesItem.id; let collectionName = seriesItem.collectionName; const headers = GCommonGandartHeads; headers.Host = "api.gandart.com"; headers['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'; let body = `ids=${encodeURIComponent(castingId)}`; let url = { url: `${config.BASE_API}/casting/nftseries/getBlindBoxStock`, headers: headers, body: body }; lk.log(`请求盲盒产品[${collectionName}(${castingId})]库存:${body}`); lk.post(url, async (error, _response, data) => { let stockNum = 0; try { if (error) { lk.log(`获取产品库存发生错误`); lk.execFail(); lk.appendNotifyInfo(`❌获取产品库存失败,请稍后再试`); } else { let ret = JSON.parse(data); if (ret.success) { lk.log(`获取产品库存成功,响应:${data}`); let obj = ret.obj; stockNum = Number(obj[castingId] || 0); } else { lk.log(`获取产品库存失败,响应:${data}`); } } } catch (e) { lk.log(`获取产品库存发生错误`); lk.logErr(e); lk.execFail(); } finally { resolve(stockNum); } }); } catch (e) { lk.log(`获取产品库存发生错误`); lk.logErr(e); resolve(0); } }); } async function getStock(seriesItem) { return new Promise((resolve, _reject) => { try { let castingId = seriesItem.id; let collectionName = seriesItem.collectionName; if (seriesItem.castingCount > 0) { castingId = ''; collectionName = ''; let castingList = seriesItem.castingList; for (let i = 0; i < castingList.length; i++) { const metaData = castingList[i]; castingId = castingId + String(metaData.id) + ','; collectionName = castingId + metaData.collectionName + ','; } castingId = castingId.substring(0, castingId.length - 1); collectionName = collectionName.substring(0, collectionName.length - 1); } const headers = GCommonGandartHeads; headers.Host = "api.gandart.com"; headers['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'; let body = `ids=${encodeURIComponent(castingId)}`; let url = { url: `${config.BASE_API}/casting/nftseries/getStock`, headers: headers, body: body }; collectionName = collectionName || getCollectionNameById(castingId); lk.log(`请求上新产品[${collectionName}(${castingId})]库存:${body}`); lk.post(url, async (error, _response, data) => { let stockNum = 0; try { if (error) { lk.log(`获取产品库存发生错误`); lk.execFail(); lk.appendNotifyInfo(`❌获取产品库存失败,请稍后再试`); } else { let ret = JSON.parse(data); if (ret.success) { lk.log(`获取产品库存成功,响应:${data}`); let obj = ret.obj; for (let k in obj) { stockNum += Number(obj[k] || 0); } } else { lk.log(`获取产品库存失败,响应:${data}`); } } } catch (e) { lk.log(`获取产品库存发生错误`); lk.logErr(e); lk.execFail(); } finally { resolve(stockNum); } }); } catch (e) { lk.log(`获取产品库存发生错误`); lk.logErr(e); resolve(0); } }); } async function getMyWalletListDetail() { return new Promise((resolve, _reject) => { try { const headers = GCommonGandartHeads; headers.Host = "api.gandart.com"; headers['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'; const body = ``; let url = { url: `${config.WALLET_API}/v2/wallet/list?`, headers: headers, body: body }; lk.log(`请求个人钱包列表数据`); lk.get(url, async (error, _response, data) => { let ret; try { if (error) { lk.log(`请求个人钱包列表数据发生错误`); lk.execFail(); } else { let info = JSON.parse(data); if (info.success) { lk.log(`请求个人钱包列表数据成功`); ret = info.obj; } else { lk.log(`请求个人钱包列表数据失败,响应:${data}`); } } } catch (e) { lk.log(`请求个人钱包列表数据发生错误`); lk.logErr(e); lk.execFail(); } finally { resolve(ret); } }); } catch (e) { lk.log(`请求个人钱包列表数据发生错误`); lk.logErr(e); resolve(); } }); } async function generate(nftSeriesItem, isBlindBox) { return new Promise((resolve, _reject) => { try { const headers = GCommonGandartHeads; headers.Host = "api.gandart.com"; headers['Content-Type'] = 'application/json;charset=UTF-8'; let pData = {}; if (isBlindBox) { pData = { seriesId: nftSeriesItem.id, }; } else { pData = { castingId: nftSeriesItem.castingList[0].id, }; } const body = JSON.stringify(pData); let url = { url: `${config.CORECENTER_URL}/transaction/generate`, headers: headers, body: body }; lk.log(`请求生成订单:${body}`); lk.get(url, async (error, _response, data) => { let ret; try { if (error) { lk.log(`请求生成订单发生错误`); lk.execFail(); } else { let info = JSON.parse(data); if (info.code == 0) { lk.log(`请求生成订单成功`); ret = info; } else { lk.log(`请求生成订单失败,响应:${data}`); } } } catch (e) { lk.log(`请求生成订单发生错误`); lk.logErr(e); lk.execFail(); } finally { resolve(ret); } }); } catch (e) { lk.log(`请求生成订单发生错误`); lk.logErr(e); resolve(); } }); } async function submitOrder(nftSeriesItem) { return new Promise((resolve, _reject) => { try { const headers = GCommonGandartHeads; headers.Host = "api.gandart.com"; headers['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'; let signData = getSign(); signData.castingId = nftSeriesItem.castingList[0].id; let body = lk.objToQueryStr(signData); let url = { url: `${config.WALLET_API}/v2/order/nftorder/submitOrder`, headers: headers, body: body }; lk.log(`请求抢购,提交订单:${body}`); lk.get(url, async (error, _response, data) => { let ret; try { if (error) { lk.log(`抢购发生错误`); lk.execFail(); } else { let info = JSON.parse(data); if (info.success) { lk.log(`抢购成功,订单号:${info.obj}`); ret = info.obj; } else { lk.log(`抢购失败,响应:${data}`); } } } catch (e) { lk.log(`抢购发生错误`); lk.logErr(e); lk.execFail(); } finally { resolve(ret); } }); } catch (e) { lk.log(`抢购发生错误`); lk.logErr(e); resolve(); } }); } async function submitBlindBoxOrder(nftSeriesItem) { return new Promise((resolve, _reject) => { try { const headers = GCommonGandartHeads; headers.Host = "api.gandart.com"; headers['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'; let pData = { seriesId: nftSeriesItem.id, }; let body = lk.objToQueryStr(pData); let url = { url: `${config.WALLET_API}/v2/order/nftorder/submitBlindBoxOrder`, headers: headers, body: body }; lk.log(`请求抢购,提交订单:${body}`); lk.get(url, async (error, _response, data) => { let ret; try { if (error) { lk.log(`抢购发生错误`); lk.execFail(); } else { let info = JSON.parse(data); if (info.success) { lk.log(`抢购成功,订单号:${info.obj}`); ret = info.obj; } else { lk.log(`抢购失败,响应:${data}`); } } } catch (e) { lk.log(`抢购发生错误`); lk.logErr(e); lk.execFail(); } finally { resolve(ret); } }); } catch (e) { lk.log(`抢购发生错误`); lk.logErr(e); resolve(); } }); } async function checkIsOrderCreated(orderNum) { let maxQueryCnt = 10; let startNum = 0; let isCreated = false; while (startNum < maxQueryCnt) { let ret = await getIsCreateOrder(orderNum); if (ret) { isCreated = true; break; } startNum++; } return isCreated; } async function getIsCreateOrder(orderNum) { return new Promise((resolve, _reject) => { try { const headers = GCommonGandartHeads; headers.Host = "api.gandart.com"; headers['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'; let body = `orderNo=${orderNum}`; let url = { url: `${config.BASE_API}/order/nftorder/getIsCreateOrder`, headers: headers, body: body }; lk.log(`检查订单是否创建:${body}`); lk.get(url, async (error, _response, data) => { let ret; try { if (error) { lk.log(`检查订单是否创建发生错误`); lk.execFail(); } else { let info = JSON.parse(data); if (info.code == 1) { lk.log(`订单创建成功:${orderNum}`); ret = info; } else { lk.log(`${info.msg}`); } } } catch (e) { lk.log(`检查订单是否创建发生错误`); lk.logErr(e); lk.execFail(); } finally { resolve(ret); } }); } catch (e) { lk.log(`检查订单是否创建发生错误`); lk.logErr(e); resolve(); } }); } async function getByOrderNo(orderNum) { return new Promise((resolve, _reject) => { try { const headers = GCommonGandartHeads; headers.Host = "api.gandart.com"; headers['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'; let body = `orderNo=${orderNum}`; let url = { url: `${config.BASE_API}/order/nftorder/getByOrderNo`, headers: headers, body: body }; lk.log(`请求订单详细信息:${body}`); lk.get(url, async (error, _response, data) => { let ret; try { if (error) { lk.log(`请求订单详细信息错误`); lk.execFail(); } else { let info = JSON.parse(data); if (info.success) { lk.log(`获取订单详细信息成功`); ret = info.obj; } else { lk.log(`获取订单详细信息失败,响应:${data}`); } } } catch (e) { lk.log(`请求订单详细信息发生错误`); lk.logErr(e); lk.execFail(); } finally { resolve(ret); } }); } catch (e) { lk.log(`请求订单详细信息发生错误`); lk.logErr(e); resolve(); } }); } async function checkPay(wChannel, orderNum, orderTotal, orderInfo) { let isPaySuccess = await finalPay(wChannel, orderNum, orderTotal, orderInfo); return isPaySuccess; } async function verifyMyWalletPassword() { let publicKey = await getPublicKey(); if (publicKey) { let accountPassword = encryptPassword(publicKey, gandartPasswordPlaintext); let isOk = await confirmPassword(accountPassword); if (isOk) { return true; } return false; } return false; } function encryptPassword(publicKey, password) { let JSEncrypt = createJSEncrypt(); let crypt = new JSEncrypt(); crypt.setPublicKey(publicKey); let md5 = createWMd5(); return crypt.encrypt(md5.hex_md5_32Upper(password)); } async function getPublicKey() { return new Promise((resolve, _reject) => { try { const headers = GCommonGandartHeads; headers.Host = "api.gandart.com"; const body = ``; let url = { url: `${config.BASE_API}/reg/getPublicKey`, headers: headers, body: body }; lk.log(`请求支付密码相关的PublicKey`); lk.post(url, async (error, _response, data) => { let ret; try { if (error) { lk.log(`请求PublicKey发生错误`); lk.execFail(); } else { let info = JSON.parse(data); if (info.success) { lk.log(`请求PublicKey成功`); ret = info.obj; } else { lk.log(`请求PublicKey失败`); } } } catch (e) { lk.log(`请求PublicKey发生错误`); lk.logErr(e); lk.execFail(); } finally { resolve(ret); } }); } catch (e) { lk.log(`请求PublicKey发生错误`); lk.logErr(e); resolve(); } }); } async function confirmPassword(accountPassword) { return new Promise((resolve, _reject) => { try { const headers = GCommonGandartHeads; headers.Host = "api.gandart.com"; const body = `accountPassword=${encodeURIComponent(accountPassword)}`; let url = { url: `${config.BASE_API}/user/confirmPassword`, headers: headers, body: body }; lk.log(`请求验证支付密码`); lk.post(url, async (error, _response, data) => { let ret = false; try { if (error) { lk.log(`请求验证支付密码发生错误`); lk.execFail(); } else { let info = JSON.parse(data); if (info.success) { lk.log(`请求验证支付密码通过`); ret = true; } else { lk.log(`请求验证支付密码失败,响应:${data}`); } } } catch (e) { lk.log(`请求验证支付密码发生错误`); lk.logErr(e); lk.execFail(); } finally { resolve(ret); } }); } catch (e) { lk.log(`请求验证支付密码发生错误`); lk.logErr(e); resolve(); } }); } async function finalPay(walletName, orderNum, orderTotal, orderInfo) { let isSuccess = false; let isPass = false; switch (walletName) { case 'A': // 恒信通 isPass = await verifyMyWalletPassword(walletName, orderNum, orderTotal); if (isPass) { isSuccess = await hxtPay(orderNum, orderInfo); } break; case 'B': // 杉德 isSuccess = await sandPay(orderNum, orderInfo); break; case 'C': // 快付通 isPass = await verifyMyWalletPassword(walletName, orderNum, orderTotal); if (isPass) { isSuccess = await kftPay(orderNum, orderInfo); } break; default: break; } return isSuccess; } async function hxtPay(orderNum, orderInfo) { return false; } async function sandPay(orderNum, orderInfo) { return false; } async function kftPay(orderNum, orderInfo) { return new Promise((resolve, _reject) => { try { const headers = GCommonGandartHeads; headers.Host = "api.gandart.com"; const body = `orderNum=${orderNum}`; let path = `${config.WALLET_API}/v2/wallet/kft/pay`; let url = { url: path, headers: headers, body: body }; lk.log(`请求支付订单[${orderNum}]=${body}`); lk.post(url, async (error, _response, data) => { let ret; try { if (error) { lk.log(`请求支付订单[${orderNum}]发生错误`); lk.execFail(); lk.appendNotifyInfo(`❌支付失败,请稍后再试`); } else { let info = JSON.parse(data); if (info.success) { ret = orderNum; lk.appendNotifyInfo(`🎉支付订单[${orderNum}]成功`); } else { lk.log(`请求支付订单[${orderNum}]失败,响应:${data}`); } } } catch (e) { lk.log(`请求支付订单[${orderNum}]发生错误`); lk.logErr(e); lk.execFail(); } finally { resolve(ret); } }); } catch (e) { lk.log(`请求支付订单[${orderNum}]发生错误`); lk.logErr(e); resolve(); } }); } function getSign() { const now = new Date().getTime(); let s1 = now - 20000; let s2 = now; let s3 = now + 20000; let s4 = now + 40000; const sssfffeee = 'e9'; //localStorage.getItem('sssfffeee'); const aggaaa = '9'; //localStorage.getItem('aggaaa'); const yyhhhasdww = '0a'; let arr = [sssfffeee, yyhhhasdww, aggaaa, '29', 'e', 'c', 3]; let crypto = createCrypto(); let s5 = crypto.md5(s3 + arr.join('')); return { 's1': s1, 's2': s2, 's3': s3, 's4': s4, 's5': s5 }; } // https://github.com/lowking/Scripts/blob/master/util/ToolKit.min.js //---SyncByPyScript---ToolKit-start function ToolKit(t,s,e){return new class{constructor(t,s,e){this.tgEscapeCharMapping={"&":"&","#":"#"},this.userAgent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0.2 Safari/605.1.15",this.prefix="lk",this.name=t,this.id=s,this.data=null,this.dataFile=this.getRealPath(""+this.prefix+this.id+".dat"),this.boxJsJsonFile=this.getRealPath(""+this.prefix+this.id+".boxjs.json"),this.options=e,this.isExecComm=!1,this.isEnableLog=this.getVal(this.prefix+"IsEnableLog"+this.id),this.isEnableLog=!!this.isEmpty(this.isEnableLog)||JSON.parse(this.isEnableLog),this.isNotifyOnlyFail=this.getVal(this.prefix+"NotifyOnlyFail"+this.id),this.isNotifyOnlyFail=!this.isEmpty(this.isNotifyOnlyFail)&&JSON.parse(this.isNotifyOnlyFail),this.isEnableTgNotify=this.getVal(this.prefix+"IsEnableTgNotify"+this.id),this.isEnableTgNotify=!this.isEmpty(this.isEnableTgNotify)&&JSON.parse(this.isEnableTgNotify),this.tgNotifyUrl=this.getVal(this.prefix+"TgNotifyUrl"+this.id),this.isEnableTgNotify=this.isEnableTgNotify&&!this.isEmpty(this.tgNotifyUrl),this.costTotalStringKey=this.prefix+"CostTotalString"+this.id,this.costTotalString=this.getVal(this.costTotalStringKey),this.costTotalString=this.isEmpty(this.costTotalString)?"0,0":this.costTotalString.replace('"',""),this.costTotalMs=this.costTotalString.split(",")[0],this.execCount=this.costTotalString.split(",")[1],this.costTotalMs=this.isEmpty(this.costTotalMs)?0:parseInt(this.costTotalMs),this.execCount=this.isEmpty(this.execCount)?0:parseInt(this.execCount),this.logSeparator="\n██",this.now=new Date,this.startTime=this.now.getTime(),this.node=this.isNode()?{request:require("request")}:null,this.execStatus=!0,this.notifyInfo=[],this.log(this.name+", 开始执行!"),this.initCache(),this.checkRecordRequestBody(),this.execComm()}checkRecordRequestBody(){var t,s;this.isRequest()&&(t=$request.body)&&(s=$request.path,s=this.id+"#"+s.replace("/","_"),this.isQuanX()&&$prefs.setValueForKey(t,s),(this.isLoon()||this.isSurge())&&$persistentStore.write(t,s),this.isNode())&&this.node.fs.writeFileSync(s+".json",t,{flag:"w"},t=>console.log(t))}getRequestBody(){var t=$request.path,t=this.id+"#"+t.replace("/","_");if(this.isSurge()||this.isLoon())return $persistentStore.read(t);if(this.isQuanX())return $prefs.valueForKey(t);if(this.isNode()){t=t+".json";if(!this.node.fs.existsSync(t))return JSON.parse(this.node.fs.readFileSync(t))}}initCache(){var t,s=this.getPersistKey();this.isQuanX()&&(this.cache=JSON.parse($prefs.valueForKey(s)||"{}")),(this.isLoon()||this.isSurge())&&(this.cache=JSON.parse($persistentStore.read(s)||"{}")),this.isNode()&&(this.node.fs.existsSync(t="root.json")||this.node.fs.writeFileSync(t,JSON.stringify({}),{flag:"wx"},t=>console.log(t)),this.root={},this.node.fs.existsSync(t=s+".json")?this.cache=JSON.parse(this.node.fs.readFileSync(s+".json")):(this.node.fs.writeFileSync(t,JSON.stringify({}),{flag:"wx"},t=>console.log(t)),this.cache={}))}getPersistKey(){return this.id+"#privateCache"}persistCache(){var t=this.getPersistKey(),s=JSON.stringify(this.cache,null,2);this.isQuanX()&&$prefs.setValueForKey(s,t),(this.isLoon()||this.isSurge())&&$persistentStore.write(s,t),this.isNode()&&(this.node.fs.writeFileSync(t+".json",s,{flag:"w"},t=>console.log(t)),this.node.fs.writeFileSync("root.json",JSON.stringify(this.root,null,2),{flag:"w"},t=>console.log(t)))}write(t,s){if(this.log("SET "+s),-1!==s.indexOf("#")){if(s=s.substr(1),isSurge||this.isLoon())return $persistentStore.write(t,s);if(this.isQuanX())return $prefs.setValueForKey(t,s);this.isNode()&&(this.root[s]=t)}else this.cache[s]=t;this.persistCache()}read(t){return this.log("READ "+t),-1!==t.indexOf("#")?(t=t.substr(1),this.isSurge()||this.isLoon()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):this.isNode()?this.root[t]:void 0):this.cache[t]}delete(t){if(this.log("DELETE "+t),-1!==t.indexOf("#")){if(t=t.substr(1),this.isSurge()||this.isLoon())return $persistentStore.write(null,t);if(this.isQuanX())return $prefs.removeValueForKey(t);this.isNode()&&delete this.root[t]}else delete this.cache[t];this.persistCache()}getRealPath(t){var s;return this.isNode()?((s=process.argv.slice(1,2)[0].split("/"))[s.length-1]=t,s.join("/")):t}getUrlHost(t){return t.slice(0,t.indexOf("/",8))}getUrlPath(t){var s=t.lastIndexOf("/")===t.length-1?-1:void 0;return t.slice(t.indexOf("/",8),s)}async execComm(){if(this.isNode()){this.comm=process.argv.slice(1);let t=!1;"p"==this.comm[1]&&(this.isExecComm=!0,this.log(`开始执行指令【${this.comm[1]}】=> 发送到手机测试脚本!`),this.isEmpty(this.options)||this.isEmpty(this.options.httpApi)?(this.log("未设置options,使用默认值"),this.isEmpty(this.options)&&(this.options={}),this.options.httpApi="ffff@10.0.0.9:6166"):/.*?@.*?:[0-9]+/.test(this.options.httpApi)||(t=!0,this.log("❌httpApi格式错误!格式:ffff@3.3.3.18:6166"),this.done()),t||this.callApi(this.comm[2]))}}callApi(t){let i=this.comm[0],s=(this.log(`获取【${i}】内容传给手机`),"");this.fs=this.fs||require("fs"),this.path=this.path||require("path");var e=this.path.resolve(i),r=this.path.resolve(process.cwd(),i),o=this.fs.existsSync(e),h=!o&&this.fs.existsSync(r);if(o||h){h=o?e:r;try{s=this.fs.readFileSync(h)}catch(t){s=""}}else s="";o={url:`http://${this.options.httpApi.split("@")[1]}/v1/scripting/evaluate`,headers:{"X-Key":""+this.options.httpApi.split("@")[0]},body:{script_text:""+s,mock_type:"cron",timeout:!this.isEmpty(t)&&5{this.log(`已将脚本【${i}】发给手机!`),this.done()})}getCallerFileNameAndLine(){let s;try{throw Error("")}catch(t){s=t}var t=s.stack.split("\n")[1];return this.path=this.path||require("path"),`[${t.substring(t.lastIndexOf(this.path.sep)+1,t.lastIndexOf(":"))}]`}getFunName(t){t=t.toString();return t=(t=t.substr("function ".length)).substr(0,t.indexOf("("))}boxJsJsonBuilder(s,r){if(this.isNode()){let i="/Users/lowking/Desktop/Scripts/lowking.boxjs.json";if(r&&r.hasOwnProperty("target_boxjs_json_path")&&(i=r.target_boxjs_json_path),this.fs.existsSync(i))if(this.isJsonObject(s)&&this.isJsonObject(r)){this.log("using node");var o=["settings","keys"],h="https://raw.githubusercontent.com/Orz-3";let e={},t="#lk{script_url}";if(r&&r.hasOwnProperty("script_url")&&(t=this.isEmpty(r.script_url)?"#lk{script_url}":r.script_url),e.id=""+this.prefix+this.id,e.name=this.name,e.desc_html=`⚠️使用说明
详情【点我查看】`,e.icons=[h+`/mini/master/Alpha/${this.id.toLocaleLowerCase()}.png`,h+`/mini/master/Color/${this.id.toLocaleLowerCase()}.png`],e.keys=[],e.settings=[{id:this.prefix+"IsEnableLog"+this.id,name:"开启/关闭日志",val:!0,type:"boolean",desc:"默认开启"},{id:this.prefix+"NotifyOnlyFail"+this.id,name:"只当执行失败才通知",val:!1,type:"boolean",desc:"默认关闭"},{id:this.prefix+"IsEnableTgNotify"+this.id,name:"开启/关闭Telegram通知",val:!1,type:"boolean",desc:"默认关闭"},{id:this.prefix+"TgNotifyUrl"+this.id,name:"Telegram通知地址",val:"",type:"text",desc:"Tg的通知地址,如:https://api.telegram.org/bot-token/sendMessage?chat_id=-100140&parse_mode=Markdown&text="}],e.author="#lk{author}",e.repo="#lk{repo}",e.script=t+"?raw=true",!this.isEmpty(s))for(var n in o){var a=o[n];if(!this.isEmpty(s[a])){if("settings"===a)for(let t=0;tt.id==e.id)[0]);0<=u?c.apps[u]=e:c.apps.push(e);let s=JSON.stringify(c,null,2);if(!this.isEmpty(r))for(const m in r){let t="";r.hasOwnProperty(m)?t=r[m]:"author"===m?t="@lowking":"repo"===m&&(t="https://github.com/lowking/Scripts"),s=s.replace(`#lk{${m}}`,t)}for(var g,y=/(?:#lk\{)(.+?)(?=\})/,S=(null!==y.exec(s)&&this.log("生成BoxJs还有未配置的参数,请参考https://github.com/lowking/Scripts/blob/master/util/example/ToolKitDemo.js#L17-L18传入参数:\n"),new Set);null!==(g=y.exec(s));)S.add(g[1]),s=s.replace(`#lk{${g[1]}}`,"");S.forEach(t=>{console.log(t+" ")}),this.fs.writeFileSync(i,s)}}}else this.log("构建BoxJsJson传入参数格式错误,请传入json对象")}}isJsonObject(t){return"object"==typeof t&&"[object object]"==Object.prototype.toString.call(t).toLowerCase()&&!t.length}appendNotifyInfo(t,s){1==s?this.notifyInfo=t:this.notifyInfo.push(t)}prependNotifyInfo(t){this.notifyInfo.splice(0,0,t)}execFail(){this.execStatus=!1}isRequest(){return"undefined"!=typeof $request}isSurge(){return"undefined"!=typeof $httpClient}isQuanX(){return"undefined"!=typeof $task}isLoon(){return"undefined"!=typeof $loon}isJSBox(){return"undefined"!=typeof $app&&"undefined"!=typeof $http}isStash(){return"undefined"!=typeof $environment&&$environment["stash-version"]}isNode(){return"function"==typeof require&&!this.isJSBox()}sleep(s){return new Promise(t=>setTimeout(t,s))}log(t){this.isEnableLog&&console.log(""+this.logSeparator+t)}logErr(t){this.execStatus=!0,this.isEnableLog&&(console.log(""+this.logSeparator+this.name+"执行异常:"),console.log(t),console.log("\n"+t.message))}msg(t,s,e,i){if((this.isRequest()||!this.isNotifyOnlyFail||!this.execStatus)&&(this.isEmpty(s)&&(s=Array.isArray(this.notifyInfo)?this.notifyInfo.join("\n"):this.notifyInfo),!this.isEmpty(s)))if(this.isEnableTgNotify){for(var r in this.log(this.name+"Tg通知开始"),this.tgEscapeCharMapping)this.tgEscapeCharMapping.hasOwnProperty(r)&&(s=s.replace(r,this.tgEscapeCharMapping[r]));this.get({url:encodeURI(this.tgNotifyUrl+"📌"+this.name+"\n"+s)},(t,s,e)=>{this.log("Tg通知完毕")})}else{var o={},h=!this.isEmpty(e),n=!this.isEmpty(i);this.isQuanX()&&(h&&(o["open-url"]=e),n&&(o["media-url"]=i),$notify(this.name,t,s,o)),(this.isSurge()||this.isStash())&&(h&&(o.url=e),$notification.post(this.name,t,s,o)),this.isNode()&&this.log("⭐️"+this.name+"\n"+t+"\n"+s),this.isJSBox()&&$push.schedule({title:this.name,body:t?t+"\n"+s:s})}}pushWxMsg(t,s,e,i=()=>{}){s={appToken:"AT_rTc93GQYIdMU8XLRnoJaSea8WkfhSzhX",content:s,summary:t,contentType:1,topicIds:[],uids:["UID_6P4B00X6Zv8U2oKC0I2R09emxtqq"],url:"",verifyPay:!1},e&&(s.url=e),t=this.getJsonDoneHeaders(),t.Host="wxpusher.zjiecode.com",t["Content-Type"]="application/json;charset=UTF-8",e={url:"https://wxpusher.zjiecode.com/api/send/message",headers:t,body:JSON.stringify(s)};this.post(e,i)}getVal(t,s=""){let e;return(e=this.isSurge()||this.isLoon()||this.isStash()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):this.isNode()?(this.data=this.loadData(),process.env[t]||this.data[t]):this.data&&this.data[t]||null)||s}setVal(t,s){return this.isSurge()||this.isLoon()||this.isStash()?$persistentStore.write(s,t):this.isQuanX()?$prefs.setValueForKey(s,t):this.isNode()?(this.data=this.loadData(),this.data[t]=s,this.writeData(),!0):this.data&&this.data[t]||null}loadData(){if(!this.isNode())return{};this.fs=this.fs||require("fs"),this.path=this.path||require("path");var t=this.path.resolve(this.dataFile),s=this.path.resolve(process.cwd(),this.dataFile),e=this.fs.existsSync(t),i=!e&&this.fs.existsSync(s);if(!e&&!i)return{};i=e?t:s;try{return JSON.parse(this.fs.readFileSync(i))}catch(t){return{}}}writeData(){var t,s,e,i,r;this.isNode()&&(this.fs=this.fs||require("fs"),this.path=this.path||require("path"),t=this.path.resolve(this.dataFile),s=this.path.resolve(process.cwd(),this.dataFile),i=!(e=this.fs.existsSync(t))&&this.fs.existsSync(s),r=JSON.stringify(this.data),!e&&i?this.fs.writeFileSync(s,r):this.fs.writeFileSync(t,r))}adapterStatus(t){return t&&(t.status?t.statusCode=t.status:t.statusCode&&(t.status=t.statusCode)),t}get(t,i=()=>{}){this.isQuanX()&&((t="string"==typeof t?{url:t}:t).method="GET",$task.fetch(t).then(t=>{i(null,this.adapterStatus(t),t.body)},t=>i(t.error,null,null))),(this.isSurge()||this.isLoon()||this.isStash())&&$httpClient.get(t,(t,s,e)=>{i(t,this.adapterStatus(s),e)}),this.isNode()&&this.node.request(t,(t,s,e)=>{i(t,this.adapterStatus(s),e)}),this.isJSBox()&&((t="string"==typeof t?{url:t}:t).header=t.headers,t.handler=function(t){let s=t.error,e=(s=s&&JSON.stringify(t.error),t.data);"object"==typeof e&&(e=JSON.stringify(t.data)),i(s,this.adapterStatus(t.response),e)},$http.get(t))}post(t,i=()=>{}){this.isQuanX()&&((t="string"==typeof t?{url:t}:t).method="POST",$task.fetch(t).then(t=>{i(null,this.adapterStatus(t),t.body)},t=>i(t.error,null,null))),(this.isSurge()||this.isLoon()||this.isStash())&&$httpClient.post(t,(t,s,e)=>{i(t,this.adapterStatus(s),e)}),this.isNode()&&this.node.request.post(t,(t,s,e)=>{i(t,this.adapterStatus(s),e)}),this.isJSBox()&&((t="string"==typeof t?{url:t}:t).header=t.headers,t.handler=function(t){let s=t.error,e=(s=s&&JSON.stringify(t.error),t.data);"object"==typeof e&&(e=JSON.stringify(t.data)),i(s,this.adapterStatus(t.response),e)},$http.post(t))}put(t,i=()=>{}){this.isQuanX()&&((t="string"==typeof t?{url:t}:t).method="PUT",$task.fetch(t).then(t=>{i(null,this.adapterStatus(t),t.body)},t=>i(t.error,null,null))),(this.isSurge()||this.isLoon()||this.isStash())&&(t.method="PUT",$httpClient.put(t,(t,s,e)=>{i(t,this.adapterStatus(s),e)})),this.isNode()&&(t.method="PUT",this.node.request.put(t,(t,s,e)=>{i(t,this.adapterStatus(s),e)})),this.isJSBox()&&((t="string"==typeof t?{url:t}:t).header=t.headers,t.handler=function(t){let s=t.error,e=(s=s&&JSON.stringify(t.error),t.data);"object"==typeof e&&(e=JSON.stringify(t.data)),i(s,this.adapterStatus(t.response),e)},$http.post(t))}costTime(){let t=this.name+"执行完毕!";this.isNode()&&this.isExecComm&&(t=`指令【${this.comm[1]}】执行完毕!`);var s=(new Date).getTime()-this.startTime,e=s/1e3;this.execCount++,this.costTotalMs+=s,this.log(`${t}耗时【${e}】秒\n总共执行【${this.execCount}】次,平均耗时【${(this.costTotalMs/this.execCount/1e3).toFixed(4)}】秒`),this.setVal(this.costTotalStringKey,JSON.stringify(this.costTotalMs+","+this.execCount))}done(t={}){this.costTime(),(this.isSurge()||this.isQuanX()||this.isLoon()||this.isStash())&&$done(t)}getRequestUrl(){return $request.url}getResponseBody(){if($response)return $response.body}isGetCookie(t){return!("OPTIONS"==$request.method||!this.getRequestUrl().match(t))}isEmpty(t){return void 0===t||null==t||""==t||"null"==t||"undefined"==t||0===t.length}randomString(s){s=s||32;var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890",i=e.length,r="";for(let t=0;t>>32-u,r)}function c(t,n,r,e,u,o,c){return f(n&r|~n&e,t,n,u,o,c)}function i(t,n,r,e,u,o,c){return f(n&e|r&~e,t,n,u,o,c)}function a(t,n,r,e,u,o,c){return f(n^r^e,t,n,u,o,c)}function l(t,n,r,e,u,o,c){return f(r^(n|~e),t,n,u,o,c)}function n(t){/[\x80-\xFF]/.test(t)&&(t=unescape(encodeURI(t))),txt="";let n=t.length,r=[1732584193,-271733879,-1732584194,271733878],e;for(e=64;e<=t.length;e+=64)o(r,function(t){let n=[],r;for(r=0;r<64;r+=4)n[r>>2]=t.charCodeAt(r)+(t.charCodeAt(r+1)<<8)+(t.charCodeAt(r+2)<<16)+(t.charCodeAt(r+3)<<24);return n}(t.substring(e-64,e)));t=t.substring(e-64);var u=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(e=0;e>2]|=t.charCodeAt(e)<<(e%4<<3);if(u[e>>2]|=128<<(e%4<<3),55>8*r+4&15]+e[t>>8*r&15];return n}(n[t]);return n.join("")}function h(t,n){return t+n&4294967295}return{md5:function(t){return r(n(t))}}} //---SyncByPyScript---Crypto-end //---SyncByPyScript---JSEncrypt-start function createJSEncrypt(){function a(t){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(t)}function L(t,e){return t&e}function h(t,e){return t|e}function j(t,e){return t^e}function H(t,e){return t&~e}var u,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function r(t){for(var e,i="",r=0;r+3<=t.length;r+=3)e=parseInt(t.substring(r,r+3),16),i+=o.charAt(e>>6)+o.charAt(63&e);for(r+1==t.length?(e=parseInt(t.substring(r,r+1),16),i+=o.charAt(e<<2)):r+2==t.length&&(e=parseInt(t.substring(r,r+2),16),i+=o.charAt(e>>2)+o.charAt((3&e)<<4));0<(3&i.length);)i+="=";return i}function C(t){for(var e="",i=0,r=0,n=0;n>2),r=3&s,1):1==i?(e+=a(r<<2|s>>4),r=15&s,2):2==i?(e=(e+=a(r))+a(s>>2),r=3&s,3):(e=(e+=a(r<<2|s>>4))+a(15&s),0))}return 1==i&&(e+=a(r<<2)),e}var c,F=function(t){if(void 0===u){var e="0123456789ABCDEF",i=" \f\n\r\t \u2028\u2029";for(u={},o=0;o<16;++o)u[e.charAt(o)]=o;for(e=e.toLowerCase(),o=10;o<16;++o)u[e.charAt(o)]=o;for(o=0;o>16,i[i.length]=r>>8&255,i[i.length]=255&r,n=r=0):r<<=6}}switch(n){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:i[i.length]=r>>10;break;case 3:i[i.length]=r>>16,i[i.length]=r>>8&255}return i},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(t){var e=U.re.exec(t);if(e)if(e[1])t=e[1];else{if(!e[2])throw new Error("RegExp out of sync");t=e[2]}return U.decode(t)}},f=1e13,l=(t.prototype.mulAdd=function(t,e){for(var i,r=this.buf,n=r.length,s=0;se?t.substring(0,e)+"…":t}i.prototype.get=function(t){if((t=void 0===t?this.pos++:t)>=this.enc.length)throw new Error("Requesting byte offset ".concat(t," on a stream of length ").concat(this.enc.length));return"string"==typeof this.enc?this.enc.charCodeAt(t):this.enc[t]},i.prototype.hexByte=function(t){return this.hexDigits.charAt(t>>4&15)+this.hexDigits.charAt(15&t)},i.prototype.hexDump=function(t,e,i){for(var r="",n=t;n>u&1?"1":"0";if(s.length>i)return n+p(s,i)}return n+s},i.prototype.parseOctetString=function(t,e,i){if(this.isASCII(t,e))return p(this.parseStringISO(t,e),i);var r=e-t,n="("+r+" byte)\n";(i/=2)i)return p(r,i);n=new l,s=0}}return 0>6,this.tagConstructed=0!=(32&e),this.tagNumber=31&e,31==this.tagNumber){for(var i=new l;e=t.get(),i.mulAdd(128,127&e),128&e;);this.tagNumber=i.simplify()}}var d=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],$=(1<<26)/d[d.length-1],m=(y.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var i,r=(1<>h)&&(n=!0,s=a(i));0<=o;)h>(h+=this.DB-e)):(i=this[o]>>(h-=e)&r,h<=0&&(h+=this.DB,--o)),(n=0>24},y.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},y.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},y.prototype.toByteArray=function(){var t,e=this.t,i=[],r=(i[0]=this.s,this.DB-e*this.DB%8),n=0;if(0>r)!=(this.s&this.DM)>>r&&(i[n++]=t|this.s<>(r+=this.DB-8)):(t=this[e]>>(r-=8)&255,r<=0&&(r+=this.DB,--e)),0!=(128&t)&&(t|=-256),0==n&&(128&this.s)!=(128&t)&&++n,(0>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e));return this.s<0?this.t*this.DB:-1},y.prototype.bitCount=function(){for(var t=0,e=this.s&this.DM,i=0;i=this.t?0!=this.s:0!=(this[e]&1<>i-a&u:(f=(t[p]&(1<>this.DB+i-a)),h=n;0==(1&f);)f>>=1,--h;if((i-=h)<0&&(i+=this.DB,--p),g)o[f].copyTo(r),g=!1;else{for(;1this.DB?(this[this.t-1]|=(o&(1<>this.DB-s):this[this.t-1]|=o<=this.DB&&(s-=this.DB))}8==i&&0!=(128&+t[0])&&(this.s=-1,0>r|o,o=(this[h]&n)<=this.t)e.t=0;else{var r=t%this.DB,n=this.DB-r,s=(1<>r;for(var o=i+1;o>r;0>=this.DB;if(t.t>=this.DB;r+=this.s}else{for(r+=this.s;i>=this.DB;r-=t.s}e.s=r<0?-1:0,r<-1?e[i++]=this.DV+r:0=e.DV&&(t[i+e.t]-=e.DV,t[i+e.t+1]=1)}0>this.F2:0),c=this.FV/r,f=(1<=i&&(this.dMultiply(r),this.dAddOffset(o,0),o=s=0))}0t&&this.subTo(y.ONE.shiftLeft(t-1),this);else{var i=[],r=7&t;i.length=1+(t>>3),e.nextBytes(i),0>=this.DB;if(t.t>=this.DB;r+=this.s}else{for(r+=this.s;i>=this.DB;r+=t.s}e.s=r<0?-1:0,0=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},y.prototype.multiplyLowerTo=function(t,e,i){var r=Math.min(this.t+t.t,e);for(i.s=0,i.t=r;0>1)&&(t=d.length),b()),s=0;st&&n.subTo(y.ONE.shiftLeft(t-1),n),n.isProbablePrime(e)?setTimeout(function(){r()},0):setTimeout(s,0)},setTimeout(s,0)):(i=7&t,(o=[]).length=1+(t>>3),e.nextBytes(o),0>15)*this.mpl&this.um)<<15)&t.DM;for(t[i=e+this.m.t]+=this.m.am(0,r,t,e,0,this.m.t);t[i]>=t.DV;)t[i]-=t.DV,t[++i]++}t.clamp(),t.drShiftTo(this.m.t,t),0<=t.compareTo(this.m)&&t.subTo(this.m,t)},s.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},s.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var X=s;function s(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<2*this.m.t?t.mod(this.m):t.compareTo(this.m)<0?t:(e=b(),t.copyTo(e),this.reduce(e),e)},v.prototype.revert=function(t){return t},v.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);0<=t.compareTo(this.m);)t.subTo(this.m,t)},v.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},v.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var Q=v;function v(t){this.m=t,this.r2=b(),this.q3=b(),m.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t)}function b(){return new m(null)}function T(t,e){return new m(t,e)}for(var S="undefined"!=typeof navigator,S=S&&"Microsoft Internet Explorer"==navigator.appName?(m.prototype.am=function(t,e,i,r,n,s){for(var o=32767&e,h=e>>15;0<=--s;){var a=32767&this[t],u=this[t++]>>15,c=h*a+u*o;n=((a=o*a+((32767&c)<<15)+i[r]+(1073741823&n))>>>30)+(c>>>15)+h*u+(n>>>30),i[r++]=1073741823&a}return n},30):S&&"Netscape"!=navigator.appName?(m.prototype.am=function(t,e,i,r,n,s){for(;0<=--s;){var o=e*this[t++]+i[r]+n;n=Math.floor(o/67108864),i[r++]=67108863&o}return n},26):(m.prototype.am=function(t,e,i,r,n,s){for(var o=16383&e,h=e>>14;0<=--s;){var a=16383&this[t],u=this[t++]>>14,c=h*a+u*o;n=((a=o*a+((16383&c)<<14)+i[r]+n)>>28)+(c>>14)+h*u,i[r++]=268435455&a}return n},28),E=(m.prototype.DB=S,m.prototype.DM=(1<>>16)&&(t=e,i+=16),0!=(e=t>>8)&&(t=e,i+=8),0!=(e=t>>4)&&(t=e,i+=4),0!=(e=t>>2)&&(t=e,i+=2),0!=(e=t>>1)&&(t=e,i+=1),i}m.ZERO=x(0),m.ONE=x(1);et.prototype.init=function(t){for(var e,i,r=0;r<256;++r)this.S[r]=r;for(r=e=0;r<256;++r)e=e+this.S[r]+t[r%t.length]&255,i=this.S[r],this.S[r]=this.S[e],this.S[e]=i;this.i=0,this.j=0},et.prototype.next=function(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]};var tt=et;function et(){this.i=0,this.j=0,this.S=[]}var it,B,A,rt,nt,O,V=null;if(null==V){if(V=[],A=void(B=0),"undefined"!=typeof window&&window.crypto&&window.crypto.getRandomValues)for(rt=new Uint32Array(256),window.crypto.getRandomValues(rt),A=0;A>3,t=function(t,e){if(e>6|192):(i[--e]=63&n|128,i[--e]=n>>6&63|128,i[--e]=n>>12|224)}i[--e]=0;for(var s=new ot,o=[];2>1,n=(this.e=parseInt(e,16),new m(e,16));;){for(;this.p=new m(t-r,1,i),0!=this.p.subtract(m.ONE).gcd(n).compareTo(m.ONE)||!this.p.isProbablePrime(10););for(;this.q=new m(r,1,i),0!=this.q.subtract(m.ONE).gcd(n).compareTo(m.ONE)||!this.q.isProbablePrime(10););this.p.compareTo(this.q)<=0&&(s=this.p,this.p=this.q,this.q=s);var s=this.p.subtract(m.ONE),o=this.q.subtract(m.ONE),h=s.multiply(o);if(0==h.gcd(n).compareTo(m.ONE)){this.n=this.p.multiply(this.q),this.d=n.modInverse(h),this.dmp1=this.d.mod(s),this.dmq1=this.d.mod(o),this.coeff=this.q.modInverse(this.p);break}}},I.prototype.decrypt=function(t){t=T(t,16),t=this.doPrivate(t);if(null==t)return null;for(var e=this.n.bitLength()+7>>3,i=t.toByteArray(),r=0;r=i.length)return null;for(var n="";++r>1,h=(this.e=parseInt(e,16),new m(e,16)),a=this,u=function(){function e(){a.p=b(),a.p.fromNumberAsync(t-o,1,s,function(){a.p.subtract(m.ONE).gcda(h,function(t){0==t.compareTo(m.ONE)&&a.p.isProbablePrime(10)?setTimeout(r,0):setTimeout(e,0)})})}var i=function(){a.p.compareTo(a.q)<=0&&(t=a.p,a.p=a.q,a.q=t);var t=a.p.subtract(m.ONE),e=a.q.subtract(m.ONE),i=t.multiply(e);0==i.gcd(h).compareTo(m.ONE)?(a.n=a.p.multiply(a.q),a.d=h.modInverse(i),a.dmp1=a.d.mod(t),a.dmq1=a.d.mod(e),a.coeff=a.q.modInverse(a.p),setTimeout(function(){n()},0)):setTimeout(u,0)},r=function(){a.q=b(),a.q.fromNumberAsync(o,1,s,function(){a.q.subtract(m.ONE).gcda(h,function(t){0==t.compareTo(m.ONE)&&a.q.isProbablePrime(10)?setTimeout(i,0):setTimeout(r,0)})})};setTimeout(e,0)};setTimeout(u,0)},I.prototype.sign=function(t,e,i){i=function(t,e){if(e=e?t:new Array(e-t.length+1).join("0")+t},this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=stohex(t)},this.setByDateValue=function(t,e,i,r,n,s){t=new Date(Date.UTC(t,e-1,i,r,n,s,0));this.setByDate(t)},this.getFreshValueHex=function(){return this.hV}},N.lang.extend(P.asn1.DERAbstractTime,P.asn1.ASN1Object),P.asn1.DERAbstractStructured=function(t){P.asn1.DERAbstractString.superclass.constructor.call(this);this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,void 0!==t&&void 0!==t.array&&(this.asn1Array=t.array)},N.lang.extend(P.asn1.DERAbstractStructured,P.asn1.ASN1Object),P.asn1.DERBoolean=function(){P.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},N.lang.extend(P.asn1.DERBoolean,P.asn1.ASN1Object),P.asn1.DERInteger=function(t){P.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=P.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){t=new m(String(t),10);this.setByBigInteger(t)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.bigint?this.setByBigInteger(t.bigint):void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},N.lang.extend(P.asn1.DERInteger,P.asn1.ASN1Object),P.asn1.DERBitString=function(t){var e;void 0!==t&&void 0!==t.obj&&(e=P.asn1.ASN1Util.newObject(t.obj),t.hex="00"+e.getEncodedHex()),P.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7>>32-n}function i(r,n){var t=2147483648&r,e=2147483648&n,o=1073741824&r,u=1073741824&n,r=(1073741823&r)+(1073741823&n);return o&u?2147483648^r^t^e:o|u?1073741824&r?3221225472^r^t^e:1073741824^r^t^e:r^t^e}function t(r,n,t,e,o,u,f){return r=i(r,i(i(n&t|~n&e,o),f)),i(a(r,u),n)}function e(r,n,t,e,o,u,f){return r=i(r,i(i(n&e|t&~e,o),f)),i(a(r,u),n)}function o(r,n,t,e,o,u,f){return r=i(r,i(i(n^t^e,o),f)),i(a(r,u),n)}function u(r,n,t,e,o,u,f){return r=i(r,i(i(t^(n|~e),o),f)),i(a(r,u),n)}function f(r){for(var n="",t="",e=0;e<=3;e++)n+=(t="0"+(r>>>8*e&255).toString(16)).substr(t.length-2,2);return n}Array();for(var h,c,d,C,m=function(r){for(var n,t=r.length,e=16*(1+((e=t+8)-e%64)/64),o=Array(e-1),u=0,f=0;f>>29,o}(r=function(r){r=r.replace(/\r\n/g,"\n");for(var n="",t=0;t>6|192))+String.fromCharCode(63&e|128):(n=(n+=String.fromCharCode(e>>12|224))+String.fromCharCode(e>>6&63|128))+String.fromCharCode(63&e|128)}return n}(r)),_=1732584193,g=4023233417,p=2562383102,x=271733878,v=0;v