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

Function getTask

activity/jd_global_mh.js:182–225  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

180 })
181}
182async function getTask() {
183 return new Promise(resolve => {
184 $.get(taskUrl("myTask", {"activityCode": actCode}), async (err, resp, data) => {
185 try {
186 if (err) {
187 console.log(`${JSON.stringify(err)}`)
188 console.log(`${$.name} API请求失败,请检查网路重试`)
189 } else {
190 if (safeGet(data)) {
191 data = JSON.parse(data);
192 if (data['code'] === '0') {
193 const {timeLimitTask, commonTask} = data.result.data
194 let task = [...timeLimitTask, ...commonTask]
195 for (let vo of task) {
196 if (vo['taskName'] === '每日邀请好友') {
197 console.log(`您的好友助力码为 ${vo['jingCommand']['keyOpenapp'].match(/masterPin":"(.*)","/)[1]}`)
198 }
199 if (['70', '50', '30', '40'].includes(vo['taskType'])) {
200 if (vo['executedTimes'] === vo['totalTimes']) {
201 console.log(`${vo['taskName']}任务已完成`)
202 } else {
203 console.log(`去做${vo['taskName']}任务`)
204 for (let i = vo['executedTimes']; i < vo['totalTimes']; ++i) {
205 await doTask({
206 "taskId": vo['taskId'],
207 "itemId": vo['itemId'],
208 "viewSeconds": vo['viewSeconds'],
209 "activityCode": actCode
210 })
211 }
212 }
213 }
214 }
215 }
216 }
217 }
218 } catch (e) {
219 $.logErr(e, resp)
220 } finally {
221 resolve(data);
222 }
223 })
224 })
225}
226
227async function doTask(body) {
228 return new Promise(resolve => {

Callers 1

jdGlobalMhFunction · 0.70

Calls 6

taskUrlFunction · 0.70
safeGetFunction · 0.70
doTaskFunction · 0.70
getMethod · 0.45
logMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected