forked from chavyleung/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
184877d
commit 30c6cb5
Showing
3 changed files
with
408 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
# 苏宁易购 | ||
|
||
> 代码已同时兼容 Surge & QuanX, 使用同一份签到脚本即可 | ||
> 2020.3.15 目前仅在 QuanX 上测试通过 (但不知 Cookie 能撑多久), Surge 应该是签不上的 (经反馈, Surge 作者会在下一个 TF 版本解决这个问题) | ||
## 配置 (Surge) | ||
|
||
```properties | ||
[MITM] | ||
hostname = passport.suning.com, luckman.suning.com, sign.suning.com | ||
|
||
[Script] | ||
# 注意有3条获取 Cookie 脚本 | ||
http-request ^https:\/\/passport.suning.com\/ids\/login$ script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/suning/suning.cookie.js, requires-body=true | ||
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 | ||
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 | ||
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/suning/suning.js | ||
``` | ||
|
||
## 配置 (QuanX) | ||
|
||
```properties | ||
[MITM] | ||
hostname = passport.suning.com, luckman.suning.com, sign.suning.com | ||
|
||
[rewrite_local] | ||
# 注意有3条获取 Cookie 脚本 | ||
^https:\/\/passport.suning.com\/ids\/login$ url script-request-body suning.cookie.js | ||
^https:\/\/luckman.suning.com\/luck-web\/sign\/api\/clock_sign.do url script-request-header suning.cookie.js | ||
^https:\/\/sign.suning.com\/sign-web\/m\/promotion\/sign\/doSign.do url script-request-header suning.cookie.js | ||
|
||
[task_local] | ||
1 0 * * * suning.js | ||
``` | ||
|
||
## 说明 | ||
|
||
1. 先把`passport.suning.com, luckman.suning.com, sign.suning.com`加到`[MITM]` | ||
2. 再配置重写规则: | ||
- Surge: 把两条远程脚本放到`[Script]` | ||
- QuanX: 把`suning.cookie.js`和`suning.js`传到`On My iPhone - Quantumult X - Scripts` (传到 iCloud 相同目录也可, 注意要打开 quanx 的 iCloud 开关) | ||
3. 获取 Cookie: | ||
- 打开 APP, 系统提示: `获取Cookie: 成功 (登录链接)` | ||
- 进入 `主页` > `签到有礼`, 系统提示: `获取Cookie: 成功 (每日签到)` | ||
- 进入 `主页` > `领取红包`, 系统提示: `获取Cookie: 成功 (每日红包)` | ||
4. 把获取 Cookie 的脚本 | ||
|
||
> 第 1 条脚本是用来获取 cookie 的, 用浏览器访问一次获取 cookie 成功后就可以删掉或注释掉了, 但请确保在`登录成功`后再获取 cookie. | ||
> 第 2 条脚本是签到脚本, 每天`00:00:10`执行一次. | ||
## 常见问题 | ||
|
||
1. 无法写入 Cookie | ||
|
||
- 检查 Surge 系统通知权限放开了没 | ||
- 如果你用的是 Safari, 请尝试在浏览地址栏`手动输入网址`(不要用复制粘贴) | ||
|
||
2. 写入 Cookie 成功, 但签到不成功 | ||
|
||
- 看看是不是在登录前就写入 Cookie 了 | ||
- 如果是,请确保在登录成功后,再尝试写入 Cookie | ||
|
||
3. 为什么有时成功有时失败 | ||
|
||
- 很正常,网络问题,哪怕你是手工签到也可能失败(凌晨签到容易拥堵就容易失败) | ||
- 暂时不考虑代码级的重试机制,但咱有配置级的(暴力美学): | ||
|
||
- `Surge`配置: | ||
|
||
```properties | ||
# 没有什么是一顿饭解决不了的: | ||
cron "10 0 0 * * *" script-path=xxx.js # 每天00:00:10执行一次 | ||
# 如果有,那就两顿: | ||
cron "20 0 0 * * *" script-path=xxx.js # 每天00:00:20执行一次 | ||
# 实在不行,三顿也能接受: | ||
cron "30 0 0 * * *" script-path=xxx.js # 每天00:00:30执行一次 | ||
|
||
# 再粗暴点,直接: | ||
cron "* */60 * * * *" script-path=xxx.js # 每60分执行一次 | ||
``` | ||
|
||
- `QuanX`配置: | ||
|
||
```properties | ||
[task_local] | ||
1 0 * * * xxx.js # 每天00:01执行一次 | ||
2 0 * * * xxx.js # 每天00:02执行一次 | ||
3 0 * * * xxx.js # 每天00:03执行一次 | ||
|
||
*/60 * * * * xxx.js # 每60分执行一次 | ||
``` | ||
|
||
## 感谢 | ||
|
||
[@NobyDa](https://github.com/NobyDa) | ||
|
||
[@lhie1](https://github.com/lhie1) | ||
|
||
[@ConnersHua](https://github.com/ConnersHua) | ||
|
||
[@Liquor030](https://github.com/Liquor030) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
const chavy = init() | ||
const cookieName = '苏宁易购' | ||
const KEY_loginurl = 'chavy_login_url_suning' | ||
const KEY_loginbody = 'chavy_login_body_suning' | ||
const KEY_loginheader = 'chavy_login_header_suning' | ||
const KEY_signurl = 'chavy_sign_url_suning' | ||
const KEY_signheader = 'chavy_sign_header_suning' | ||
const KEY_signweburl = 'chavy_signweb_url_suning' | ||
const KEY_signwebheader = 'chavy_signweb_header_suning' | ||
|
||
if ($request.url.match(/\/ids\/login/)) { | ||
const VAL_loginurl = $request.url | ||
const VAL_loginbody = $request.body | ||
const VAL_loginheader = JSON.stringify($request.headers) | ||
if (VAL_loginurl) chavy.setdata(VAL_loginurl, KEY_loginurl) | ||
if (VAL_loginbody) chavy.setdata(VAL_loginbody, KEY_loginbody) | ||
if (VAL_loginheader) chavy.setdata(VAL_loginheader, KEY_loginheader) | ||
chavy.msg(`${cookieName}`, '获取Cookie: 成功 (登录链接)', '') | ||
chavy.log(`❕ ${cookieName} 获取Cookie: 成功, VAL_loginurl: ${VAL_loginurl}`) | ||
chavy.log(`❕ ${cookieName} 获取Cookie: 成功, VAL_loginbody: ${VAL_loginbody}`) | ||
chavy.log(`❕ ${cookieName} 获取Cookie: 成功, VAL_loginheader: ${VAL_loginheader}`) | ||
} else if ($request.url.match(/\/sign\/doSign.do/)) { | ||
const VAL_signurl = $request.url | ||
const VAL_signheader = JSON.stringify($request.headers) | ||
if (VAL_signurl) chavy.setdata(VAL_signurl, KEY_signurl) | ||
if (VAL_signheader) chavy.setdata(VAL_signheader, KEY_signheader) | ||
chavy.msg(`${cookieName}`, '获取Cookie: 成功 (每日签到)', '') | ||
chavy.log(`❕ ${cookieName} 获取Cookie: 成功, VAL_signurl: ${VAL_signurl}`) | ||
chavy.log(`❕ ${cookieName} 获取Cookie: 成功, VAL_signheader: ${VAL_signheader}`) | ||
} else if ($request.url.match(/\/api\/clock_sign.do/)) { | ||
const VAL_signweburl = $request.url | ||
const VAL_signwebheader = JSON.stringify($request.headers) | ||
if (VAL_signweburl) chavy.setdata(VAL_signweburl, KEY_signweburl) | ||
if (VAL_signwebheader) chavy.setdata(VAL_signwebheader, KEY_signwebheader) | ||
chavy.msg(`${cookieName}`, '获取Cookie: 成功 (每日红包)', '') | ||
chavy.log(`❕ ${cookieName} 获取Cookie: 成功, VAL_signweburl: ${VAL_signweburl}`) | ||
chavy.log(`❕ ${cookieName} 获取Cookie: 成功, VAL_signwebheader: ${VAL_signwebheader}`) | ||
} | ||
|
||
function init() { | ||
isSurge = () => { | ||
return undefined === this.$httpClient ? false : true | ||
} | ||
isQuanX = () => { | ||
return undefined === this.$task ? false : true | ||
} | ||
getdata = (key) => { | ||
if (isSurge()) return $persistentStore.read(key) | ||
if (isQuanX()) return $prefs.valueForKey(key) | ||
} | ||
setdata = (key, val) => { | ||
if (isSurge()) return $persistentStore.write(key, val) | ||
if (isQuanX()) return $prefs.setValueForKey(key, val) | ||
} | ||
msg = (title, subtitle, body) => { | ||
if (isSurge()) $notification.post(title, subtitle, body) | ||
if (isQuanX()) $notify(title, subtitle, body) | ||
} | ||
log = (message) => console.log(message) | ||
get = (url, cb) => { | ||
if (isSurge()) { | ||
$httpClient.get(url, cb) | ||
} | ||
if (isQuanX()) { | ||
url.method = 'GET' | ||
$task.fetch(url).then((resp) => cb(null, {}, resp.body)) | ||
} | ||
} | ||
post = (url, cb) => { | ||
if (isSurge()) { | ||
$httpClient.post(url, cb) | ||
} | ||
if (isQuanX()) { | ||
url.method = 'POST' | ||
$task.fetch(url).then((resp) => cb(null, {}, resp.body)) | ||
} | ||
} | ||
done = (value = {}) => { | ||
$done(value) | ||
} | ||
return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done } | ||
} | ||
chavy.done() |
Oops, something went wrong.