MCPcopy Index your code
hub / github.com/NobyDa/Script / JDMagicCube

Function JDMagicCube

JD-DailyBonus/JD_DailyBonus.js:1044–1079  ·  view source on GitHub ↗
(s, sign)

Source from the content-addressed store, hash-verified

1042}
1043
1044function JDMagicCube(s, sign) {
1045 merge.JDCube = {};
1046 return new Promise((resolve, reject) => {
1047 if (disable("JDCube")) return reject()
1048 const JDUrl = {
1049 url: `https://api.m.jd.com/client.action?functionId=getNewsInteractionInfo&appid=smfe${sign?`&body=${encodeURIComponent(`{"sign":${sign}}`)}`:``}`,
1050 headers: {
1051 Cookie: KEY,
1052 }
1053 };
1054 $nobyda.get(JDUrl, async (error, response, data) => {
1055 try {
1056 if (error) throw new Error(error)
1057 const Details = LogDetails ? "response:\n" + data : '';
1058 console.log(`\n京东魔方-尝试查询活动(${sign}) ${Details}`)
1059 if (data.match(/\"interactionId\":\d+/)) {
1060 resolve({
1061 id: data.match(/\"interactionId\":(\d+)/)[1],
1062 sign: sign || null
1063 })
1064 } else if (data.match(/配置异常/) && sign) {
1065 await JDMagicCube(s, sign == 2 ? 1 : null)
1066 reject()
1067 } else {
1068 resolve(null)
1069 }
1070 } catch (eor) {
1071 $nobyda.AnError("京东魔方-查询", "JDCube", eor, response, data)
1072 reject()
1073 }
1074 })
1075 if (out) setTimeout(reject, out + s)
1076 }).then(data => {
1077 return JDMagicCubeSign(s, data)
1078 }, () => {});
1079}
1080
1081function JDMagicCubeSign(s, id) {
1082 return new Promise(resolve => {

Callers 1

allFunction · 0.85

Calls 4

disableFunction · 0.85
JDMagicCubeSignFunction · 0.85
getMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected