forked from angreman/WALL.E
-
Notifications
You must be signed in to change notification settings - Fork 0
/
m_jd_fav_shop_gift.js
136 lines (131 loc) · 4.9 KB
/
m_jd_fav_shop_gift.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
let mode = __dirname.includes('magic')
const {Env} = mode ? require('./magic') : require('./magic')
const $ = new Env('M收藏有礼');
$.favShopArgv = process.env.M_FAV_SHOP_ARGV
? process.env.M_FAV_SHOP_ARGV
: '';
if (mode) {
$.favShopArgv = '1000000307_1000000307'
}
let stop = false;
$.logic = async function () {
if (stop) {
return;
}
let argv = $?.favShopArgv?.split('_');
$.shopId = argv?.[0];
$.venderId = argv?.[1];
if (!$.shopId || !$.venderId) {
$.log(`无效的参数${$.favShopArgv}`)
stop = true;
return
}
await $.wait(100, 500);
let actInfo = await QueryShopActive();
if (actInfo?.iRet !== '0') {
$.putMsg(actInfo?.errMsg)
return
}
if (actInfo?.fan === 1) {
$.putMsg('已经收藏过啦');
await DelShopFav()
return
}
let bean = actInfo?.gift?.filter(o => o.jingBean?.sendCount > 0)?.[0];
if (!bean) {
$.putMsg('没有奖励')
//stop = true
return
}
$.activeId = bean.activeId || '';
$.giftId = bean.giftId || '';
$.beanCnt = bean?.jingBean?.sendCount || 0;
$.log($.activeId, $.giftId, $.beanCnt)
if (!$.activeId) {
$.putMsg('没找到活动信息')
stop = true
return
}
let addFav = await addfavgiftshop();
if (addFav.iRet === "0") {
$.putMsg('收藏成功')
}
let gift = await GiveShopGift();
$.log(JSON.stringify(gift))
if (gift.retCode === 0) {
$.putMsg(`${$.beanCnt}豆`)
} else if (gift.retCode === 201) {
$.putMsg(`已领取过`)
} else {
$.putMsg(`领取失败`)
//stop = true
return
}
await DelShopFav()
};
$.run({wait: [300, 1000],whitelist: ['1-5']})
.catch(reason => $.log(reason))
async function GiveShopGift() {
let url = `https://wq.jd.com/fav_snsgift/GiveShopGift?venderId=${$.venderId}&activeId=${$.activeId}&giftId=${$.giftId}&_=${$.timestamp()}&sceneval=2&g_login_type=1&callback=jsonpCBKQ&g_tk=1292830178&g_ty=ls`
let headers = {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "zh-CN,zh-Hans;q=0.9",
"Connection": "keep-alive",
"Cookie": $.cookie,
"Host": "wq.jd.com",
"Referer": `https://shop.m.jd.com/?shopId=${$.shopId}`,
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.0 Mobile/15E148 Safari/604.1"
}
let {status, data} = await $.request(url, headers);
await $.wait(100, 500)
return $.handler(data);
}
async function DelShopFav() {
let url = `https://wq.jd.com/fav/shop/DelShopFav?shopId=${$.shopId}&venderId=${$.venderId}&_=${$.timestamp()}&sceneval=2&g_login_type=1&callback=jsonpCBKM&g_tk=1292830178&g_ty=ls`
let headers = {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "zh-CN,zh-Hans;q=0.9",
"Connection": "keep-alive",
"Cookie": $.cookie,
"Host": "wq.jd.com",
"Referer": `https://shop.m.jd.com/?shopId=${$.shopId}`,
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.0 Mobile/15E148 Safari/604.1"
}
let {data} = await $.request(url, headers);
await $.wait(100, 500)
return $.handler(data);
}
async function addfavgiftshop() {
let url = `https://wq.jd.com/fav_snsgift/addfavgiftshop?venderId=${$.venderId}&shareToken=&_=${$.timestamp()}&sceneval=2&g_login_type=1&callback=jsonpCBKO&g_tk=1292830178&g_ty=ls`
let headers = {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "zh-CN,zh-Hans;q=0.9",
"Connection": "keep-alive",
"Cookie": $.cookie,
"Host": "wq.jd.com",
"Referer": `https://shop.m.jd.com/?shopId=${$.shopId}`,
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.0 Mobile/15E148 Safari/604.1"
}
let {status, data} = await $.request(url, headers);
await $.wait(100, 500)
return $.handler(data);
}
async function QueryShopActive() {
let headers = {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "zh-CN,zh-Hans;q=0.9",
"Connection": "keep-alive",
"Cookie": $.cookie,
"Host": "wq.jd.com",
"Referer": `https://shop.m.jd.com/?shopId=${$.shopId}`,
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.0 Mobile/15E148 Safari/604.1"
}
let url = `https://wq.jd.com/fav_snsgift/QueryShopActive?venderId=${$.venderId}&_=${$.timestamp()}&sceneval=2&g_login_type=1&callback=jsonpCBKC&g_tk=1292830178&g_ty=ls`
let {status, data} = await $.request(url, headers);
await $.wait(100, 500)
return $.handler(data);
}