MCPcopy Create free account
hub / github.com/Semporia/Scripts / openBox

Function openBox

jd_crazy_joy_coin.js:560–587  ·  view source on GitHub ↗
(eventType = 'LUCKY_BOX_DROP', boxId)

Source from the content-addressed store, hash-verified

558}
559
560function openBox(eventType = 'LUCKY_BOX_DROP', boxId) {
561 let body = { eventType, "eventRecordId": boxId}
562 return new Promise(async resolve => {
563 $.get(taskUrl('crazyJoy_event_getVideoAdvert', JSON.stringify(body)), async (err, resp, data) => {
564 try {
565 if (err) {
566 console.log(`${JSON.stringify(err)}`)
567 console.log(`${$.name} API请求失败,请检查网路重试`)
568 } else {
569 if (safeGet(data)) {
570 data = JSON.parse(data);
571 if (data['success']) {
572 $.log(`点击幸运盒子成功,剩余观看视频次数:${data.data.advertViewTimes}, ${data.data.advertViewTimes > 0 ? '等待32秒' : '跳出'}`)
573 if (data.data.advertViewTimes > 0) {
574 await $.wait(32000)
575 await rewardBox(eventType, boxId);
576 }
577 }
578 }
579 }
580 } catch (e) {
581 $.logErr(e, resp)
582 } finally {
583 resolve();
584 }
585 })
586 })
587}
588
589function rewardBox(eventType, boxId) {
590 let body = { eventType, "eventRecordId": boxId}

Callers 3

buyJoyFunction · 0.70
sellJoyFunction · 0.70
getCoinFunction · 0.70

Calls 7

rewardBoxFunction · 0.85
taskUrlFunction · 0.70
safeGetFunction · 0.70
getMethod · 0.45
logMethod · 0.45
waitMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected