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

Function JDMagicCube

JD_DailyBonus.js:1036–1071  ·  view source on GitHub ↗
(s, sign)

Source from the content-addressed store, hash-verified

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