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

Function getTask

activity/jd_global.js:170–220  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers 1

jdGlobalFunction · 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