wubianHelper.js 82 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449
  1. /*
  2. 无边星链助手
  3. [Script]
  4. # > 无边星链助手
  5. ^https?:\/\/api\.wubian\.pro url script-request-body https://git.jojo21.top/shawenguan/Quantumult-X/raw/master/Scripts/wubian/wubianHelper.js
  6. ^https?:\/\/api\.wubian\.pro url script-response-body https://git.jojo21.top/shawenguan/Quantumult-X/raw/master/Scripts/wubian/wubianHelper.js
  7. [MITM]
  8. hostname = api.wubian.pro
  9. */
  10. const scriptName = `无边星链助手`;
  11. const magicJS = MagicJS(scriptName, "INFO");
  12. const WuBianConstKey = {
  13. // 基础数据
  14. UserInfo: 'WubianUserInfo',
  15. Token: 'WubianProToken',
  16. BrowserProxyUrl: 'WubianBrowserProxyUrl',
  17. TenantId: 'WubianTenantId',
  18. MarketAlbumListData: 'WubianMarketAlbumListData',
  19. AllMarketGroupListData: 'WubianAllMarketGroupListData',
  20. MyAllArtModifyCountData: 'WubianMyAllArtModifyCountData',
  21. MyAllArtRealCountData: 'WubianMyAllArtRealCountData',
  22. MyArtCountCaptureEnabled: 'WubianMyArtCountCaptureEnabled',
  23. MyArtCountModifyMode: 'WubianMyArtCountModifyMode',
  24. ArtIdNameMapData: 'WubianArtIdNameMapData',
  25. DataMaskingEnabled: 'WubianDataMaskingEnabled',
  26. VerListMaskkingDataMap: 'WubianVerListMaskkingDataMap',
  27. AllUserSimpleInfo: 'WubianAllUserSimpleInfo',
  28. ScoreRankDaily: 'WubianScoreRankDaily',
  29. QueryOthersCollectUserName: 'WubianQueryOthersCollectUserName',
  30. QueryOthersCollectHashId: 'WubianQueryOthersCollectHashId',
  31. ActivityListData: 'WubianActivityListData',
  32. ActivityGoodsList: 'WubianActivityGoodsList',
  33. ActivityTaskCaptureEnabled: 'WubianActivityTaskCaptureEnabled',
  34. ActivityTagName: 'WubianActivityActivityTagName',
  35. ActivityIndexName: 'WubianActivityIndexName',
  36. ActivityId: 'WubianActivityId',
  37. SynthesisConcurrentMode: 'WubianSynthesisConcurrentMode',
  38. SynthesisRunsPerSecond: 'WubianSynthesisRunsPerSecond',
  39. SynthesisAmount: 'WubianSynthesisTargetAmount',
  40. SynthesisActivityDisabled: 'WubianSynthesisActivityDisabled',
  41. FirstOrderCaptureEnabled: 'WubianFirstOrderCaptureEnabled',
  42. FirstArtListData: 'WubianFirstArtListData',
  43. FirstGoodsId: 'WubianFirstGoodsId',
  44. FirstGoodsName: 'WubianFirstGoodsName',
  45. CreateFirstOrderData: 'WubianCreateFirstOrderData',
  46. FirstGrabConcurrentMode: 'WubianFirstGrabConcurrentMode',
  47. FirstGrabRunsPerSecond: 'WubianFirstGrabRunsPerSecond',
  48. ConsignmentCaptureEnabled: 'WubianConsignmentCaptureEnabled',
  49. MyCollectListData: 'WubianMyCollectListData',
  50. ConsignmentArtName: 'WubianConsignmentArtName',
  51. ConsignmentArtId: 'WubianConsignmentArtId',
  52. ConsignmentArtPrice: 'WubianConsignmentArtPrice',
  53. ConsignmentArtAmount: 'WubianConsignmentArtAmount',
  54. FastBuyCaptureEnabled: 'WubianFastBuyCaptureEnabled',
  55. FastBuyQuickModeEnabled: 'WubianFastBuyQuickModeEnabled',
  56. FastBuyArtName: 'WubianFastBuyArtName',
  57. FastBuyArtId: 'WubianFastBuyArtId',
  58. FastBuyArtPrice: 'WubianFastBuyArtPrice',
  59. FastBuyArtAmount: 'WubianFastBuyArtAmount',
  60. FastBuyArtInfo: 'WubianFastBuyArtInfo',
  61. };
  62. const gUserAgent = `Mozilla/5.0 (iPhone; CPU iPhone OS 16_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 Html5Plus/1.0 (Immersed/20) uni-app`;
  63. const gHost = `api.wubian.pro`;
  64. let gToken = magicJS.data.read(WuBianConstKey.Token, '');
  65. const gCommonHeaders = {
  66. 'Accept': `*/*`,
  67. 'Accept-Encoding': `gzip, deflate, br`,
  68. 'Connection': `keep-alive`,
  69. 'Content-Type': `application/json`,
  70. 'Cookie': `token=${gToken}`,
  71. 'Host': gHost,
  72. 'User-Agent': gUserAgent,
  73. 'CLIENT-TYPE': `APP`,
  74. 'token': gToken,
  75. 'Accept-Language': `zh-CN,zh-Hans;q=0.9`
  76. };
  77. let gRetBody;
  78. async function Main() {
  79. if (magicJS.isStrictRequest) {
  80. magicJS.checkRecordRequestBody();
  81. }
  82. if (magicJS.isRequest) {
  83. checkHandleRequest();
  84. } else {
  85. updateHeaders();
  86. }
  87. magicJS.notification.msg('');
  88. if (gRetBody) {
  89. magicJS.done({
  90. body: JSON.stringify(gRetBody)
  91. });
  92. } else {
  93. magicJS.done();
  94. }
  95. }
  96. function checkHandleRequest() {
  97. const url = $request.url;
  98. const path = $request.path;
  99. magicJS.logger.info(`请求url=${url}#${$request.method}`);
  100. magicJS.logger.info(`请求body=${magicJS.getRequestBody()}`);
  101. if ($request && $request.method != 'OPTIONS') {
  102. switch (path) {
  103. case '/vmf/app/login/mobileLogin':
  104. handleMobileLogin();
  105. break;
  106. case '/vmf/app/user/collect/list':
  107. // 我的-产品品类列表
  108. handleUserCollectList();
  109. break;
  110. case '/vmf/app/user/collect/verList':
  111. // 我的-某一个产品的列表详情
  112. handleUserVerList();
  113. break;
  114. case '/vmf/app/user/getBatchGiveArtIds':
  115. break;
  116. case '/vmf/app/user/batchRole':
  117. // 批量下单钱包列表
  118. handleBatchRole();
  119. break;
  120. case '/vmf/app/market/goodsInfo':
  121. // 我的-某产品详情
  122. handleGoodsInfo();
  123. break;
  124. case 'vmf/app/market/confirmGoodsInfo':
  125. handleConfirmGoodsInfo();
  126. break;
  127. case '/vmf/app/common/getInitData':
  128. handleInitData();
  129. break;
  130. case '/vmf/app/index/topBannerList':
  131. break;
  132. case '/vmf/app/index/bannerArticleList':
  133. break;
  134. case '/vmf/app/index/artList':
  135. // 首发产品
  136. handleFirstArtList();
  137. break;
  138. case '/vmf/app/index/firstArtInfo':
  139. // 首发产品详情,市场产品详情
  140. handleFirstArtInfo();
  141. break;
  142. case '/vmf/app/market/confirmArtInfo':
  143. // 首发产品购买信息确认页面
  144. break;
  145. case '/vmf/app/order/createFirstOrder':
  146. // 创建发售订单
  147. break;
  148. case '/vmf/app/index/littleMinerInfo':
  149. break;
  150. case '/vmf/app/article/category':
  151. break;
  152. case '/vmf/app/article/listByCategory':
  153. // 公告列表
  154. handleNoticeList();
  155. break;
  156. case '/vmf/app/article/info':
  157. // 公告详情
  158. handleNoticeInfo();
  159. break;
  160. case '/vmf/app/article/selectArticleByType':
  161. // 产品相关的历史公告
  162. break;
  163. case '/vmf/app/index/recommend':
  164. // 推荐
  165. break;
  166. case '/vmf/app/index/firstArtInfo':
  167. // 产品信息
  168. break;
  169. case '/vmf/app/user/batchRole':
  170. break;
  171. case '/vmf/app/market/albumList':
  172. // 市场分区专辑列表
  173. handleMarketAlbumList();
  174. break;
  175. case '/vmf/app/market/groupList':
  176. // 市场产品寄售列表信息
  177. hadnleMarketGroupList();
  178. break;
  179. case '/vmf/app/market/saleRecord':
  180. // 市场最近成交记录
  181. break;
  182. case '/vmf/app/market/artInfo':
  183. // 市场寄售时产品详情
  184. break;
  185. case '/vmf/app/market/verList':
  186. // 市场某产品寄售列表
  187. handleMarketVerList();
  188. break;
  189. case '/vmf/app/order/entrustArtInfo':
  190. // 市场某产品委托限价范围
  191. break;
  192. case '/vmf/app/order/createEntrustOrder':
  193. // 创建委托订单
  194. break;
  195. case '/vmf/app/order/cancelEntrustOrder':
  196. // 取消委托订单
  197. break;
  198. case '/vmf/app/pay/cashier':
  199. // 支付收银台钱包选择列表
  200. break;
  201. case '/vmf/app/pay/getUrl':
  202. // 获取支付地址
  203. break;
  204. case '/vmf/app/pay/payResult':
  205. break;
  206. case '/vmf/app/synthesis/activityList':
  207. handleActivityList();
  208. break;
  209. case '/vmf/app/synthesis/convertGoodsList':
  210. handleCvtGoodsList();
  211. break;
  212. case '/vmf/app/synthesis/createConvertOrder':
  213. break;
  214. case '/vmf/app/synthesis/compositeGoodsList':
  215. handleCompositeGoodsList();
  216. break;
  217. case '/vmf/app/synthesis/createCompositeOrder':
  218. break;
  219. case 'vmf/app/order/list':
  220. // 订单列表
  221. handleOrderList();
  222. break;
  223. case '/vmf/app/order/info':
  224. // 订单详情
  225. handleOrderInfo();
  226. break;
  227. default:
  228. if (path.indexOf('/vmf/app/order/createFirstOrder') != -1) {
  229. handleCreateFirstOrder();
  230. }
  231. break;
  232. }
  233. }
  234. }
  235. function handleHeaders() {
  236. if ($request && $request.method != 'OPTIONS') {
  237. let headers = $request.headers;
  238. let newToken = headers['token'];
  239. let oldToken = magicJS.data.read(WuBianConstKey.Token, null);
  240. if (newToken) {
  241. if (newToken != oldToken) {
  242. magicJS.logger.info(`当前Token刷新到最新`);
  243. magicJS.notification.appendNotifyInfo(`🎉当前Token刷新到最新`);
  244. } else {
  245. magicJS.logger.info(`当前Token已经是最新无需更新`);
  246. }
  247. magicJS.data.write(WuBianConstKey.Token, newToken);
  248. } else {
  249. let newCookieStr = headers['Cookie'];
  250. if (newCookieStr) {
  251. let cookieDict = magicJS.parseCookies(newCookieStr);
  252. if (cookieDict['token'] != void 0) {
  253. newToken = ookieDict['token'];
  254. magicJS.data.write(WuBianConstKey.Token, newToken);
  255. magicJS.logger.info(`当前Token刷新到最新`);
  256. }
  257. }
  258. }
  259. }
  260. }
  261. function updateHeaders() {
  262. gToken = magicJS.data.read(WuBianConstKey.Token, '');
  263. gCommonHeaders['token'] = gToken;
  264. gCommonHeaders['cookie'] = `token=${gToken}`;
  265. }
  266. function getResponsePlainData() {
  267. let data = magicJS.getResponseBody();
  268. if (!data) {
  269. return;
  270. }
  271. try {
  272. return JSON.parse(data);
  273. } catch (err) {
  274. magicJS.logger.info(data);
  275. magicJS.logger.error(err);
  276. }
  277. }
  278. function getRequestPlainData() {
  279. let data = magicJS.getRequestBody();
  280. let reqData = null;
  281. if (data) {
  282. reqData = JSON.parse(data);
  283. } else {
  284. reqData = magicJS.parseQueryStr($request.url);
  285. }
  286. return reqData;
  287. }
  288. function getQueryPlainData() {
  289. let params = magicJS.parseQueryStr($request.url);
  290. return params;
  291. }
  292. function compareCookieStr(cookieStr1, cookieStr2) {
  293. let cookieDict1 = magicJS.parseCookies(cookieStr1);
  294. let cookieDict2 = magicJS.parseCookies(cookieStr2);
  295. let skipKeys = [];
  296. let retCode = 0;
  297. for (let key in cookieDict1) {
  298. if (!skipKeys.includes(key)) {
  299. if (cookieDict1[key] != void 0 && cookieDict2[key] != void 0 && cookieDict1[key] != cookieDict2[key]) {
  300. magicJS.logger.info(`${key}`);
  301. retCode = -1;
  302. break;
  303. }
  304. }
  305. }
  306. return retCode;
  307. }
  308. function appendCookieStr(newCookieStr) {
  309. let cookieStr = magicJS.data.read(WuBianConstKey.Cookie, null);
  310. let cookieDict = magicJS.parseCookies(cookieStr);
  311. let newCookieDict = magicJS.parseCookies(newCookieStr);
  312. for (let key in newCookieDict) {
  313. cookieDict[key] = newCookieDict[key];
  314. }
  315. cookieStr = magicJS.serializeCookies(cookieDict);
  316. magicJS.data.write(WuBianConstKey.Cookie, cookieStr);
  317. }
  318. /**
  319. * 登录后获取用户信息,然后持久化保存在本地
  320. * @returns
  321. */
  322. function handleMobileLogin() {
  323. let rspData = getResponsePlainData();
  324. if (!rspData) {
  325. return;
  326. }
  327. if (rspData.code != 200) {
  328. return;
  329. }
  330. /*
  331. // 结果示例:
  332. let result = {
  333. "code": 200,
  334. "data": {
  335. "rankInfoHide": 0,
  336. "hashId": "80n19034n1",
  337. "cancellation": 0,
  338. "mobile": "134*****115",
  339. "isAuth": 1,
  340. "isSecurityPassword": 1,
  341. "tokenExpireTime": 1728625959,
  342. "avatar": "/assets/img/avatar01.png",
  343. "token": "bccafa59-d04c-48c9-82f6-08829155b2c6",
  344. "address": "0x3dc7d16739d0f169977f589788007c33a0e8996d",
  345. "locksold": 0,
  346. "gameUserId": 0,
  347. "nickname": "WBXL-9115",
  348. "email": "",
  349. "score": 0,
  350. "lockown": 0
  351. },
  352. "msg": "成功",
  353. "fail": false
  354. }
  355. */
  356. magicJS.data.write(WuBianConstKey.UserInfo, rspData.data);
  357. if (isDataMaskingEnabled()) {
  358. rspData.data.nickname = '测试专用001';
  359. rspData.data.address = '0x0000000000000000000000000000000000000001';
  360. rspData.data.avatar = '/uploads/20240930/c8a5a0d2aa889057e2d79334b70ffd9d.png';
  361. gRetBody = rspData;
  362. }
  363. let token = rspData.data.token;
  364. let expireDate = new Date(rspData.data.tokenExpireTime * 1000);
  365. magicJS.data.write(WuBianConstKey.Token, token);
  366. magicJS.notification.appendNotifyInfo(`🎉当前Token刷新到最新,过期时间:${magicJS.formatDate(expireDate, 'yyyy-MM-dd HH:mm:ss')}`);
  367. }
  368. function handleUserCollectList() {
  369. let rspData = getResponsePlainData();
  370. if (!rspData) {
  371. return;
  372. }
  373. if (rspData.code != 200) {
  374. return;
  375. }
  376. handleHeaders();
  377. let reqData = getRequestPlainData();
  378. if (reqData.state == 1) {//1=收藏中 2=转让中 3=已转让
  379. let artIdNameMapData = magicJS.data.read(WuBianConstKey.ArtIdNameMapData, {});
  380. let realCntDict = getMyAllArtRealCountData();
  381. let modCntDict = getAllArtModifyCountDict();
  382. let list = rspData.data.list;
  383. for (let i = list.length - 1; i >= 0; i--) {
  384. const artInfo = list[i];
  385. artIdNameMapData[artInfo.artId] = artInfo.title;
  386. realCntDict[artInfo.title] = artInfo.total;
  387. }
  388. magicJS.data.write(WuBianConstKey.ArtIdNameMapData, artIdNameMapData);
  389. if (isMyArtCountCaptureEnabled()) {
  390. for (let i = list.length - 1; i >= 0; i--) {
  391. const artInfo = list[i];
  392. realCntDict[artInfo.title] = artInfo.total;
  393. }
  394. setAllArtRealCountDict(realCntDict);
  395. }
  396. if (isMyArtCountModifyMode()) {
  397. for (let i = list.length - 1; i >= 0; i--) {
  398. const artInfo = list[i];
  399. checkArticleModify(artInfo, modCntDict);
  400. if (artInfo.total == 0) {
  401. list.splice(i, 1);
  402. modCntDict[artInfo.title] = 0;
  403. }
  404. }
  405. gRetBody = rspData;
  406. setAllArtModifyCountDict(modCntDict);
  407. }
  408. }
  409. }
  410. function handleUserVerList() {
  411. let rspData = getResponsePlainData();
  412. if (!rspData) {
  413. return;
  414. }
  415. if (rspData.code != 200) {
  416. return;
  417. }
  418. if (isMyArtCountModifyMode()) {
  419. let reqData = getRequestPlainData();
  420. let artHashId = reqData.artHashId;
  421. let count = getArtModifyCountByHashId(artHashId);
  422. if (count != void 0) {
  423. rspData.data.total = count;
  424. gRetBody = rspData;
  425. }
  426. if (isDataMaskingEnabled()) {
  427. let page = reqData.page;
  428. let verListMap = magicJS.data.read(WuBianConstKey.VerListMaskkingDataMap, {});
  429. if (page == 1) {
  430. verListMap = {};
  431. }
  432. let verList = rspData.data.list;
  433. for (let i = 0; i < verList.length; i++) {
  434. let verInfo = verList[i];
  435. let maskStr = desensitizeNumber(verInfo.ver);
  436. if (!verListMap[maskStr]) {
  437. verListMap[maskStr] = [];
  438. }
  439. verListMap[maskStr].push(verInfo.ver);
  440. verInfo.ver = maskStr;
  441. }
  442. magicJS.data.write(WuBianConstKey.VerListMaskkingDataMap, verListMap);
  443. gRetBody = rspData;
  444. }
  445. }
  446. }
  447. function handleBatchRole() {
  448. let rspData = getResponsePlainData();
  449. if (!rspData) {
  450. return;
  451. }
  452. if (rspData.code != 200) {
  453. return;
  454. }
  455. let walletList = rspData.data.walletList;
  456. let firstInfo = walletList[0];
  457. if (firstInfo) {
  458. let batchLockNums = [10, 5, 2, 1];
  459. for (let i = 1; i < batchLockNums.length; i++) {
  460. if (!walletList[i]) {
  461. walletList[i] = {
  462. tips: firstInfo.tips,
  463. name: firstInfo.name,
  464. walletId: firstInfo.walletId,
  465. }
  466. }
  467. walletList[i].batchLockNum = batchLockNums[i];
  468. }
  469. gRetBody = rspData;
  470. }
  471. }
  472. function desensitizeNumber(number, maskChar = '*', leastPadCount = 3) {
  473. // 将数字转换为字符串
  474. let str = number.toString();
  475. // 保留最后一位,其他位用脱敏字符替换
  476. let repCount = Math.max(leastPadCount, str.length - 1);
  477. return maskChar.repeat(repCount) + str[str.length - 1];
  478. }
  479. function getVerNumByMaskStr(maskStr) {
  480. let verListMap = magicJS.data.read(WuBianConstKey.VerListMaskkingDataMap, {});
  481. let arr = verListMap[maskStr];
  482. if (arr && arr.length > 0) {
  483. return getRandomElement(arr);
  484. }
  485. return maskStr;
  486. }
  487. function getRandomElement(arr) {
  488. // 生成一个随机索引
  489. const randomIndex = Math.floor(Math.random() * arr.length);
  490. // 返回随机索引处的元素
  491. return arr[randomIndex];
  492. }
  493. function getArtNameByHashId(hashId) {
  494. let artIdNameMapData = magicJS.data.read(WuBianConstKey.ArtIdNameMapData, {});
  495. return artIdNameMapData[hashId];
  496. }
  497. function getAllArtModifyCountDict() {
  498. let dict = {};
  499. let str = magicJS.data.read(WuBianConstKey.MyAllArtModifyCountData, '');
  500. if (str && str.trim().length > 0) {
  501. let lineArr = str.split('\n');
  502. for (let i = 0; i < lineArr.length; i++) {
  503. let kvArr = lineArr[i].trim().split('=');
  504. let name = kvArr[0].trim();
  505. if (kvArr[1]) {
  506. let count = parseInt(kvArr[1].trim());
  507. dict[name] = count;
  508. }
  509. }
  510. }
  511. return dict;
  512. }
  513. function setAllArtModifyCountDict(dict) {
  514. let str = '';
  515. for (let name in dict) {
  516. str += `${name}=${dict[name]}\n`;
  517. }
  518. magicJS.data.write(WuBianConstKey.MyAllArtModifyCountData, str);
  519. }
  520. function getArtModifyCountByName(name) {
  521. let dict = getAllArtModifyCountDict();
  522. return dict[name];
  523. }
  524. function getArtModifyCountByHashId(hashId) {
  525. let name = getArtNameByHashId(hashId);
  526. if (!name) {
  527. return null;
  528. }
  529. return getArtModifyCountByName(name);
  530. }
  531. function checkArticleModify(artInfo, modifyCntDict) {
  532. let title = artInfo.title;
  533. if (modifyCntDict[title] != void 0) {
  534. artInfo.total = modifyCntDict[title];
  535. }
  536. }
  537. function getMyAllArtRealCountData() {
  538. let dict = {};
  539. let str = magicJS.data.read(WuBianConstKey.MyAllArtRealCountData, '');
  540. if (str && str.trim().length > 0) {
  541. let lineArr = str.split('\n');
  542. for (let i = 0; i < lineArr.length; i++) {
  543. let kvArr = lineArr[i].trim().split('=');
  544. let name = kvArr[0].trim();
  545. if (kvArr[1]) {
  546. let count = parseInt(kvArr[1].trim());
  547. dict[name] = count;
  548. }
  549. }
  550. }
  551. return dict;
  552. }
  553. function setAllArtRealCountDict(dict) {
  554. let str = '';
  555. for (let name in dict) {
  556. str += `${name}=${dict[name]}\n`;
  557. }
  558. magicJS.data.write(WuBianConstKey.MyAllArtRealCountData, str);
  559. }
  560. function handleInitData() {
  561. let rspData = getResponsePlainData();
  562. if (!rspData) {
  563. return;
  564. }
  565. if (rspData.code != 200) {
  566. return;
  567. }
  568. handleHeaders();
  569. }
  570. function handleNoticeList() {
  571. let rspData = getResponsePlainData();
  572. if (!rspData) {
  573. return;
  574. }
  575. if (rspData.code != 200) {
  576. return;
  577. }
  578. let reqData = getRequestPlainData();
  579. let tenantId = reqData.tenantId;
  580. magicJS.data.write(WuBianConstKey.TenantId, tenantId);
  581. if (reqData.page == 1) {
  582. let oneNotice = {
  583. "hashId": "468xab6e",
  584. "category": "系统公告",
  585. "icon": "/uploads/icon/系统公告.png",
  586. "title": "【神秘空间】应有尽有等你来探索!",
  587. "image": "",
  588. "createdTime": magicJS.formatDate(new Date(), 'yyyy-MM-dd HH:mm:ss'),
  589. "type": 0,
  590. "categoryType": 6,
  591. "url": ""
  592. };
  593. rspData.data.list.splice(1, 0, oneNotice);
  594. gRetBody = rspData;
  595. }
  596. }
  597. function handleNoticeInfo() {
  598. let rspData = getResponsePlainData();
  599. if (!rspData) {
  600. return;
  601. }
  602. let reqData = getRequestPlainData();
  603. let hashId = reqData.hashId;
  604. if (hashId == '468xab6e') {
  605. let marketAlbumList = magicJS.data.read(WuBianConstKey.MarketAlbumListData, []);
  606. let marketGroupLstDict = magicJS.data.read(WuBianConstKey.AllMarketGroupListData, {});
  607. let baseLstDict = [];
  608. let relationLstDict = [];
  609. let tempId = 1;
  610. for (let artId in marketGroupLstDict) {
  611. const artInfo = marketGroupLstDict[artId];
  612. const groupName = artInfo.groupName;
  613. const artInfoA = {
  614. sortId: artInfo.sortId,
  615. hash_id: artInfo.artId,
  616. id: tempId,
  617. image: artInfo.image,
  618. title: artInfo.title,
  619. event: "art",
  620. type: { syn: "合成兑换", act: "空投", art: "藏品", pri: "抽奖", article: "公告" },
  621. };
  622. if (!baseLstDict[groupName]) {
  623. baseLstDict[groupName] = [];
  624. }
  625. baseLstDict[groupName].push(artInfoA);
  626. tempId += 1;
  627. const artInfoB = {
  628. sortId: artInfo.sortId,
  629. jumpType: "",
  630. url: "",
  631. timeList: [],
  632. title: artInfo.onSale == 1 ? artInfo.title : artInfo.title + '(停售)',
  633. image: artInfo.image,
  634. activityType: "",
  635. authorName: artInfo.brandName,
  636. type: "art",
  637. typeName: "",
  638. categoryType: "",
  639. relationId: artInfo.artId,
  640. };
  641. if (!relationLstDict[groupName]) {
  642. relationLstDict[groupName] = [];
  643. }
  644. relationLstDict[groupName].push(artInfoB);
  645. }
  646. let artLstText = ``;
  647. let relationAllList = [];
  648. for (let t = 0; t < marketAlbumList.length; t++) {
  649. const albumInfo = marketAlbumList[t];
  650. const albumName = albumInfo.name;
  651. if (albumName.indexOf('推荐') >= 0) {
  652. continue;
  653. }
  654. artLstText += `<p><strong><span style="color:#E53333;">&nbsp; &nbsp; <span style="color:#000000;">${albumName}:</span></span></strong></p>`;
  655. let artLstSubText = ``;
  656. let baseList = baseLstDict[albumName] || [];
  657. let relationList = relationLstDict[albumName] || [];
  658. baseList.sort((a, b) => a.sortId - b.sortId);
  659. relationList.sort((a, b) => a.sortId - b.sortId);
  660. relationAllList = relationAllList.concat(relationList);
  661. for (let i = 0; i < baseList.length; ++i) {
  662. let element = baseList[i];
  663. let dataStr = JSON.stringify(element);
  664. dataStr = dataStr.replace(/"/g, "&quot;");
  665. let tmpStr = `<input ` +
  666. `style="align-content:center;width:80%;height:35px;background:#18bc9c;color:#FFFFFF;" readonly="readonly" ` +
  667. `disabled="disabled" ` +
  668. `name="relation['art'][]" ` +
  669. `value="[显示]藏品:${element.title}" ` +
  670. `data-event="art" ` +
  671. `data-id="${element.hash_id}" ` +
  672. `data-show="1" ` +
  673. `data="${dataStr}" />`;
  674. artLstSubText += tmpStr;
  675. };
  676. artLstText += `<p><strong><span style="color:#E53333;">${artLstSubText}<br /></span></strong></p>`;
  677. }
  678. // magicJS.logger.info(artLstText);
  679. let dateStr = magicJS.formatDate(new Date(), 'yyyy年M月d日');
  680. let content = `
  681. <p><br /></p>
  682. <p style="white-space:normal;"><strong>以下过往开放过的藏品:</strong></p>
  683. <p><br /></p>
  684. ${artLstText}
  685. <p><strong><span style="color:#E53333;"><br /></span></strong></p>
  686. <p><strong><span style="color:#E53333;"><br /></span></strong></p>
  687. <p><strong><span style="color:#E53333;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span></strong></p>
  688. <p style="white-space:normal;text-align:right;"><strong><b>无边星链运营团队</b></strong></p>
  689. <p style="white-space:normal;text-align:right;"><strong><b><br /></b></strong></p>
  690. <p style="white-space:normal;text-align:right;"><strong><b>${dateStr}</b></strong></p>
  691. <p><br /></p>
  692. `;
  693. dateStr = magicJS.formatDate(new Date(), 'yyyy-MM-dd HH:mm:ss');
  694. rspData.data.createdTime = dateStr;
  695. rspData.data.content = content;
  696. rspData.data.relationList = relationAllList;
  697. rspData.data.title = '欢迎来到神秘空间';
  698. gRetBody = rspData;
  699. }
  700. }
  701. function handleMarketAlbumList() {
  702. let rspData = getResponsePlainData();
  703. if (!rspData) {
  704. return;
  705. }
  706. if (rspData.code != 200) {
  707. return;
  708. }
  709. if (rspData.data && rspData.data.length > 0) {
  710. magicJS.data.write(WuBianConstKey.MarketAlbumListData, rspData.data);
  711. }
  712. }
  713. function hadnleMarketGroupList() {
  714. let rspData = getResponsePlainData();
  715. if (!rspData) {
  716. return;
  717. }
  718. if (rspData.code != 200) {
  719. return;
  720. }
  721. let reqData = getRequestPlainData();
  722. let dataDict = magicJS.data.read(WuBianConstKey.AllMarketGroupListData, {});
  723. let sortId = (reqData.page - 1) * 20 + 1;
  724. let list = rspData.data?.list || [];
  725. let groupName = '';
  726. let nowTime = Date.now();
  727. let artIdNameMapData = magicJS.data.read(WuBianConstKey.ArtIdNameMapData, {});
  728. for (let i = 0; i < list.length; ++i) {
  729. let item = list[i];
  730. dataDict[item.artId] = item;
  731. item.sortId = sortId;
  732. item.onSale = 1;
  733. item.updateTime = nowTime;
  734. sortId += 1;
  735. groupName = item.groupName;
  736. artIdNameMapData[item.artId] = item.title;
  737. }
  738. magicJS.data.write(WuBianConstKey.ArtIdNameMapData, artIdNameMapData);
  739. for (let artId in dataDict) {
  740. let item = dataDict[artId];
  741. if (item.updateTime == void 0) {
  742. item.updateTime = 0;
  743. }
  744. if (item.sortId == void 0) {
  745. item.sortId = 9999;
  746. }
  747. if (item.updateTime < nowTime - 2 * 24 * 3600 * 1000) {
  748. item.onSale = 0;
  749. item.sortId = 9999;
  750. } else {
  751. item.onSale = 1;
  752. }
  753. }
  754. magicJS.data.write(WuBianConstKey.AllMarketGroupListData, dataDict);
  755. }
  756. function handleMarketVerList() {
  757. let rspData = getResponsePlainData();
  758. if (!rspData) {
  759. return;
  760. }
  761. if (rspData.code != 200) {
  762. return;
  763. }
  764. let verList = rspData.data.list;
  765. for (let i = 0; i < verList.length; i++) {
  766. let verInfo = verList[i];
  767. verInfo.wallet = `${verInfo.wallet}\n市场流通:${rspData.data.total}`;
  768. }
  769. gRetBody = rspData;
  770. }
  771. function handleActivityList() {
  772. let rspData = getResponsePlainData();
  773. if (!rspData) {
  774. return;
  775. }
  776. if (rspData.code != 200) {
  777. return;
  778. }
  779. let reqData = getRequestPlainData();
  780. // 1=合成活动,2=置换活动,3=分解活动,4=兑换活动
  781. let activityType = reqData.activityType || 0;
  782. let page = reqData.page;
  783. let key = `${WuBianConstKey.ActivityListData}#${activityType}`;
  784. let list = rspData.data.list;
  785. let dataDict = magicJS.data.read(key, {});
  786. let nowTime = Math.floor(Date.now() / 1000);
  787. for (let item of list) {
  788. // name
  789. // startTime
  790. // endTime
  791. // hashId
  792. // activityType
  793. // type 0=合成 1=兑换或置换
  794. // status -1=未开始 1=进行中 2=已结束
  795. const hashId = item.hashId;
  796. dataDict[hashId] = item;
  797. // item.startTime = Math.floor(Date.now() / 1000 - 3600);
  798. // item.endTime = Math.floor(Date.now() / 1000 + 3600);
  799. if (nowTime < item.endTime + 24 * 3600) {
  800. if (item.status == -1) {
  801. item.name = `${item.name}(未开始)`;
  802. } else if (item.status == 2) {
  803. item.name = `${item.name}(已结束)`;
  804. item.endTime = item.endTime + 24 * 3600;
  805. item.status = 1;
  806. }
  807. }
  808. }
  809. magicJS.data.write(key, dataDict);
  810. gRetBody = rspData;
  811. }
  812. function isActivityTaskCaptureEnabled() {
  813. let isEnabled = magicJS.data.read(WuBianConstKey.ActivityTaskCaptureEnabled, true);
  814. return isEnabled;
  815. }
  816. function isFirstOrderCaptureEnabled() {
  817. let isEnabled = magicJS.data.read(WuBianConstKey.FirstOrderCaptureEnabled, true);
  818. return isEnabled;
  819. }
  820. function isConsignmentCaptureEnabled() {
  821. let isEnabled = magicJS.data.read(WuBianConstKey.ConsignmentCaptureEnabled, true);
  822. return isEnabled;
  823. }
  824. function isFastBuyCaptureEnabled() {
  825. let isEnabled = magicJS.data.read(WuBianConstKey.FastBuyCaptureEnabled, true);
  826. return isEnabled;
  827. }
  828. function setActivityDisabled(activityId, bDisabled = true) {
  829. let key = `${WuBianConstKey.SynthesisActivityDisabled}#${activityId}`;
  830. magicJS.data.write(key, bDisabled);
  831. }
  832. function isMyArtCountCaptureEnabled() {
  833. let isEnabled = magicJS.data.read(WuBianConstKey.MyArtCountCaptureEnabled, true);
  834. return isEnabled;
  835. }
  836. function isMyArtCountModifyMode() {
  837. let isEnabled = magicJS.data.read(WuBianConstKey.MyArtCountModifyMode, false);
  838. return isEnabled;
  839. }
  840. function isDataMaskingEnabled() {
  841. let isEnabled = magicJS.data.read(WuBianConstKey.DataMaskingEnabled, true);
  842. return isEnabled;
  843. }
  844. function handleCvtGoodsList() {
  845. let rspData = getResponsePlainData();
  846. if (!rspData) {
  847. return;
  848. }
  849. if (rspData.code != 200) {
  850. return;
  851. }
  852. let reqData = getRequestPlainData();
  853. let activityId = reqData.activityId || 'default';
  854. if (isActivityTaskCaptureEnabled()) {
  855. let activityInfo = rspData.data.activityInfo;
  856. activityId = activityInfo.activityId;
  857. magicJS.data.write(WuBianConstKey.ActivityId, activityId);
  858. magicJS.data.write(WuBianConstKey.ActivityIndexName, activityInfo.name);
  859. magicJS.data.write(WuBianConstKey.SynthesisAmount, 10);
  860. activityInfo.type = 1;
  861. setActivityDisabled(activityId, false);
  862. magicJS.notification.appendNotifyInfo(`🎉[${activityInfo.name}]兑换数据采集成功!`);
  863. }
  864. let key = `${WuBianConstKey.ActivityGoodsList}#${activityId}`;
  865. magicJS.data.write(key, rspData.data);
  866. }
  867. function handleCompositeGoodsList() {
  868. let rspData = getResponsePlainData();
  869. if (!rspData) {
  870. return;
  871. }
  872. if (rspData.code != 200) {
  873. return;
  874. }
  875. let reqData = getRequestPlainData();
  876. let activityId = reqData.id || 'default';
  877. if (isActivityTaskCaptureEnabled()) {
  878. let activityInfo = rspData.data.activityInfo;
  879. activityId = activityInfo.activityId;
  880. magicJS.data.write(WuBianConstKey.ActivityId, activityId);
  881. magicJS.data.write(WuBianConstKey.ActivityIndexName, activityInfo.name);
  882. magicJS.data.write(WuBianConstKey.SynthesisAmount, 10);
  883. activityInfo.type = 0;
  884. setActivityDisabled(activityId, false);
  885. magicJS.notification.appendNotifyInfo(`🎉[${activityInfo.name}]合成数据采集成功!`);
  886. }
  887. let key = `${WuBianConstKey.ActivityGoodsList}#${activityId}`;
  888. magicJS.data.write(key, rspData.data);
  889. }
  890. function handleFirstArtList() {
  891. let rspData = getResponsePlainData();
  892. if (!rspData) {
  893. return;
  894. }
  895. if (rspData.code != 200) {
  896. return;
  897. }
  898. // 结果示例
  899. /*
  900. let result = {
  901. "code": 200,
  902. "data": {
  903. "total": 1,
  904. "next": 0,
  905. "list": [
  906. {
  907. "category": 1,
  908. "coverImage": "",
  909. "refreshTime": 1725881400,
  910. "count": 10000,
  911. "type": 1,
  912. "title": "星链计划",
  913. "avatar": "/uploads/20240830/c18be0bb7951859b97a7a2afba9d33a2.jpg",
  914. "image": "/uploads/20240909/0c5d20baa4c00a3390b131b84bf8d592.jpg",
  915. "tagList": [
  916. ],
  917. "price": 138,
  918. "attachFileType": 1,
  919. "artId": "3oe8bev8",
  920. "nickname": "无边星链",
  921. "status": "1" // 1=进行中 2=已结束
  922. }
  923. ]
  924. },
  925. "msg": "成功",
  926. "fail": false
  927. }
  928. */
  929. // let result = {
  930. // "code": 200,
  931. // "data": {
  932. // "total": 1,
  933. // "next": 0,
  934. // "list": [
  935. // {
  936. // "category": 1,
  937. // "coverImage": "",
  938. // "refreshTime": 1725881400,
  939. // "count": 10000,
  940. // "type": 1,
  941. // "title": "星链计划",
  942. // "avatar": "/uploads/20240830/c18be0bb7951859b97a7a2afba9d33a2.jpg",
  943. // "image": "/uploads/20240909/0c5d20baa4c00a3390b131b84bf8d592.jpg",
  944. // "tagList": [
  945. // ],
  946. // "price": 138,
  947. // "attachFileType": 1,
  948. // "artId": "3oe8bev8",
  949. // "nickname": "无边星链",
  950. // "status": "1"
  951. // }
  952. // ]
  953. // },
  954. // "msg": "成功",
  955. // "fail": false
  956. // }
  957. // rspData = result;
  958. let artDataDict = magicJS.data.read(WuBianConstKey.FirstArtListData, {});
  959. let reqData = getRequestPlainData();
  960. if (reqData && reqData.page == 1) {
  961. artDataDict = {};
  962. }
  963. let artList = rspData.data.list;
  964. for (let item of artList) {
  965. const artId = item.artId;
  966. artDataDict[artId] = item;
  967. }
  968. magicJS.data.write(WuBianConstKey.FirstArtListData, artDataDict);
  969. gRetBody = rspData;
  970. }
  971. function getFirstArtData(artId) {
  972. let artDataDict = magicJS.data.read(WuBianConstKey.FirstArtListData, {});
  973. return artDataDict[artId];
  974. }
  975. function getFirstArtName(artId) {
  976. let data = getFirstArtData(artId);
  977. if (data) {
  978. return data.title;
  979. }
  980. return `${artId}`;
  981. }
  982. function checkIsValidFirstArt(artId) {
  983. let artData = getFirstArtData(artId);
  984. if (artData) {
  985. if (artData.status == 1) {
  986. return true;
  987. }
  988. }
  989. return false;
  990. }
  991. function handleGoodsInfo() {
  992. let rspData = getResponsePlainData();
  993. if (!rspData) {
  994. return;
  995. }
  996. if (rspData.code != 200) {
  997. return;
  998. }
  999. /* 结果示例:
  1000. let result = {
  1001. "code": 200,
  1002. "data": {
  1003. "giveInfo": "",
  1004. "resellInfo": "",
  1005. "author": {
  1006. "avatar": "/uploads/20240830/c18be0bb7951859b97a7a2afba9d33a2.jpg",
  1007. "address": "0x96d1e7792e13c655b311e68e71d56698346786ce",
  1008. "isAuthor": 1,
  1009. "id": "657v3oean1",
  1010. "bio": "",
  1011. "isFocus": "",
  1012. "nickName": "无边星链"
  1013. },
  1014. "owner": {
  1015. "avatar": "/assets/img/avatar01.png",
  1016. "address": "0x3dc7d16739d0f169977f589788007c33a0e8996d",
  1017. "isAuthor": 0,
  1018. "id": "80n19034n1",
  1019. "bio": "",
  1020. "isFocus": "",
  1021. "nickName": "******5"
  1022. },
  1023. "button": [
  1024. {
  1025. "key": "NONE",
  1026. "disable": 1,
  1027. "highlight": ""
  1028. }
  1029. ],
  1030. "isBox": 0,
  1031. "paymentInfo": {
  1032. "walletType": "",
  1033. "isBuy": 0,
  1034. "price": 48,
  1035. "serviceRate": "0.07",
  1036. "saleMinPrice": "",
  1037. "saleMaxPrice": "",
  1038. "mainOrderSn": "",
  1039. "beginSaleTime": "",
  1040. "walletId": ""
  1041. },
  1042. "info": {
  1043. "lock": false,
  1044. "tokenId": "182894170004127",
  1045. "status": 2,
  1046. "title": "星链计划",
  1047. "image": "/uploads/20240909/0c5d20baa4c00a3390b131b84bf8d592.jpg",
  1048. "count": 10000,
  1049. "images": "",
  1050. "contractAddress": "0x3a7ddb3129c52e8304ba1124a6d5c5f6622d8038",
  1051. "type": 1,
  1052. "brandName": "无边星链",
  1053. "id": "e3nl20k41n4d",
  1054. "ver": 4127,
  1055. "attachFileType": 1,
  1056. "circulationNum": 7500,
  1057. "groupName": "限价区",
  1058. "json": "{\"entrustEnable\":\"1\"}",
  1059. "artId": "3oe8bev8",
  1060. "isLike": 0,
  1061. "attachFile": "",
  1062. "content": "在浩渺的宇宙中,人类的探索从未停止。【星链计划】便是对人类太空探索梦想的独特诠释。这件藏品以精湛的工艺呈现出星链在太空中的壮丽景象。神秘深邃的背景中,无数颗卫星如同璀璨的明珠,以特定的轨道排列,仿佛一条闪耀着科技之光的银河。每一颗卫星都刻画得细致入微,金属质感的外壳散发着冷冽的光泽,彰显着现代科技的强大魅力。星链计划不仅代表着在宇宙领域的重大突破,更是人类向太空进军的勇敢尝试,也是对人类无限创造力的致敬。它不仅具有极高的艺术价值,更是历史与未来的交汇点,让你在欣赏它的同时,仿佛能感受到宇宙的浩瀚与人类的伟大。",
  1063. "description": ""
  1064. }
  1065. },
  1066. "msg": "成功",
  1067. "fail": false
  1068. }
  1069. */
  1070. let artInfo = rspData.data.info;
  1071. let paymentInfo = rspData.data.paymentInfo;
  1072. if (isConsignmentCaptureEnabled()) {
  1073. let oldArtId = magicJS.data.read(WuBianConstKey.ConsignmentArtId, null);
  1074. if (oldArtId != artInfo.artId) {
  1075. if (typeof paymentInfo.saleMaxPrice == 'number') {
  1076. magicJS.data.write(WuBianConstKey.ConsignmentArtPrice, paymentInfo.saleMaxPrice);
  1077. } else {
  1078. if (paymentInfo.price > 0) {
  1079. magicJS.data.write(WuBianConstKey.ConsignmentArtPrice, paymentInfo.price);
  1080. } else {
  1081. magicJS.data.write(WuBianConstKey.ConsignmentArtPrice, 9999);
  1082. }
  1083. }
  1084. }
  1085. magicJS.data.write(WuBianConstKey.ConsignmentArtId, artInfo.artId);
  1086. magicJS.data.write(WuBianConstKey.ConsignmentArtName, artInfo.title);
  1087. magicJS.notification.appendNotifyInfo(`🎉[${artInfo.title}]一键寄售数据采集成功!`);
  1088. }
  1089. let authorInfo = rspData.data.author;
  1090. if (typeof paymentInfo.saleMinPrice == 'string' && paymentInfo.saleMinPrice.length == 0) {
  1091. paymentInfo.saleMinPrice = 1;
  1092. }
  1093. if (typeof paymentInfo.saleMaxPrice == 'string' && paymentInfo.saleMaxPrice.length == 0) {
  1094. paymentInfo.saleMaxPrice = 99999;
  1095. }
  1096. let buttons = rspData.data.button;
  1097. if (buttons[0].disable == 1) {
  1098. // let mapList = [
  1099. // ["DESTROY", "已销毁"],
  1100. // ["LOCKING", "锁定中"],
  1101. // ["OPENED", "已开启"],
  1102. // ["SOLD", "已售出"],
  1103. // ["PAY", "立即购买"],
  1104. // ["DRIVE", "车辆试驾"],
  1105. // ["AVATAR", "设为头像"],
  1106. // ["CLOSE_SALE", "取消寄售"],
  1107. // ["SALE", "平台寄售"],
  1108. // ["GIVE", "转赠好友"],
  1109. // ["OPEN_BOX", "打开宝箱"],
  1110. // ["SYNTHESISING", "合成中"],
  1111. // ["NONE", "暂未开放"],
  1112. // ["CONVERT", "兑换"],
  1113. // ["SHARE", "分享"],
  1114. // ["RESELL", "转售"],
  1115. // ];
  1116. let frtBtnKey = buttons[0]?.key;
  1117. if (frtBtnKey == void 0 || frtBtnKey == 'NONE') {
  1118. buttons[0].disable = 0;
  1119. buttons[0].key = 'SALE';
  1120. buttons[1] = {
  1121. disable: 0,
  1122. key: 'GIVE',
  1123. };
  1124. authorInfo.nickName = `${authorInfo.nickName}#改`;
  1125. }
  1126. }
  1127. let owner = rspData.data.owner;
  1128. if (owner) {
  1129. let userDataCache = magicJS.data.read(WuBianConstKey.AllUserSimpleInfo, {});
  1130. if (!userDataCache[owner.id]) {
  1131. userDataCache[owner.id] = {
  1132. nickName: owner.nickName,
  1133. hashId: owner.id,
  1134. address: owner.address,
  1135. };
  1136. }
  1137. }
  1138. gRetBody = rspData;
  1139. }
  1140. function handleConfirmGoodsInfo() {
  1141. let rspData = getResponsePlainData();
  1142. if (!rspData) {
  1143. return;
  1144. }
  1145. if (rspData.code != 200) {
  1146. return;
  1147. }
  1148. let owner = data.owner;
  1149. if (owner) {
  1150. let userDataCache = magicJS.data.read(WuBianConstKey.AllUserSimpleInfo, {});
  1151. if (!userDataCache[owner.id]) {
  1152. userDataCache[owner.id] = {
  1153. nickName: owner.nickName,
  1154. hashId: owner.id,
  1155. address: owner.address,
  1156. };
  1157. } else {
  1158. userDataCache[owner.id].nickName = owner.nickName;
  1159. userDataCache[owner.id].hashId = owner.id;
  1160. userDataCache[owner.id].address = owner.address;
  1161. }
  1162. }
  1163. }
  1164. function handleFirstArtInfo() {
  1165. let rspData = getResponsePlainData();
  1166. if (!rspData) {
  1167. return;
  1168. }
  1169. if (rspData.code != 200) {
  1170. return;
  1171. }
  1172. /* 结果示例:
  1173. let result = {
  1174. "code": 200,
  1175. "data": {
  1176. "artInfo": {
  1177. "description": "",
  1178. "brandName": "无边星链",
  1179. "preBookTime": 600,
  1180. "contractAddress": "0x3a7ddb3129c52e8304ba1124a6d5c5f6622d8038",
  1181. "json": "{\"entrustEnable\":\"1\"}",
  1182. "count": 10000,
  1183. "isLike": 0,
  1184. "type": 1,
  1185. "title": "星链计划",
  1186. "image": "/uploads/20240909/0c5d20baa4c00a3390b131b84bf8d592.jpg",
  1187. "btnContent": "",
  1188. "attachfile": "",
  1189. "attachfileType": 1,
  1190. "images": [
  1191. ],
  1192. "groupName": "限价区",
  1193. "artId": "3oe8bev8",
  1194. "circulationNum": 8723,
  1195. "status": 2,
  1196. "content": "在浩渺的宇宙中,人类的探索从未停止。【星链计划】便是对人类太空探索梦想的独特诠释。这件藏品以精湛的工艺呈现出星链在太空中的壮丽景象。神秘深邃的背景中,无数颗卫星如同璀璨的明珠,以特定的轨道排列,仿佛一条闪耀着科技之光的银河。每一颗卫星都刻画得细致入微,金属质感的外壳散发着冷冽的光泽,彰显着现代科技的强大魅力。星链计划不仅代表着在宇宙领域的重大突破,更是人类向太空进军的勇敢尝试,也是对人类无限创造力的致敬。它不仅具有极高的艺术价值,更是历史与未来的交汇点,让你在欣赏它的同时,仿佛能感受到宇宙的浩瀚与人类的伟大。"
  1197. },
  1198. "authorInfo": {
  1199. "avatar": "/uploads/20240830/c18be0bb7951859b97a7a2afba9d33a2.jpg",
  1200. "address": "0x96d1e7792e13c655b311e68e71d56698346786ce",
  1201. "isAuthor": 1,
  1202. "id": "657v3oean1",
  1203. "bio": "",
  1204. "isFocus": "",
  1205. "nickName": "无边星链"
  1206. },
  1207. "covertInfo": "",
  1208. "payInfo": {
  1209. "category": 1,
  1210. "enableConsignment": 0,
  1211. "price": 138,
  1212. "limited": 0,
  1213. "refreshTime": 0,
  1214. "btnContent": "立即购买",
  1215. "serviceRate": "0.07",
  1216. "saleMaxPrice": 438,
  1217. "saleMinPrice": 1
  1218. }
  1219. },
  1220. "msg": "成功",
  1221. "fail": false
  1222. }
  1223. */
  1224. let artInfo = rspData.data.artInfo;
  1225. let authorInfo = rspData.data.authorInfo;
  1226. let payInfo = rspData.data.payInfo;
  1227. if (checkIsValidFirstArt(artInfo.artId)) {
  1228. if (isFirstOrderCaptureEnabled()) {
  1229. magicJS.data.write(WuBianConstKey.CreateFirstOrderData, {
  1230. title: artInfo.title,
  1231. artId: artInfo.artId,
  1232. price: artInfo.price,
  1233. num: payInfo.limited,
  1234. });
  1235. magicJS.data.write(WuBianConstKey.FirstGoodsId, artInfo.artId);
  1236. magicJS.data.write(WuBianConstKey.FirstGoodsName, artInfo.title);
  1237. magicJS.notification.appendNotifyInfo(`🎉产品[${artInfo.title}]首发数据采集成功!`);
  1238. }
  1239. } else {
  1240. if (isFastBuyCaptureEnabled()) {
  1241. let oldArtId = magicJS.data.read(WuBianConstKey.FastBuyArtId, null);
  1242. if (oldArtId != artInfo.artId) {
  1243. magicJS.data.write(WuBianConstKey.FastBuyArtPrice, payInfo.saleMinPrice || 1);
  1244. }
  1245. magicJS.data.write(WuBianConstKey.FastBuyArtId, artInfo.artId);
  1246. magicJS.data.write(WuBianConstKey.FastBuyArtName, artInfo.title);
  1247. magicJS.data.write(WuBianConstKey.FastBuyArtInfo, artInfo);
  1248. magicJS.notification.appendNotifyInfo(`🎉产品[${artInfo.title}]快捷购买数据采集成功!`);
  1249. }
  1250. }
  1251. artInfo.title = `${artInfo.title}(流通:${artInfo.circulationNum})`;
  1252. // 购买寄售强开
  1253. if (payInfo.enableConsignment == 0) {
  1254. payInfo.enableConsignment = 1;
  1255. authorInfo.nickName = `${authorInfo.nickName}#改`;
  1256. magicJS.logger.info(`强制开启批量购买功能`);
  1257. }
  1258. // payInfo只跟首发相关
  1259. // 强制开启首发购买
  1260. // artInfo.status = 1;
  1261. if (payInfo.limited < 1) {
  1262. // 购买数量强开
  1263. payInfo.limited = 999;
  1264. magicJS.logger.info(`强制开启购买数量限制`);
  1265. }
  1266. if (payInfo.refreshTime == 0) {
  1267. payInfo.refreshTime = Math.floor(Date.now() / 1000);
  1268. }
  1269. gRetBody = rspData;
  1270. }
  1271. function handleCreateFirstOrder() {
  1272. let rspData = getResponsePlainData();
  1273. if (!rspData) {
  1274. return;
  1275. }
  1276. if (isFirstOrderCaptureEnabled()) {
  1277. // `https://api.wubian.pro/vmf/app/order/createFirstOrder?token=80n19034n1`
  1278. let reqData = JSON.parse(magicJS.getRequestBody());
  1279. let queryParams = magicJS.parseQueryStr($request.url);
  1280. magicJS.data.write(WuBianConstKey.CreateFirstOrderData, {
  1281. token: queryParams.token,
  1282. artId: reqData.artHashId,
  1283. price: reqData.price,
  1284. num: reqData.num,
  1285. });
  1286. magicJS.data.write(WuBianConstKey.FirstGoodsId, reqData.artHashId);
  1287. magicJS.notification.appendNotifyInfo(`🎉产品[${getFirstArtName(reqData.artHashId)}]首发数据采集成功!`);
  1288. }
  1289. }
  1290. function handleOrderList() {
  1291. let rspData = getResponsePlainData();
  1292. if (!rspData) {
  1293. return;
  1294. }
  1295. /**
  1296. *
  1297. 结果示例:
  1298. {
  1299. "code": 200,
  1300. "data": {
  1301. "total": 283,
  1302. "next": 1,
  1303. "list": [
  1304. {
  1305. "state": 8,
  1306. "orderTypeName": "兑换订单",
  1307. "orderSn": "20240919200738282206032433",
  1308. "createdTime": "2024-09-19 20:07:38",
  1309. "count": 82781,
  1310. "authorName": "无边星链",
  1311. "title": "玉兔捣药分解活动!",
  1312. "price": 0,
  1313. "image": "/uploads/20240919/ca5a67f98ed6396fd548752caa3d8974.png",
  1314. "ver": "#22314/82781",
  1315. "orderType": 6,
  1316. "num": 6,
  1317. "lockTime": 0,
  1318. "stateDesc": "已兑换",
  1319. "buttonList": []
  1320. }
  1321. ]
  1322. },
  1323. "msg": "成功",
  1324. "fail": false
  1325. }
  1326. */
  1327. // let mapList = [
  1328. // ["CANCEL_CONSIGNMENT", "取消寄售"],
  1329. // ["VIEW_GOODS", "查看藏品"],
  1330. // ["CANCEL_ORDER", "取消订单"],
  1331. // ["PAY", "去支付"],
  1332. // ["GOODS_LIBRARY", "藏品库"],
  1333. // ["BUY_ANOTHER", "继续购买"],
  1334. // ["ORDER_CONFIRM", "订单确认中"],
  1335. // ["INVOICE", "申请发票"],
  1336. // ["UPDATE_PRICE", "修改价格"],
  1337. // ["CANCEL_COMPETE", "取消竞价"],
  1338. // ["CANCEL_ENTRUST", "取消委托"]
  1339. // ];
  1340. }
  1341. function handleOrderInfo() {
  1342. let rspData = getResponsePlainData();
  1343. if (!rspData) {
  1344. return;
  1345. }
  1346. }
  1347. Main().catch((e) => magicJS.logger.log(`-\n ${e}`)).finally(() => magicJS.done());
  1348. //---SyncByPyScript---MagicJS3-start
  1349. function MagicJS(e = "MagicJS", t = "INFO") { const n = () => { const e = "undefined" != typeof $loon, t = "undefined" != typeof $task, r = "undefined" != typeof module, n = "undefined" != typeof $httpClient && !e, o = "undefined" != typeof $storm, i = "undefined" != typeof $environment && void 0 !== $environment["stash-build"]; var s = n || e || o || i; const a = "undefined" != typeof importModule; return { isLoon: e, isQuanX: t, isNode: r, isSurge: n, isStorm: o, isStash: i, isSurgeLike: s, isScriptable: a, get name() { return e ? "Loon" : t ? "QuantumultX" : r ? "NodeJS" : n ? "Surge" : a ? "Scriptable" : "unknown" }, get build() { return n ? $environment["surge-build"] : i ? $environment["stash-build"] : o ? $storm.buildVersion : void 0 }, get language() { if (n || i) return $environment.language }, get version() { return n ? $environment["surge-version"] : i ? $environment["stash-version"] : o ? $storm.appVersion : r ? process.version : void 0 }, get system() { return n ? $environment.system : r ? process.platform : void 0 }, get systemVersion() { if (o) return $storm.systemVersion }, get deviceName() { if (o) return $storm.deviceName } } }, o = (r, e = "INFO") => { let n = e, t = "\n"; const o = { SNIFFER: 6, DEBUG: 5, INFO: 4, NOTIFY: 3, WARNING: 2, ERROR: 1, CRITICAL: 0, NONE: -1 }, i = { SNIFFER: "", DEBUG: "", INFO: "", NOTIFY: "", WARNING: "❗ ", ERROR: "❌ ", CRITICAL: "❌ ", NONE: "" }, s = (e, t = "INFO") => { o[n] < o[t.toUpperCase()] || console.log(`██[${r}][${t}]` + i[t.toUpperCase()] + e + "\n") }; return { getLevel: () => n, setLevel: e => { n = e }, sniffer: (...e) => { e = e.join(t); s(e, "SNIFFER") }, log: (...e) => { e = e.join(t); console.log(`██[${r}]` + e + "\n") }, debug: (...e) => { e = e.join(t); s(e, "DEBUG") }, info: (...e) => { e = e.join(t); s(e, "INFO") }, notify: (...e) => { e = e.join(t); s(e, "NOTIFY") }, warning: (...e) => { e = e.join(t); s(e, "WARNING") }, error: (...e) => { e = e.join(t); s(e, "ERROR") }, retry: (...e) => { e = e.join(t); s(e, "RETRY") } } }; return new class { constructor(e, t) { var r; this._startTime = Date.now(), this.version = "3.0.0", this.scriptName = e, this.env = n(), this.logger = o(e, t), this.http = "function" == typeof MagicHttp ? MagicHttp(this.env, this.logger) : void 0, this.data = "function" == typeof MagicData ? MagicData(this.env, this.logger) : void 0, this.notification = "function" == typeof MagicNotification ? MagicNotification(this.scriptName, this.env, this.logger, this.http) : void 0, this.utils = "function" == typeof MagicUtils ? MagicUtils(this.env, this.logger) : void 0, this.qinglong = "function" == typeof MagicQingLong ? MagicQingLong(this.env, this.data, this.logger) : void 0, void 0 !== this.data && (t = this.data.read("magic_loglevel"), r = this.data.read("magic_bark_url"), t && this.logger.setLevel(t.toUpperCase()), r) && this.notification.setBark(r), this.logger.info(e + ", 开始执行!") } get isRequest() { return "undefined" != typeof $request } get isStrictRequest() { return "undefined" != typeof $request && "undefined" == typeof $response } get isResponse() { return "undefined" != typeof $response } get isDebug() { return "DEBUG" === this.logger.level } get request() { return "undefined" != typeof $request ? $request : void 0 } get response() { if ("undefined" != typeof $response) return $response.hasOwnProperty("status") && ($response.statusCode = $response.status), $response.hasOwnProperty("statusCode") && ($response.status = $response.statusCode), $response } log(...e) { this.logger.log(e) } toStr(e, t = null) { try { return JSON.stringify(e) } catch { return t } } toObj(e, t = null) { try { return JSON.parse(e) } catch { return t } } checkRecordRequestBody() { if (this.isRequest) { var t = $request.body; if (t) { var r = this.env, n = $request.path; let e = this.scriptName + "#" + n.replace("/", "_"); e = e.replace("?", "#"), r.isQuanX && $prefs.setValueForKey(t, e), (r.isLoon || r.isSurge) && $persistentStore.write(t, e), r.isNode && require("fs").writeFileSync(e + ".json", t, { flag: "w" }, e => console.log(e)) } } } getRequestBody() { var e = this.env, t = $request.path; let r = this.scriptName + "#" + t.replace("/", "_"); if (r = r.replace("?", "#"), e.isSurge || e.isLoon) return $persistentStore.read(r); if (e.isQuanX) return $prefs.valueForKey(r); if (e.isNode) { t = r + ".json", e = require("fs"); if (!e.existsSync(t)) return JSON.parse(e.readFileSync(t)) } } getResponseBody() { if ($response) return $response.body } parseCookies(e, t = !1) { let r = {}; return t ? e && e.split(";").forEach(function (e) { e = e.split("="); r[e.shift().trim()] = decodeURIComponent(e.join("=")) }) : e && e.split(";").forEach(function (e) { e = e.split("="); r[e.shift().trim()] = e.join("=") }), r } serializeCookies(e, t = !1) { var r = []; if (t) for (var n in e) { var o = e[n], n = n + "=" + encodeURIComponent(o); r.push(n) } else for (var i in e) { var s = e[i], i = i + "=" + s; r.push(i) } return r.join("; ") } parseSetCookies(e) { var t = e.split(/,\s*/).map(e => { var e = e.trim().split(/;\s*(?=[^=]+=[^;]*)/), t = e[0].split("=").map(e => e.trim()); const r = { name: t[0], value: t[1] }; return e.slice(1).forEach(e => { var [e, t] = e.split("=").map(e => e.trim()); r[e] = t || !0 }), r }), r = []; let n = 0; for (; n < t.length;) { var o, i = t[n]; r.push(i), i.Expires ? ((o = t[n + 1]) && (i.Expires = i.Expires + "," + o.name), n += 2) : n += 1 } return r } objToQueryStr(t, r) { let n = ""; for (const o in t) { let e = t[o]; null != e && "" !== e && ("object" == typeof e ? e = JSON.stringify(e) : r && (e = encodeURIComponent(e)), n += `${o}=${e}&`) } return n = n.substring(0, n.length - 1) } parseQueryStr(e) { var t = {}, r = (e = -1 < e.indexOf("?") ? e.split("?")[1] : e).split("&"); for (let e = 0; e < r.length; e++) { var n = r[e].split("="); t[n[0]] = n[1] } return t } deepClone(e, t) { for (var r in t = t || {}, e) "object" == typeof e[r] ? (t[r] = e[r].constructor === Array ? [] : {}, this.deepClone(e[r], t[r])) : t[r] = e[r]; return t } formatDate(e, t) { var r, n = { "M+": e.getMonth() + 1, "d+": e.getDate(), "H+": e.getHours(), "m+": e.getMinutes(), "s+": e.getSeconds(), "q+": Math.floor((e.getMonth() + 3) / 3), S: e.getMilliseconds() }; for (r in /(y+)/.test(t) && (t = t.replace(RegExp.$1, (e.getFullYear() + "").substr(4 - RegExp.$1.length))), n) new RegExp("(" + r + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? n[r] : ("00" + n[r]).substr(("" + n[r]).length))); return t } parseDate(a, e) { let l = { y: 0, M: 1, d: 0, H: 0, h: 0, m: 0, s: 0, S: 0 }; (e = e || "yyyy-MM-dd").replace(/([^yMdHmsS]*?)(([yMdHmsS])\3*)([^yMdHmsS]*?)/g, function (e, t, r, n, o, i, s) { return a = a.replace(new RegExp(t + "(\\d{" + r.length + "})" + o), function (e, t) { return l[n] = parseInt(t), "" }), "" }), l.M--; e = new Date(l.y, l.M, l.d, l.H, l.m, l.s); return 0 !== l.S && e.setMilliseconds(l.S), e } getBaseDoneHeaders(e = {}) { return Object.assign({ "Access-Control-Allow-Origin": "*", "Access-Control-Allow-Methods": "POST,GET,OPTIONS,PUT,DELETE", "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept" }, e) } getHtmlDoneHeaders() { return this.getBaseDoneHeaders({ "Content-Type": "text/html;charset=UTF-8" }) } getJsonDoneHeaders() { return this.getBaseDoneHeaders({ "Content-Type": "text/json; charset=utf-8", Connection: "keep-alive" }) } doWxpusherSend(e) { var t = this.getJsonDoneHeaders(), t = (t.Host = "wxpusher.zjiecode.com", t["Content-Type"] = "application/json;charset=UTF-8", { url: "https://wxpusher.zjiecode.com/api/send/message", headers: t, body: JSON.stringify(e) }); return this.http.post(t) } fastWxpusherSend(e, t = "", r = "") { return this.doWxpusherSend({ appToken: "AT_7wDWqSoT8xpJCQqJtHpshKhw7kXc0XCW", content: e, summary: t, contentType: 1, topicIds: [], uids: ["UID_6P4B00X6Zv8U2oKC0I2R09emxtqq"], url: r, verifyPay: !1, verifyPayType: 0 }) } isEmpty(e) { return void 0 === e || null == e || "" == e || "null" == e || "undefined" == e || 0 === e.length } base64Encode(e) { var t, r, n, o = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; let i, s, a; for (a = e.length, s = 0, i = ""; s < a;) { if (t = 255 & e.charCodeAt(s++), s == a) { i = (i += o.charAt(t >> 2)) + o.charAt((3 & t) << 4) + "=="; break } if (r = e.charCodeAt(s++), s == a) { i = (i = (i += o.charAt(t >> 2)) + o.charAt((3 & t) << 4 | (240 & r) >> 4)) + o.charAt((15 & r) << 2) + "="; break } n = e.charCodeAt(s++), i = (i = (i = (i += o.charAt(t >> 2)) + o.charAt((3 & t) << 4 | (240 & r) >> 4)) + o.charAt((15 & r) << 2 | (192 & n) >> 6)) + o.charAt(63 & n) } return i } base64Decode(e) { var t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; if (/([^\s]+[^0-9a-zA-Z\+\/\=]|[^0-9a-zA-Z\+\/\=]\s+)/.test(e)) throw new Error("Invalid base64 input"); var r, n, o, i, s, a, l = e.replace(/\s/g, ""); let u = "", c = 0; for (; c < l.length;)o = t.indexOf(l.charAt(c++)), r = (15 & (i = t.indexOf(l.charAt(c++)))) << 4 | (s = t.indexOf(l.charAt(c++))) >> 2, n = (3 & s) << 6 | (a = t.indexOf(l.charAt(c++))), u += String.fromCharCode(o << 2 | i >> 4), 64 !== s && (u += String.fromCharCode(r)), 64 !== a && (u += String.fromCharCode(n)); return u = this.utf8Decode(u) } utf8Decode(t) { let e = [], r = 0, n = 0, o = 0; for (t = t.replace(/\r\n/g, "\n"); r < t.length;) { n = 255 & t.charCodeAt(r), o = 0, o = n <= 191 ? (n &= 127, 1) : n <= 223 ? (n &= 31, 2) : n <= 239 ? (n &= 15, 3) : (n &= 7, 4); for (let e = 1; e < o; ++e)n = n << 6 | 63 & t.charCodeAt(e + r); 4 === o ? (n -= 65536, e.push(String.fromCharCode(55296 | n >> 10 & 1023)), e.push(String.fromCharCode(56320 | 1023 & n))) : e.push(String.fromCharCode(n)), r += o } return e.join("") } parseJwt(e) { try { var t = e.split("."), r = t[0].replace(/-/g, "+").replace(/_/g, "/"), n = this.base64Decode(r).replace(/\0/g, ""), o = JSON.parse(n), i = t[1].replace(/-/g, "+").replace(/_/g, "/"), s = this.base64Decode(i).replace(/\0/g, ""); return { header: o, payload: JSON.parse(s), signature: t[2] } } catch (e) { return this.log(e), null } } costTime() { var e = this.scriptName + "执行完毕!", t = (this._endTime = (new Date).getTime(), this._endTime - this._startTime); this.logger.info(e + `耗时【${t / 1e3}】秒`) } done = (e = {}) => { this.costTime(), "undefined" != typeof $done && $done(e) } }(e, t) } function MagicHttp(d, p) { var e; let g; d.isNode && (e = require("axios"), g = e.create()); class t { constructor(e = !0) { this.handlers = [], this.isRequest = e } use(e, t, r) { return "function" == typeof e && p.debug("Register fulfilled " + e.name), "function" == typeof t && p.debug("Register rejected " + t.name), this.handlers.push({ fulfilled: e, rejected: t, synchronous: !(!r || "boolean" != typeof r.synchronous) && r.synchronous, runWhen: r ? r.runWhen : null }), this.handlers.length - 1 } eject(e) { this.handlers[e] && (this.handlers[e] = null) } forEach(t) { this.handlers.forEach(e => { null !== e && t(e) }) } } function f(e) { let r = { ...e }; return r.params && !d.isNode && (e = Object.keys(r.params).map(e => { var t = encodeURIComponent(e); return r.url = r.url.replace(new RegExp(e + "=[^&]*", "ig"), ""), r.url = r.url.replace(new RegExp(t + "=[^&]*", "ig"), ""), t + "=" + encodeURIComponent(r.params[e]) }).join("&"), r.url.indexOf("?") < 0 && (r.url += "?"), /(&|\?)$/g.test(r.url) || (r.url += "&"), r.url += e, delete r.params, p.debug("Params to QueryString: " + r.url)), r } const h = (e, t = null) => { if (e) { t = { ...e, config: e.config || t, status: e.statusCode || e.status, body: e.body || e.data, headers: e.headers || e.header }; if ("string" == typeof t.body) try { t.body = JSON.parse(t.body) } catch { } return delete t.data, t } return e }; const y = (e, t = null) => { if (e && 400 <= e.status) return p.debug("Raise exception when status code is " + e.status), { name: "RequestException", message: "Request failed with status code " + e.status, config: t || e.config, response: e } }, m = { request: new t, response: new t(!1) }; let v = [], b = [], S = !0; function N(e) { return e = f(e), p.debug(`HTTP ${e.method.toUpperCase()}:` + "\n" + JSON.stringify(e)), e } function E(t) { try { t = t && h(t), p.sniffer(`HTTP ${t.config.method.toUpperCase()}:` + "\n" + JSON.stringify(t.config) + "\nSTATUS CODE:\n" + t.status + "\nRESPONSE:\n" + ("object" == typeof t.body ? JSON.stringify(t.body) : t.body)); var e = y(t); return e ? Promise.reject(e) : t } catch (e) { return p.error(e), t } } const r = (e, r) => { let n; r = ((e, t) => { let r = "object" == typeof t ? { headers: {}, ...t } : { url: t, headers: {} }; return r.method || (r.method = e), !0 === (r = f(r)).rewrite && (d.isSurge ? (r.headers["X-Surge-Skip-Scripting"] = !1, delete r.rewrite) : d.isQuanX && (r.hints = !1, delete r.rewrite)), d.isSurgeLike ? (t = r.headers["content-type"] || r.headers["Content-Type"], "GET" !== r.method && t && 0 <= t.indexOf("application/json") && r.body instanceof Array && (r.body = JSON.stringify(r.body), p.debug("Convert Array object to String: " + r.body))) : d.isQuanX ? (r.hasOwnProperty("body") && "string" != typeof r.body && (r.body = JSON.stringify(r.body)), r.method = e) : d.isNode && ("POST" === e || "PUT" === e || "PATCH" === e || "DELETE" === e ? r.data = r.data || r.body : "GET" === e && (r.params = r.params || r.body), delete r.body), r })(e.toUpperCase(), r), n = d.isNode ? g : d.isSurgeLike ? i => new Promise((n, o) => { $httpClient[e.toLowerCase()](i, (e, t, r) => { e ? (e = { name: e.name || e, message: e.message || e, stack: e.stack || e, config: i, response: h(t) }, o(e)) : (t.config = i, t.body = r, n(t)) }) }) : n => new Promise((r, t) => { $task.fetch(n).then(e => { e = h(e, n); var t = y(e, n); if (t) return Promise.reject(t); r(e) }).catch(e => { e = { name: e.message || e.error, message: e.message || e.error, stack: e.error, config: n, response: e.response ? h(e.response) : null }; t(e) }) }); let o; var t = r; try { v = [], b = [], m.request.forEach(e => { "function" == typeof e.runWhen && !1 === e.runWhen(t) || (S = S && e.synchronous, v.unshift(e.fulfilled, e.rejected)) }), m.response.forEach(e => { b.push(e.fulfilled, e.rejected) }) } catch (e) { p.error(`Failed to register interceptors: ${e}.`) } var i = [N, void 0], s = [E, void 0]; if (S) { for (p.debug("Interceptors are executed in synchronous mode"), Array.prototype.unshift.apply(v, i), v = v.concat([N, void 0]); v.length;) { var a = v.shift(), l = v.shift(); try { "function" == typeof a && p.debug("Executing request fulfilled " + a.name), r = a(r) } catch (e) { "function" == typeof l && p.debug("Executing request rejected " + l.name), l(e); break } } try { o = (!d.isNode && r.timeout ? c : n)(r) } catch (e) { return Promise.reject(e) } for (Array.prototype.unshift.apply(b, s); b.length;)o = o.then(b.shift(), b.shift()); return o } { p.debug("Interceptors are executed in asynchronous mode"); let t = [n, void 0]; for (Array.prototype.unshift.apply(t, i), Array.prototype.unshift.apply(t, v), t = (t = t.concat(s)).concat(b), o = Promise.resolve(r); t.length;)try { let e = t.shift(); var u = t.shift(); "function" == typeof (e = !d.isNode && r.timeout && e === n ? c : e) && p.debug("Executing request fulfilled " + e.name), "function" == typeof u && p.debug("Executing request rejected " + u.name), o = o.then(e, u) } catch (e) { p.error("request exception: " + e) } return o } function c(r) { try { var e = new Promise((e, t) => { setTimeout(() => { var e = { message: `timeout of ${r.timeout}ms exceeded.`, config: r }; t(e) }, r.timeout) }); return Promise.race([n(r), e]) } catch (e) { p.error(`Request Timeout exception: ${e}.`) } } }; return { request: r, interceptors: m, convertHeadersToLowerCase: r => Object.keys(r).reduce((e, t) => (e[t.toLowerCase()] = r[t], e), {}), convertHeadersToCamelCase: r => Object.keys(r).reduce((e, t) => { return e[t.split("-").map(e => e[0].toUpperCase() + e.slice(1)).join("-")] = r[t], e }, {}), modifyResponse: h, get: e => r("GET", e), post: e => r("POST", e), put: e => r("PUT", e), patch: e => r("PATCH", e), delete: e => r("DELETE", e), head: e => r("HEAD", e), options: e => r("OPTIONS", e) } } function MagicData(d, p) { let g = { fs: void 0, data: {} }; if (d.isNode) { g.fs = require("fs"); try { g.fs.accessSync("./magic.json", g.fs.constants.R_OK | g.fs.constants.W_OK) } catch (e) { g.fs.writeFileSync("./magic.json", "{}", { encoding: "utf8" }) } g.data = require("./magic.json") } const s = (e, t) => "object" != typeof t && e === t, a = e => "true" === e || "false" !== e && (void 0 === e ? null : e), l = (e, t, r, n) => { if (r) try { e = !0 === (e = "string" == typeof e ? JSON.parse(e) : e).magic_session ? e[r] : null } catch { e = null } if ("string" == typeof e && "null" !== e) try { e = JSON.parse(e) } catch { } return null == (e = !1 === n && e && !0 === e.magic_session ? null : e) && null != t && (e = t), e = a(e) }, f = t => { if ("string" != typeof t) return t instanceof Array || null == t || t != t || "boolean" == typeof t ? {} : t; { let e = {}; try { var r = typeof (e = JSON.parse(t)); ("object" != r || e instanceof Array || "bool" == r || null === e) && (e = {}) } catch { } return e } }, u = (e, t = null, r = "", n = !1, o = null) => { let i = ""; return i = o || d.isNode ? ((e, t = null, r = "", n = !1, o = null) => { o = o || g.data; return val = o && void 0 !== o[e] && null !== o[e] ? o[e] : r ? {} : null, val = l(val, t, r, n) })(e, t, r, n, o) : (d.isSurgeLike ? i = $persistentStore.read(e) : d.isQuanX && (i = $prefs.valueForKey(e)), l(i, t, r, n)), p.debug(`READ DATA [${e}]${r ? `[${r}]` : ""} <${typeof i}>` + "\n" + JSON.stringify(i)), i }, c = (e, t, r = "", n = null) => { if (void 0 === t || t != t) return !1; d.isNode || "boolean" != typeof t && "number" != typeof t || (t = String(t)); let o = ""; var i, s, a, l, u, c; if (n || d.isNode ? o = ([i, s, a = "", l = null] = [e, t, r, n], c = l || g.data, c = f(c), a ? ((u = f(c[i])).magic_session = !0, u[a] = s, c[i] = u) : c[i] = s, null !== l && (l = c), c) : r ? (d.isSurgeLike ? o = $persistentStore.read(e) ? $persistentStore.read(e) : o : d.isQuanX && (o = $prefs.valueForKey(e) ? $prefs.valueForKey(e) : o), (o = f(o)).magic_session = !0, o[r] = t) : o = t, o && "object" == typeof o && (o = JSON.stringify(o, null, 4)), p.debug(`WRITE DATA [${e}]${r ? `[${r}]` : ""} <${typeof t}>` + "\n" + JSON.stringify(t)), !n) { if (d.isSurgeLike) return $persistentStore.write(o, e); if (d.isQuanX) return $prefs.setValueForKey(o, e); if (d.isNode) try { g.fs.writeFileSync("./magic.json", o) } catch (e) { return p.error(e), !1 } } return !0 }; return { read: u, write: c, del: (e, t = "", r = null) => { let n = {}; if (r || d.isNode) n = (o = e, i = t, s = r || g.data, s = f(s), i ? (delete (obj = f(s[o]))[i], s[o] = obj) : delete s[o], s), r ? r = n : g.fs.writeFileSync("./magic.json", JSON.stringify(n, null, 4)); else if (t) { d.isSurgeLike ? n = $persistentStore.read(e) : d.isQuanX && (n = $prefs.valueForKey(e)), delete (n = f(n))[t]; i = JSON.stringify(n, null, 4); c(e, i) } else { if (d.isStorm) return $persistentStore.remove(e); if (d.isSurgeLike) return $persistentStore.write(null, e); if (d.isQuanX) return $prefs.removeValueForKey(e) } var o, i, s; p.debug(`DELETE KEY [${e}]` + (t ? `[${t}]` : "")) }, update: (e, t, r, n = s, o = null) => { var i; return t = a(t), !0 !== n(u(e, null, r, !1, o), t) && (i = c(e, t, r, o), e = u(e, null, r, !1, o), n === s && "object" == typeof e ? i : n(t, e)) }, allSessions: (e, t = null) => { let r = {}; t = u(e, null, null, !0, t); return !0 === (t = f(t)).magic_session && delete (r = { ...t }).magic_session, p.debug(`READ ALL SESSIONS [${e}] <${typeof r}>` + "\n" + JSON.stringify(r, null, 4)), r }, allSessionNames: (e, t = null) => { let r = []; t = u(e, null, null, !0, t), t = f(t); return r = !0 !== t.magic_session ? [] : Object.keys(t).filter(e => "magic_session" !== e), p.debug(`READ ALL SESSIONS [${e}] <${typeof r}>` + "\n" + JSON.stringify(r, null, 4)), r }, defaultValueComparator: s, convertToObject: f } } function MagicNotification(i, o, s, a) { let l = null, u = null, c = []; function d(e = i, t = "", r = "", n = "") { n = (t => { try { let e = {}; var r; return "string" == typeof t ? 0 < t.length && (o.isLoon ? e = { openUrl: t } : o.isQuanX ? e = { "open-url": t } : o.isSurge && (e = { url: t })) : "object" == typeof t && (o.isLoon ? (e.openUrl = t["open-url"] || "", e.mediaUrl = t["media-url"] || "") : o.isQuanX ? e = t["open-url"] || t["media-url"] ? t : {} : o.isSurge && (r = t["open-url"] || t.openUrl, e = r ? { url: r } : {})), e } catch (e) { s.error("通知选项转换失败" + e) } return t })(n), 1 === arguments.length && (e = i, t = "", r = arguments[0]), s.notify("\ntitle:" + e + "\nsubTitle:" + t + "\nbody:" + r + "\noptions:" + ("object" == typeof n ? JSON.stringify(n) : n)), o.isSurge ? $notification.post(e, t, r, n) : o.isLoon ? n ? $notification.post(e, t, r, n) : $notification.post(e, t, r) : o.isQuanX && $notify(e, t, r, n), l && u && p(e, t, r) } function p(e = i, t = "", r = "", n) { if (void 0 === a || void 0 === a.post) throw "Bark notification needs to import MagicHttp module."; e = { url: l, headers: { "content-type": "application/json; charset=utf-8" }, body: { title: e, body: t ? t + "\n" + r : r, device_key: u } }; a.post(e).catch(e => { s.error("Bark notify error: " + e) }) } return { post: d, debug: function (e = i, t = "", r = "", n = "") { "DEBUG" === s.getLevel() && (1 === arguments.length && (e = i, t = "", r = arguments[0]), this.post(e, t, r, n)) }, bark: p, setBark: e => { try { var t = e.replace(/\/+$/g, ""); l = /^https?:\/\/([^/]*)/.exec(t)[0] + "/push", u = /\/([^\/]+)\/?$/.exec(t)[1] } catch (e) { s.error(`Bark url error: ${e}.`) } }, appendNotifyInfo: function (e, t) { 1 == t ? c = e : c.push(e) }, prependNotifyInfo: function (e) { c.splice(0, 0, e) }, msg: function (e, t, r, n) { var o = {}; r && (o["open-url"] = r), n && (o["media-url"] = n), (t = t && 0 != t.length ? t : Array.isArray(c) ? c.join("\n") : c) && 0 < t.length && d(i, "", t, o) } } } function MagicUtils(n, u) { const e = (e, t = "yyyy-MM-dd hh:mm:ss") => { var r, n = { "M+": e.getMonth() + 1, "d+": e.getDate(), "h+": e.getHours(), "m+": e.getMinutes(), "s+": e.getSeconds(), "q+": Math.floor((e.getMonth() + 3) / 3), S: e.getMilliseconds() }; for (r in /(y+)/.test(t) && (t = t.replace(RegExp.$1, (e.getFullYear() + "").substr(4 - RegExp.$1.length))), n) new RegExp("(" + r + ")").test(t) && (t = t.replace(RegExp.$1, 1 === RegExp.$1.length ? n[r] : ("00" + n[r]).substr(("" + n[r]).length))); return t }; return { retry: (i, s = 5, a = 0, l = null) => (...e) => new Promise((r, n) => { function o(...t) { Promise.resolve().then(() => i.apply(this, t)).then(e => { "function" == typeof l ? Promise.resolve().then(() => l(e)).then(() => { r(e) }).catch(e => { 1 <= s ? 0 < a ? setTimeout(() => o.apply(this, t), a) : o.apply(this, t) : n(e), s-- }) : r(e) }).catch(e => { u.error(e), 1 <= s && 0 < a ? setTimeout(() => o.apply(this, t), a) : 1 <= s ? o.apply(this, t) : n(e), s-- }) } o.apply(this, e) }), formatTime: e, now: () => e(new Date, "yyyy-MM-dd hh:mm:ss"), today: () => e(new Date, "yyyy-MM-dd"), sleep: t => new Promise(e => setTimeout(e, t)), assert: (e, t = null) => { var r; n.isNode ? (r = require("assert"), t ? r(e, t) : r(e)) : !0 !== e && u.error("AssertionError: " + (t || "The expression evaluated to a falsy value.")) } } } function MagicQingLong(e, a, o) { let i = "", s = "", l = "", u = "", c = "", t = ""; const d = "magic.json", p = MagicHttp(e, o); async function r() { return l = l || a.read("magic_qlclient"), u = u || a.read("magic_qlsecrt"), s = s || a.read("magic_qlname"), c = c || a.read("magic_qlpwd"), i && l && u ? (o.info("Get token from QingLong Panel"), await p.get({ url: "/open/auth/token", headers: { "content-type": "application/json" }, params: { client_id: l, client_secret: u } }).then(e => { if (!(0 < Object.keys(e.body).length && e.body.data && e.body.data.token)) throw new Error("Get QingLong Panel token failed."); o.info("Successfully logged in to QingLong Panel"), t = e.body.data.token, a.write("magic_qltoken", t) }).catch(e => { o.error("Error logging in to QingLong Panel.\n" + (e.message || e)) })) : i && s && c && await p.post({ url: "/api/user/login", headers: { "content-type": "application/json" }, body: { username: s, password: c } }).then(e => { o.info("Successfully logged in to QingLong Panel"), t = e.body.data.token, a.write("magic_qltoken", t) }).catch(e => { o.error("Error logging in to QingLong Panel.\n" + (e.message || e)) }), t } async function g(e) { let t = []; return await p.post({ url: "/api/envs", headers: { "content-type": "application/json" }, body: e }).then(e => { 200 === e.body.code ? e.body.data.forEach(e => { o.debug(`QINGLONG ADD ENV ${e.name} <${typeof e.value}> (${e.id})` + "\n" + JSON.stringify(e)), t.push(e.id) }) : o.error("Error adding environments variable from QingLong Panel.\n" + JSON.stringify(e)) }).catch(e => { o.error("Error adding environments variable from QingLong Panel.\n" + (e.message || e)) }), t } async function n(n = null, e = "", t) { let o = []; return await p.get({ url: "/api/envs", headers: { "content-type": "application/json" }, params: { searchValue: e } }).then(e => { if (200 !== e.body.code) throw new Error("Error reading environment variable from QingLong Panel.\n" + JSON.stringify(e)); e = e.body.data; if (n) { var t = []; for (const r of e) r.name === n && o.push(r); o = t } o = e }).catch(e => { throw new Error("Error reading environments variable from QingLong Panel.\n" + (e.message || e)) }), o } async function f(e, t = "") { let r = ""; return await p.get({ url: "/api/scripts/" + e, params: { path: t } }).then(e => { if (200 !== e.body.code) throw new Error("Error reading data from QingLong Panel.\n" + JSON.stringify(e)); r = e.body.data }).catch(e => { throw new Error("Error reading data from QingLong Panel.\n" + (e.message || e)) }), r } async function h(e, t = "", r = "") { let n = !1; return await p.put({ url: "/api/scripts", headers: { "content-type": "application/json" }, body: { filename: e, path: t, content: r } }).then(e => { 200 === e.body.code ? n = !0 : o.error("Error reading data from QingLong Panel.\n" + JSON.stringify(e)) }).catch(e => { o.error("Error reading data from QingLong Panel.\n" + (e.message || e)) }), n } return p.interceptors.request.use(function (e) { return i = i || a.read("magic_qlurl"), e.url.indexOf(i) < 0 && (e.url = "" + i + e.url), { ...e, timeout: 3e3 } }, void 0), p.interceptors.request.use(function (e) { return (l = l || a.read("magic_qlclient")) && (e.url = e.url.replace("/api/", "/open/")), e }, void 0, { runWhen: e => e.url.indexOf("api/user/login") < 0 && e.url.indexOf("open/auth/token") < 0 }), p.interceptors.request.use(async function (e) { return (t = t || a.read("magic_qltoken", "")) || await r(), e.headers.authorization = "Bearer " + t, e }, void 0, { runWhen: e => e.url.indexOf("api/user/login") < 0 && e.url.indexOf("open/auth/token") < 0 }), p.interceptors.request.use(function (e) { return e.params = { ...e.params, t: Date.now() }, e }, void 0, { runWhen: e => e.url.indexOf("open/auth/token") < 0 }), p.interceptors.request.use(function (e) { return i = i || a.read("magic_qlurl"), t = t || a.read("magic_qltoken"), o.debug("QingLong url: " + i + "\nQingLong token: " + t), e }, void 0), p.interceptors.response.use(void 0, async function (e) { try { var t = e.message || e.error || JSON.stringify(e); return (0 <= t.indexOf("NSURLErrorDomain") && 0 <= t.indexOf("-1012") || e.response && 401 === e.response.status) && e.config && !0 !== e.config.refreshToken ? (o.warning("QingLong Panel token has expired"), o.info("Refreshing the QingLong Panel token"), await r(), e.config.refreshToken = !0, o.info("Call the previous method again"), await p.request(e.config.method, e.config)) : Promise.reject(e) } catch (e) { return Promise.reject(e) } }), { url: i || a.read("magic_qlurl"), init: (e, t, r, n, o) => { i = e, l = t, u = r, s = n, c = o }, getToken: r, setEnv: async function (t, r, n = null) { if (i = i || a.read("magic_qlurl"), null === n) { var e = await g([{ name: t, value: r }]); if (e && 1 === e.length) return e[0] } else await p.put({ url: "/api/envs", headers: { "content-type": "application/json" }, body: { name: t, value: r, id: n } }).then(e => { if (200 === e.body.code) return o.debug(`QINGLONG UPDATE ENV ${t} <${typeof r}> (${n})` + "\n" + JSON.stringify(r)), !0; o.error("Error adding environment variable from QingLong Panel.\n" + JSON.stringify(e)) }).catch(e => (o.error("Error adding environment variable from QingLong Panel.\n" + (e.message || e)), !1)) }, setEnvs: g, getEnv: async function (e) { let t = null; for (const r of await n()) if (r.id === e) { t = r; break } return t }, getEnvs: n, delEnvs: async function (t) { return p.delete({ url: "/api/envs", headers: { accept: "application/json", "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6", connection: "keep-alive", "content-type": "application/json;charset=UTF-8", "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.63 Safari/537.36 Edg/102.0.1245.30" }, body: t }).then(e => 200 === e.body.code ? (o.debug("QINGLONG DELETE ENV IDS: " + t), !0) : (o.error("Error deleting environments variable from QingLong Panel.\n" + JSON.stringify(e)), !1)).catch(e => { o.error("Error deleting environments variable from QingLong Panel.\n" + (e.message || e)) }) }, disableEnvs: async function (t) { let r = !1; return await p.put({ url: "/api/envs/disable", headers: { accept: "application/json", "accept-Language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6", connection: "keep-alive", "content-type": "application/json;charset=UTF-8", "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.63 Safari/537.36 Edg/102.0.1245.30" }, body: t }).then(e => { 200 === e.body.code ? (o.debug("QINGLONG DISABLED ENV IDS: " + t), r = !0) : o.error("Error disabling environments variable from QingLong Panel.\n" + JSON.stringify(e)) }).catch(e => { o.error("Error disabling environments variable from QingLong Panel.\n" + (e.message || e)) }), r }, enableEnvs: async function (t) { let r = !1; return await p.put({ url: "/api/envs/enable", headers: { accept: "application/json", "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6", connection: "keep-alive", "content-type": "application/json;charset=UTF-8", "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.63 Safari/537.36 Edg/102.0.1245.30" }, body: t }).then(e => { 200 === e.body.code ? (o.debug("QINGLONG ENABLED ENV IDS: " + t), r = !0) : o.error("Error enabling environments variable from Qilong panel.\n" + JSON.stringify(e)) }).catch(e => { o.error("Error enabling environments variable from Qilong panel.\n" + (e.message || e)) }), r }, addScript: async function (e, t = "", r = "") { let n = !1; return await p.post({ url: "/api/scripts", headers: { "content-type": "application/json" }, body: { filename: e, path: t, content: r } }).then(e => { 200 === e.body.code ? n = !0 : o.error("Error reading data from QingLong Panel.\n" + JSON.stringify(e)) }).catch(e => { o.error("Error reading data from QingLong Panel.\n" + (e.message || e)) }), n }, getScript: f, editScript: h, delScript: async function (e, t = "") { let r = !1; return await p.delete({ url: "/api/scripts", headers: { "content-type": "application/json" }, body: { filename: e, path: t } }).then(e => { 200 === e.body.code ? r = !0 : o.error("Error reading data from QingLong Panel.\n" + JSON.stringify(e)) }).catch(e => { o.error("Error reading data from QingLong Panel.\n" + (e.message || e)) }), r }, write: async function (e, t, r = "") { var n = await f(d, ""), o = a.convertToObject(n), e = a.write(e, t, r, o), n = JSON.stringify(o, null, 4); return await h(d, "", n) && e }, read: async function (e, t, r = "", n = !1) { var o = await f(d, ""), o = a.convertToObject(o); return a.read(e, t, r, n, o) }, del: async function (e, t = "") { var r = await f(d, ""), n = a.convertToObject(r), e = a.del(e, t, n), r = JSON.stringify(n, null, 4), t = await h(d, "", r); return e && t }, update: async function (e, t, r, n = a.defaultValueComparator) { var o = await f(d, ""), i = a.convertToObject(o), e = a.update(e, t, r, n, i); let s = !1; return !0 === e && (o = JSON.stringify(i, null, 4), s = await h(d, "", o)), e && s }, batchWrite: async function (...e) { var t, r = await f(d, ""), n = a.convertToObject(r); for (t of e) a.write(t[0], t[1], void 0 !== t[2] ? t[2] : "", n); return r = JSON.stringify(n, null, 4), h(d, "", r) }, batchRead: async function (...e) { var t, r = await f(d, ""), n = a.convertToObject(r), o = []; for (t of e) { var i = a.read(t[0], t[1], void 0 !== t[2] ? t[2] : "", "boolean" == typeof t[3] && t[3], n); o.push(i) } return o }, batchUpdate: async function (...e) { var t, r = await f(d, ""), n = a.convertToObject(r); for (t of e) a.update(t[0], t[1], void 0 !== t[2] ? t[2] : "", void 0 !== t[3] ? t.comparator : a.defaultValueComparator, n); return r = JSON.stringify(n, null, 4), h(d, "", r) }, batchDel: async function (...e) { var t, r = await f(d, ""), n = a.convertToObject(r); for (t of e) a.del(t[0], void 0 !== t[1] ? t[1] : "", n); return r = JSON.stringify(n, null, 4), h(d, "", r) }, allSessions: async function (e) { var t = await f(d, ""), t = a.convertToObject(t); return a.allSessions(e, t) }, allSessionNames: async function (e) { var t = await f(d, ""), t = a.convertToObject(t); return a.allSessionNames(e, t) } } }
  1350. //---SyncByPyScript---MagicJS3-end