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

Function initForFarm

jd_get_share_code.js:425–472  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

423}
424async function getJDFruit() {
425 async function initForFarm() {
426 return new Promise((resolve) => {
427 const option = {
428 url: `${JD_API_HOST}?functionId=initForFarm`,
429 body: `body=${escape(
430 JSON.stringify({version: 4})
431 )}&appid=wh5&clientVersion=9.1.0`,
432 headers: {
433 accept: "*/*",
434 "accept-encoding": "gzip, deflate, br",
435 "accept-language": "zh-CN,zh;q=0.9",
436 "cache-control": "no-cache",
437 cookie: cookie,
438 origin: "https://home.m.jd.com",
439 pragma: "no-cache",
440 referer: "https://home.m.jd.com/myJd/newhome.action",
441 "sec-fetch-dest": "empty",
442 "sec-fetch-mode": "cors",
443 "sec-fetch-site": "same-site",
444 "User-Agent": $.isNode()
445 ? process.env.JD_USER_AGENT
446 ? process.env.JD_USER_AGENT
447 : "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"
448 : $.getdata("JDUA")
449 ? $.getdata("JDUA")
450 : "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",
451 "Content-Type": "application/x-www-form-urlencoded",
452 },
453 };
454 $.post(option, (err, resp, data) => {
455 try {
456 if (err) {
457 console.log("东东农场: API查询请求失败 ‼️‼️");
458 console.log(JSON.stringify(err));
459 $.logErr(err);
460 } else {
461 if (safeGet(data)) {
462 $.farmInfo = JSON.parse(data);
463 }
464 }
465 } catch (e) {
466 $.logErr(e, resp);
467 } finally {
468 resolve();
469 }
470 });
471 });
472 }
473
474 async function jdFruit() {
475 await initForFarm();

Callers 1

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