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

Function TotalBean

tools/jd_cfd_SlotMachine.js:142–182  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

140}
141
142function TotalBean() {
143 return new Promise(async resolve => {
144 const options = {
145 url: "https://me-api.jd.com/user_new/info/GetJDUserInfoUnion",
146 headers: {
147 Host: "me-api.jd.com",
148 Accept: "*/*",
149 Connection: "keep-alive",
150 Cookie: cookie,
151 "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require(`${path}/USER_AGENTS`).USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "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"),
152 "Accept-Language": "zh-cn",
153 "Referer": "https://home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&",
154 "Accept-Encoding": "gzip, deflate, br"
155 }
156 }
157 $.get(options, (err, resp, data) => {
158 try {
159 if (err) {
160 $.logErr(err)
161 } else {
162 if (data) {
163 data = JSON.parse(data);
164 if (data['retcode'] === "1001") {
165 $.isLogin = false; //cookie过期
166 return;
167 }
168 if (data['retcode'] === "0" && data.data && data.data.hasOwnProperty("userInfo")) {
169 $.nickName = data.data.userInfo.baseInfo.nickname;
170 }
171 } else {
172 $.log('京东服务器返回空数据');
173 }
174 }
175 } catch (e) {
176 $.logErr(e)
177 } finally {
178 resolve();
179 }
180 })
181 })
182}
183
184function writeFile(text, filename = 'a.json') {
185 fs.writeFileSync(filename, text, 'utf-8')

Callers 1

Calls 5

isNodeMethod · 0.45
getdataMethod · 0.45
getMethod · 0.45
logErrMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected