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

Function getJdPet

jd_get_share_code.js:231–299  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

229}
230
231function getJdPet(){
232 const JDPet_API_HOST = "https://api.m.jd.com/client.action";
233
234 function jdPet_Url(function_id, body = {}) {
235 body["version"] = 2;
236 body["channel"] = "app";
237 return {
238 url: `${JDPet_API_HOST}?functionId=${function_id}`,
239 body: `body=${escape(
240 JSON.stringify(body)
241 )}&appid=wh5&loginWQBiz=pet-town&clientVersion=9.0.4`,
242 headers: {
243 Cookie: cookie,
244 "User-Agent": $.isNode()
245 ? process.env.JD_USER_AGENT
246 ? process.env.JD_USER_AGENT
247 : "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"
248 : $.getdata("JDUA")
249 ? $.getdata("JDUA")
250 : "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",
251 Host: "api.m.jd.com",
252 "Content-Type": "application/x-www-form-urlencoded",
253 },
254 };
255 }
256 return new Promise(resolve => {
257 $.post(jdPet_Url("initPetTown"), async (err, resp, data) => {
258 try {
259 if (err) {
260 console.log("东东萌宠: API查询请求失败 ‼️‼️");
261 console.log(JSON.stringify(err));
262 $.logErr(err);
263 } else {
264 data = JSON.parse(data);
265
266 const initPetTownRes = data;
267
268 message = `【京东账号${$.index}】${$.nickName}`;
269 if (
270 initPetTownRes.code === "0" &&
271 initPetTownRes.resultCode === "0" &&
272 initPetTownRes.message === "success"
273 ) {
274 $.petInfo = initPetTownRes.result;
275 if ($.petInfo.userStatus === 0) {
276 /*console.log(
277 `【提示】京东账号${$.index}${$.nickName}萌宠活动未开启请手动去京东APP开启活动入口:我的->游戏与互动->查看更多开启`
278 );*/
279 return;
280 }
281
282 console.log(
283 `【京东账号${$.index}(${$.UserName})京东萌宠】${$.petInfo.shareCode}`
284 );
285
286 } else if (initPetTownRes.code === "0") {
287 console.log(`初始化萌宠失败: ${initPetTownRes.message}`);
288 } else {

Callers 1

getShareCodeFunction · 0.85

Calls 4

jdPet_UrlFunction · 0.85
postMethod · 0.45
logMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected