Skip to content

Commit 30c6cb5

Browse files
committed
添加[苏宁易购]签到: 测试版, 目前仅支持QuanX商店版和TF版
1 parent 184877d commit 30c6cb5

3 files changed

Lines changed: 408 additions & 0 deletions

File tree

‎suning/README.md‎

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# 苏宁易购
2+
3+
> 代码已同时兼容 Surge & QuanX, 使用同一份签到脚本即可
4+
5+
> 2020.3.15 目前仅在 QuanX 上测试通过 (但不知 Cookie 能撑多久), Surge 应该是签不上的 (经反馈, Surge 作者会在下一个 TF 版本解决这个问题)
6+
7+
## 配置 (Surge)
8+
9+
```properties
10+
[MITM]
11+
hostname = passport.suning.com, luckman.suning.com, sign.suning.com
12+
13+
[Script]
14+
# 注意有3条获取 Cookie 脚本
15+
http-request ^https:\/\/passport.suning.com\/ids\/login$ script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/suning/suning.cookie.js, requires-body=true
16+
http-request ^https:\/\/luckman.suning.com\/luck-web\/sign\/api\/clock_sign.do script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/suning/suning.cookie.js
17+
http-request ^https:\/\/sign.suning.com\/sign-web\/m\/promotion\/sign\/doSign.do script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/suning/suning.cookie.js
18+
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/suning/suning.js
19+
```
20+
21+
## 配置 (QuanX)
22+
23+
```properties
24+
[MITM]
25+
hostname = passport.suning.com, luckman.suning.com, sign.suning.com
26+
27+
[rewrite_local]
28+
# 注意有3条获取 Cookie 脚本
29+
^https:\/\/passport.suning.com\/ids\/login$ url script-request-body suning.cookie.js
30+
^https:\/\/luckman.suning.com\/luck-web\/sign\/api\/clock_sign.do url script-request-header suning.cookie.js
31+
^https:\/\/sign.suning.com\/sign-web\/m\/promotion\/sign\/doSign.do url script-request-header suning.cookie.js
32+
33+
[task_local]
34+
1 0 * * * suning.js
35+
```
36+
37+
## 说明
38+
39+
1. 先把`passport.suning.com, luckman.suning.com, sign.suning.com`加到`[MITM]`
40+
2. 再配置重写规则:
41+
- Surge: 把两条远程脚本放到`[Script]`
42+
- QuanX: 把`suning.cookie.js`和`suning.js`传到`On My iPhone - Quantumult X - Scripts` (传到 iCloud 相同目录也可, 注意要打开 quanx 的 iCloud 开关)
43+
3. 获取 Cookie:
44+
- 打开 APP, 系统提示: `获取Cookie: 成功 (登录链接)`
45+
- 进入 `主页` > `签到有礼`, 系统提示: `获取Cookie: 成功 (每日签到)`
46+
- 进入 `主页` > `领取红包`, 系统提示: `获取Cookie: 成功 (每日红包)`
47+
4. 把获取 Cookie 的脚本
48+
49+
> 第 1 条脚本是用来获取 cookie 的, 用浏览器访问一次获取 cookie 成功后就可以删掉或注释掉了, 但请确保在`登录成功`后再获取 cookie.
50+
51+
> 第 2 条脚本是签到脚本, 每天`00:00:10`执行一次.
52+
53+
## 常见问题
54+
55+
1. 无法写入 Cookie
56+
57+
- 检查 Surge 系统通知权限放开了没
58+
- 如果你用的是 Safari, 请尝试在浏览地址栏`手动输入网址`(不要用复制粘贴)
59+
60+
2. 写入 Cookie 成功, 但签到不成功
61+
62+
- 看看是不是在登录前就写入 Cookie 了
63+
- 如果是,请确保在登录成功后,再尝试写入 Cookie
64+
65+
3. 为什么有时成功有时失败
66+
67+
- 很正常,网络问题,哪怕你是手工签到也可能失败(凌晨签到容易拥堵就容易失败)
68+
- 暂时不考虑代码级的重试机制,但咱有配置级的(暴力美学):
69+
70+
- `Surge`配置:
71+
72+
```properties
73+
# 没有什么是一顿饭解决不了的:
74+
cron "10 0 0 * * *" script-path=xxx.js # 每天00:00:10执行一次
75+
# 如果有,那就两顿:
76+
cron "20 0 0 * * *" script-path=xxx.js # 每天00:00:20执行一次
77+
# 实在不行,三顿也能接受:
78+
cron "30 0 0 * * *" script-path=xxx.js # 每天00:00:30执行一次
79+
80+
# 再粗暴点,直接:
81+
cron "* */60 * * * *" script-path=xxx.js # 每60分执行一次
82+
```
83+
84+
- `QuanX`配置:
85+
86+
```properties
87+
[task_local]
88+
1 0 * * * xxx.js # 每天00:01执行一次
89+
2 0 * * * xxx.js # 每天00:02执行一次
90+
3 0 * * * xxx.js # 每天00:03执行一次
91+
92+
*/60 * * * * xxx.js # 每60分执行一次
93+
```
94+
95+
## 感谢
96+
97+
[@NobyDa](https://github.com/NobyDa)
98+
99+
[@lhie1](https://github.com/lhie1)
100+
101+
[@ConnersHua](https://github.com/ConnersHua)
102+
103+
[@Liquor030](https://github.com/Liquor030)

‎suning/suning.cookie.js‎

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
const chavy = init()
2+
const cookieName = '苏宁易购'
3+
const KEY_loginurl = 'chavy_login_url_suning'
4+
const KEY_loginbody = 'chavy_login_body_suning'
5+
const KEY_loginheader = 'chavy_login_header_suning'
6+
const KEY_signurl = 'chavy_sign_url_suning'
7+
const KEY_signheader = 'chavy_sign_header_suning'
8+
const KEY_signweburl = 'chavy_signweb_url_suning'
9+
const KEY_signwebheader = 'chavy_signweb_header_suning'
10+
11+
if ($request.url.match(/\/ids\/login/)) {
12+
const VAL_loginurl = $request.url
13+
const VAL_loginbody = $request.body
14+
const VAL_loginheader = JSON.stringify($request.headers)
15+
if (VAL_loginurl) chavy.setdata(VAL_loginurl, KEY_loginurl)
16+
if (VAL_loginbody) chavy.setdata(VAL_loginbody, KEY_loginbody)
17+
if (VAL_loginheader) chavy.setdata(VAL_loginheader, KEY_loginheader)
18+
chavy.msg(`${cookieName}`, '获取Cookie: 成功 (登录链接)', '')
19+
chavy.log(`❕ ${cookieName} 获取Cookie: 成功, VAL_loginurl: ${VAL_loginurl}`)
20+
chavy.log(`❕ ${cookieName} 获取Cookie: 成功, VAL_loginbody: ${VAL_loginbody}`)
21+
chavy.log(`❕ ${cookieName} 获取Cookie: 成功, VAL_loginheader: ${VAL_loginheader}`)
22+
} else if ($request.url.match(/\/sign\/doSign.do/)) {
23+
const VAL_signurl = $request.url
24+
const VAL_signheader = JSON.stringify($request.headers)
25+
if (VAL_signurl) chavy.setdata(VAL_signurl, KEY_signurl)
26+
if (VAL_signheader) chavy.setdata(VAL_signheader, KEY_signheader)
27+
chavy.msg(`${cookieName}`, '获取Cookie: 成功 (每日签到)', '')
28+
chavy.log(`❕ ${cookieName} 获取Cookie: 成功, VAL_signurl: ${VAL_signurl}`)
29+
chavy.log(`❕ ${cookieName} 获取Cookie: 成功, VAL_signheader: ${VAL_signheader}`)
30+
} else if ($request.url.match(/\/api\/clock_sign.do/)) {
31+
const VAL_signweburl = $request.url
32+
const VAL_signwebheader = JSON.stringify($request.headers)
33+
if (VAL_signweburl) chavy.setdata(VAL_signweburl, KEY_signweburl)
34+
if (VAL_signwebheader) chavy.setdata(VAL_signwebheader, KEY_signwebheader)
35+
chavy.msg(`${cookieName}`, '获取Cookie: 成功 (每日红包)', '')
36+
chavy.log(`❕ ${cookieName} 获取Cookie: 成功, VAL_signweburl: ${VAL_signweburl}`)
37+
chavy.log(`❕ ${cookieName} 获取Cookie: 成功, VAL_signwebheader: ${VAL_signwebheader}`)
38+
}
39+
40+
function init() {
41+
isSurge = () => {
42+
return undefined === this.$httpClient ? false : true
43+
}
44+
isQuanX = () => {
45+
return undefined === this.$task ? false : true
46+
}
47+
getdata = (key) => {
48+
if (isSurge()) return $persistentStore.read(key)
49+
if (isQuanX()) return $prefs.valueForKey(key)
50+
}
51+
setdata = (key, val) => {
52+
if (isSurge()) return $persistentStore.write(key, val)
53+
if (isQuanX()) return $prefs.setValueForKey(key, val)
54+
}
55+
msg = (title, subtitle, body) => {
56+
if (isSurge()) $notification.post(title, subtitle, body)
57+
if (isQuanX()) $notify(title, subtitle, body)
58+
}
59+
log = (message) => console.log(message)
60+
get = (url, cb) => {
61+
if (isSurge()) {
62+
$httpClient.get(url, cb)
63+
}
64+
if (isQuanX()) {
65+
url.method = 'GET'
66+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
67+
}
68+
}
69+
post = (url, cb) => {
70+
if (isSurge()) {
71+
$httpClient.post(url, cb)
72+
}
73+
if (isQuanX()) {
74+
url.method = 'POST'
75+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
76+
}
77+
}
78+
done = (value = {}) => {
79+
$done(value)
80+
}
81+
return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done }
82+
}
83+
chavy.done()

0 commit comments

Comments
 (0)