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

Function interact_template_getHomeData

jd_lotteryMachine.js:100–172  ·  view source on GitHub ↗
(timeout = 0)

Source from the content-addressed store, hash-verified

98 }
99}
100function interact_template_getHomeData(timeout = 0) {
101 return new Promise((resolve) => {
102 setTimeout( ()=>{
103 let url = {
104 url : `https://api.m.jd.com/client.action`,
105 headers : {
106 'Origin' : `https://h5.m.jd.com`,
107 'Cookie' : cookie,
108 'Connection' : `keep-alive`,
109 'Accept' : `application/json, text/plain, */*`,
110 'Referer' : `https://h5.m.jd.com/babelDiy/Zeus/2WBcKYkn8viyxv7MoKKgfzmu7Dss/index.html`,
111 'Host' : `api.m.jd.com`,
112 'Accept-Encoding' : `gzip, deflate, br`,
113 'Accept-Language' : `zh-cn`
114 },
115 body: `functionId=${homeDataFunPrefix}_getHomeData&body={"appId":"${$.appId}","taskToken":""}&client=wh5&clientVersion=1.0.0`
116 }
117
118 $.post(url, async (err, resp, data) => {
119 try {
120 let invitesFlag = false;
121 data = JSON.parse(data);
122 if (data['code'] === 0) {
123 if (data.data && data.data.bizCode === 0) {
124 for (let item of data.data.result.taskVos) {
125 if ([14, 6].includes(item.taskType)) {
126 console.log(`邀请码:${item.assistTaskDetailVo.taskToken}`)
127 console.log(`邀请好友助力:${item.times}/${item['maxTimes']}\n`);
128 if (item.assistTaskDetailVo.taskToken && item.taskId && item.times !== item['maxTimes']) {
129 $.invites.push({
130 taskToken: item.assistTaskDetailVo.taskToken,
131 taskId: item.taskId,
132 userName: $.UserName,
133 appId: $.appId,
134 index: $.appIndex,
135 max: false
136 })
137 }
138 invitesFlag = true;//该活动存在助力码
139 }
140 }
141 if (!invitesFlag) {
142 $.acHelpFlag = false;
143 }
144 } else {
145 console.log(`获取抽奖活动数据失败:${data.data.bizMsg}`);
146 $.invites.push({
147 taskToken: null,
148 taskId: null,
149 userName: $.UserName,
150 appId: $.appId,
151 index: $.appIndex
152 })
153 }
154 } else {
155 console.log(`获取抽奖活动数据异常:${JSON.stringify(data)}`)
156 $.invites.push({
157 taskToken: null,

Callers 1

helpFunction · 0.70

Calls 3

postMethod · 0.45
logMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected