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

Function initForFarm

jd_fruit.js:1168–1208  ·  view source on GitHub ↗

* 初始化农场, 可获取果树及用户信息API

()

Source from the content-addressed store, hash-verified

1166 * 初始化农场, 可获取果树及用户信息API
1167 */
1168async function initForFarm() {
1169 return new Promise(resolve => {
1170 const option = {
1171 url: `${JD_API_HOST}?functionId=initForFarm`,
1172 body: `body=${escape(JSON.stringify({"version":4}))}&appid=wh5&clientVersion=9.1.0`,
1173 headers: {
1174 "accept": "*/*",
1175 "accept-encoding": "gzip, deflate, br",
1176 "accept-language": "zh-CN,zh;q=0.9",
1177 "cache-control": "no-cache",
1178 "cookie": cookie,
1179 "origin": "https://home.m.jd.com",
1180 "pragma": "no-cache",
1181 "referer": "https://home.m.jd.com/myJd/newhome.action",
1182 "sec-fetch-dest": "empty",
1183 "sec-fetch-mode": "cors",
1184 "sec-fetch-site": "same-site",
1185 "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"),
1186 "Content-Type": "application/x-www-form-urlencoded"
1187 },
1188 timeout: 10000,
1189 };
1190 $.post(option, (err, resp, data) => {
1191 try {
1192 if (err) {
1193 console.log('\n东东农场: API查询请求失败 ‼️‼️');
1194 console.log(JSON.stringify(err));
1195 $.logErr(err);
1196 } else {
1197 if (safeGet(data)) {
1198 $.farmInfo = JSON.parse(data)
1199 }
1200 }
1201 } catch (e) {
1202 $.logErr(e, resp)
1203 } finally {
1204 resolve();
1205 }
1206 })
1207 })
1208}
1209
1210// 初始化任务列表API
1211async function taskInitForFarm() {

Callers 3

jdFruitFunction · 0.70
predictionFruitFunction · 0.70
doTenWaterAgainFunction · 0.70

Calls 6

safeGetFunction · 0.70
isNodeMethod · 0.45
getdataMethod · 0.45
postMethod · 0.45
logMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected