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

Function getPlantBean

jd_get_share_code.js:345–423  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

343 await getTaskList()
344}
345async function getPlantBean() {
346 const JDplant_API_HOST = "https://api.m.jd.com/client.action";
347
348 async function plantBeanIndex() {
349 $.plantBeanIndexResult = await plant_request("plantBeanIndex"); //plantBeanIndexBody
350 }
351
352 function plant_request(function_id, body = {}) {
353 return new Promise(async (resolve) => {
354 $.post(plant_taskUrl(function_id, body), (err, resp, data) => {
355 try {
356 if (err) {
357 console.log("种豆得豆: API查询请求失败 ‼️‼️");
358 console.log(`function_id:${function_id}`);
359 $.logErr(err);
360 } else {
361 data = JSON.parse(data);
362 }
363 } catch (e) {
364 $.logErr(e, resp);
365 } finally {
366 resolve(data);
367 }
368 });
369 });
370 }
371
372 function plant_taskUrl(function_id, body) {
373 body["version"] = "9.0.0.1";
374 body["monitor_source"] = "plant_app_plant_index";
375 body["monitor_refer"] = "";
376 return {
377 url: JDplant_API_HOST,
378 body: `functionId=${function_id}&body=${escape(
379 JSON.stringify(body)
380 )}&appid=ld&client=apple&area=5_274_49707_49973&build=167283&clientVersion=9.1.0`,
381 headers: {
382 Cookie: cookie,
383 Host: "api.m.jd.com",
384 Accept: "*/*",
385 Connection: "keep-alive",
386 "User-Agent": $.isNode()
387 ? process.env.JD_USER_AGENT
388 ? process.env.JD_USER_AGENT
389 : "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"
390 : $.getdata("JDUA")
391 ? $.getdata("JDUA")
392 : "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",
393 "Accept-Language": "zh-Hans-CN;q=1,en-CN;q=0.9",
394 "Accept-Encoding": "gzip, deflate, br",
395 "Content-Type": "application/x-www-form-urlencoded",
396 },
397 };
398 }
399
400 function getParam(url, name) {
401 const reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
402 const r = url.match(reg);

Callers 1

getShareCodeFunction · 0.85

Calls 1

jdPlantBeanFunction · 0.70

Tested by

no test coverage detected