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

Function getToken

jd_joy_run.js:185–257  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

183//获取来客有礼Token
184let count = 0;
185async function getToken() {
186 const url = $request.url;
187 $.log(`${$.name}url\n${url}\n`)
188 if (isURL(url, /^https:\/\/draw\.jdfcloud\.com(\/mirror)?\/\/api\/user\/addUser\?code=/)) {
189 const body = JSON.parse($response.body);
190 const LKYLToken = body.data && body.data.token;
191 if (LKYLToken) {
192 $.log(`${$.name} token\n${LKYLToken}\n`);
193 $.msg($.name, '更新Token: 成功🎉', ``);
194 console.log(`\nToken,${LKYLToken}\n`)
195 $.http.post({
196 url: `http://share.turinglabs.net/api/v3/create/sharecode/`,
197 headers: { "Content-Type": "application/json" },
198 body: JSON.stringify({
199 "activity_name": "joy",
200 "share_code": LKYLToken,
201 }),
202 timeout: 30000
203 }).then((resp) => {
204 if (resp.statusCode === 200) {
205 try {
206 let { body } = resp;
207 console.log(`Token提交结果:${body}\n`)
208 body = JSON.parse(body);
209 console.log(`${body.message}`)
210 } catch (e) {
211 console.log(`提交Token异常:${e}`)
212 }
213 }
214 }).catch((e) => console.log(`catch 宠汪汪TOKEN提交异常:${e}`));
215 // count = $.getdata('countFlag') ? $.getdata('countFlag') * 1 : 0;
216 // count ++;
217 // console.log(`count: ${count}`)
218 // $.setdata(`${count}`, 'countFlag');
219 // if ($.getdata('countFlag') * 1 === 2) {
220 // count = 0;
221 // $.setdata(`${count}`, 'countFlag');
222 // $.msg($.name, '更新Token: 成功🎉', ``);
223 // console.log(`开始上传Token,${LKYLToken}\n`)
224 // await $.http.get({url: `http://jd.turinglabs.net/api/v2/jd/joy/create/${LKYLToken}/`}).then((resp) => {
225 // if (resp.statusCode === 200) {
226 // let { body } = resp;
227 // console.log(`Token提交结果:${body}\n`)
228 // body = JSON.parse(body);
229 // console.log(`${body.message}`)
230 // }
231 // });
232 // }
233 $.setdata(LKYLToken, 'jdJoyRunToken');
234 }
235 $.done({ body: JSON.stringify(body) })
236 } else if (isURL(url, /^https:\/\/draw\.jdfcloud\.com(\/mirror)?\/\/api\/user\/user\/detail\?openId=/)){
237 if ($request && $request.method !== 'OPTIONS') {
238 const LKYLToken = $request.headers['LKYLToken'];
239 //if ($.getdata('jdJoyRunToken')) {
240 //if ($.getdata('jdJoyRunToken') !== LKYLToken) {
241
242 //}

Callers 1

jd_joy_run.jsFile · 0.70

Calls 6

isURLFunction · 0.85
logMethod · 0.45
msgMethod · 0.45
postMethod · 0.45
setdataMethod · 0.45
doneMethod · 0.45

Tested by

no test coverage detected