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

Function JDUserSignPre2

JD-DailyBonus/JD_DailyBonus.js:725–780  ·  view source on GitHub ↗
(s, key, title, acData)

Source from the content-addressed store, hash-verified

723}
724
725function JDUserSignPre2(s, key, title, acData) {
726 return new Promise((resolve, reject) => {
727 if (disable(key, title, 1)) return reject()
728 const JDUrl = {
729 url: `https://pro.m.jd.com/mall/active/${acData}/index.html`,
730 headers: {
731 Cookie: KEY,
732 }
733 };
734 $nobyda.get(JDUrl, async function(error, response, data) {
735 try {
736 if (error) {
737 throw new Error(error)
738 } else {
739 const act = data.match(/\"params\":\"\{\\\"enActK.+?\\\"\}\"/)
740 const turnTable = data.match(/\"turnTableId\":\"(\d+)\"/)
741 const page = data.match(/\"paginationFlrs\":\"(\[\[.+?\]\])\"/)
742 if (act) { // 含有签到活动数据
743 return resolve(act)
744 } else if (turnTable) { // 无签到数据, 但含有关注店铺签到
745 const boxds = $nobyda.read("JD_Follow_disable") === "false" ? false : true
746 if (boxds) {
747 console.log(`\n${title}关注店铺`)
748 return resolve(parseInt(turnTable[1]))
749 } else {
750 merge[key].notify = `${title}: 失败, 需要关注店铺 ⚠️`
751 merge[key].fail = 1
752 }
753 } else if (page) { // 无签到数据, 尝试带参查询
754 const boxds = $nobyda.read("JD_Retry_disable") === "false" ? false : true
755 if (boxds) {
756 console.log(`\n${title}二次查询`)
757 return resolve(page[1])
758 } else {
759 merge[key].notify = `${title}: 失败, 请尝试开启增强 ⚠️`
760 merge[key].fail = 1
761 }
762 } else {
763 merge[key].notify = `${title}: 失败, ${!data ? `需要手动执行` : `不含活动数据`} ⚠️`
764 merge[key].fail = 1
765 }
766 }
767 reject()
768 } catch (eor) {
769 $nobyda.AnError(title, key, eor, response, data)
770 reject()
771 }
772 })
773 if (out) setTimeout(reject, out + s)
774 }).then(data => {
775 disable(key, title, 2)
776 if (typeof(data) == "object") return JDUserSign1(s, key, title, encodeURIComponent(`{${data}}`));
777 if (typeof(data) == "number") return JDUserSign2(s, key, title, data)
778 if (typeof(data) == "string") return JDUserSignPre1(s, key, title, acData, data)
779 }, () => disable(key, title, 2))
780}
781
782function JDUserSign1(s, key, title, body) {

Callers 1

JDUserSignPreFunction · 0.85

Calls 7

disableFunction · 0.85
JDUserSign1Function · 0.85
JDUserSign2Function · 0.85
JDUserSignPre1Function · 0.85
getMethod · 0.45
readMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected