Skip to content

Commit

Permalink
更新[苏宁易购]: 增加天天低价
Browse files Browse the repository at this point in the history
  • Loading branch information
chavyleung committed Mar 15, 2020
1 parent 379f274 commit 9e27741
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 9 deletions.
5 changes: 3 additions & 2 deletions QuantumultX_AppStore_Local_Cookie.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 本配置适用于: QuanX 商店版 v1.0.6-build194 及之前版本
# 如果你是TF版, 请使用: QuantumultX_Local_Cookie.conf

hostname = luckman.suning.com, passport.suning.com, sign.suning.com, m.ctrip.com, 110.43.90.61, zt.wps.cn, daojia.jd.com, app.nio.com, wxprdapplet.gac-nio.com, maicai.api.ddxq.mobi, group.baicizhan.com, api.everphoto.cn, promotion.waimai.meituan.com, wx.10086.cn, www.maomicd.com, m.client.10010.com, act.10010.com, api-takumi.mihoyo.com, gdws.nsenz.com, credits.bz.mgtv.com, *.csdn.net, wapside.189.cn, *.acfun.cn, apk.tw, *.bilibili.com, api.dongqiudi.com, *.feng.com, www.flyertea.com, music.163.com, *.m.163.com, user.qunar.com, *.rr.tv, sf-integral-sign-in.weixinjia.net, *.smzdm.com, tieba.baidu.com, *.v2ex.com, *.video.qq.com, v.qq.com, mobwsa.ximalaya.com, *.you.163.com, *.rrys2019.com, ios.zmzapi.com
hostname = luckman.suning.com, passport.suning.com, sign.suning.com, gameapi.suning.com, m.ctrip.com, 110.43.90.61, zt.wps.cn, daojia.jd.com, app.nio.com, wxprdapplet.gac-nio.com, maicai.api.ddxq.mobi, group.baicizhan.com, api.everphoto.cn, promotion.waimai.meituan.com, wx.10086.cn, www.maomicd.com, m.client.10010.com, act.10010.com, api-takumi.mihoyo.com, gdws.nsenz.com, credits.bz.mgtv.com, *.csdn.net, wapside.189.cn, *.acfun.cn, apk.tw, *.bilibili.com, api.dongqiudi.com, *.feng.com, www.flyertea.com, music.163.com, *.m.163.com, user.qunar.com, *.rr.tv, sf-integral-sign-in.weixinjia.net, *.smzdm.com, tieba.baidu.com, *.v2ex.com, *.video.qq.com, v.qq.com, mobwsa.ximalaya.com, *.you.163.com, *.rrys2019.com, ios.zmzapi.com

# 电信营业厅
^https:\/\/wapside.189.cn:9001\/api\/home\/homeInfo url script-request-header chavyleung/10000/10000.cookie.js
Expand Down Expand Up @@ -139,4 +139,5 @@ https:\/\/www.maomicd.com\/plugin.php\?id=k_misign:sign&operation=qiandao url sc
# 苏宁易购
^https:\/\/passport.suning.com\/ids\/login$ url script-request-body chavyleung/suning/suning.cookie.js
^https:\/\/luckman.suning.com\/luck-web\/sign\/api\/clock_sign.do url script-request-header chavyleung/suning/suning.cookie.js
^https:\/\/sign.suning.com\/sign-web\/m\/promotion\/sign\/doSign.do url script-request-header chavyleung/suning/suning.cookie.js
^https:\/\/sign.suning.com\/sign-web\/m\/promotion\/sign\/doSign.do url script-request-header chavyleung/suning/suning.cookie.js
^https:\/\/gameapi.suning.com\/sngame-web\/(api\/signin\/private\/customerSignOperation.do|gateway\/api\/queryPrize.do) url script-request-header chavyleung/suning/suning.cookie.js
5 changes: 3 additions & 2 deletions QuantumultX_Local_Cookie.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 本配置适用于: QuanX TestFlight v1.0.6-build195 及以后版本
# 如果你是商店版, 请使用: QuantumultX_AppStore_Local_Cookie.conf

hostname = luckman.suning.com, passport.suning.com, sign.suning.com, m.ctrip.com, 110.43.90.61, zt.wps.cn, m-bean.kaola.com, daojia.jd.com, app.nio.com, wxprdapplet.gac-nio.com, node.kg.qq.com, api.dushu.io, pm.m.fenqile.com, maicai.api.ddxq.mobi, group.baicizhan.com, api.everphoto.cn, i.meituan.com, promotion.waimai.meituan.com, wx.10086.cn, www.maomicd.com, m.client.10010.com, act.10010.com, api-takumi.mihoyo.com, m.gdoil.cn, credits.bz.mgtv.com, *.csdn.net, wapside.189.cn, *.acfun.cn, apk.tw, *.bilibili.com, api.dongqiudi.com, *.feng.com, www.flyertea.com, music.163.com, *.m.163.com, user.qunar.com, *.rr.tv, sf-integral-sign-in.weixinjia.net, *.smzdm.com, tieba.baidu.com, *.v2ex.com, *.video.qq.com, v.qq.com, mobwsa.ximalaya.com, *.you.163.com, *.rrys2019.com, ios.zmzapi.com
hostname = luckman.suning.com, passport.suning.com, sign.suning.com, gameapi.suning.com, m.ctrip.com, 110.43.90.61, zt.wps.cn, m-bean.kaola.com, daojia.jd.com, app.nio.com, wxprdapplet.gac-nio.com, node.kg.qq.com, api.dushu.io, pm.m.fenqile.com, maicai.api.ddxq.mobi, group.baicizhan.com, api.everphoto.cn, i.meituan.com, promotion.waimai.meituan.com, wx.10086.cn, www.maomicd.com, m.client.10010.com, act.10010.com, api-takumi.mihoyo.com, m.gdoil.cn, credits.bz.mgtv.com, *.csdn.net, wapside.189.cn, *.acfun.cn, apk.tw, *.bilibili.com, api.dongqiudi.com, *.feng.com, www.flyertea.com, music.163.com, *.m.163.com, user.qunar.com, *.rr.tv, sf-integral-sign-in.weixinjia.net, *.smzdm.com, tieba.baidu.com, *.v2ex.com, *.video.qq.com, v.qq.com, mobwsa.ximalaya.com, *.you.163.com, *.rrys2019.com, ios.zmzapi.com

# 电信营业厅
^https:\/\/wapside.189.cn:9001\/api\/home\/homeInfo url script-request-header https://raw.githubusercontent.com/chavyleung/scripts/master/10000/10000.cookie.js
Expand Down Expand Up @@ -135,4 +135,5 @@ https:\/\/www.maomicd.com\/plugin.php\?id=k_misign:sign&operation=qiandao url sc
# 苏宁易购
^https:\/\/passport.suning.com\/ids\/login$ url script-request-body https://raw.githubusercontent.com/chavyleung/scripts/master/suning/suning.cookie.js
^https:\/\/luckman.suning.com\/luck-web\/sign\/api\/clock_sign.do url script-request-header https://raw.githubusercontent.com/chavyleung/scripts/master/suning/suning.cookie.js
^https:\/\/sign.suning.com\/sign-web\/m\/promotion\/sign\/doSign.do url script-request-header https://raw.githubusercontent.com/chavyleung/scripts/master/suning/suning.cookie.js
^https:\/\/sign.suning.com\/sign-web\/m\/promotion\/sign\/doSign.do url script-request-header https://raw.githubusercontent.com/chavyleung/scripts/master/suning/suning.cookie.js
^https:\/\/gameapi.suning.com\/sngame-web\/(api\/signin\/private\/customerSignOperation.do|gateway\/api\/queryPrize.do) url script-request-header https://raw.githubusercontent.com/chavyleung/scripts/master/suning/suning.cookie.js
14 changes: 9 additions & 5 deletions suning/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
> 有一定动手及排查问题能力的同学先上车
> 2020.3.15 增加天天低价, 注意更新`mitm``rewrite`并进入天天低价获取两次 Cookie
## 配置 (Surge)

```properties
[MITM]
hostname = passport.suning.com, luckman.suning.com, sign.suning.com
hostname = passport.suning.com, luckman.suning.com, sign.suning.com, gameapi.suning.com

[Script]
# 注意有3条获取 Cookie 脚本
# 注意有4条获取 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
Expand All @@ -22,28 +24,30 @@ cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scr

```properties
[MITM]
hostname = passport.suning.com, luckman.suning.com, sign.suning.com
hostname = passport.suning.com, luckman.suning.com, sign.suning.com, gameapi.suning.com

[rewrite_local]
# 注意有3条获取 Cookie 脚本
# 注意有4条获取 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
^https:\/\/gameapi.suning.com\/sngame-web\/(api\/signin\/private\/customerSignOperation.do|gateway\/api\/queryPrize.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]`
1. 先把`passport.suning.com, luckman.suning.com, sign.suning.com, gameapi.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: 成功 (每日红包)` (如果找不到领取红包,尝试卸载苏宁重新安装) 兼容之前 @barrymchen 写的 snyg.js 如果之前有用这个脚本获取过 Cookie 那不用重新取
- 【可选】进入 `主页` > `天天低价`, 系统提示: `获取Cookie: 成功 (天天低价)``获取Cookie: 成功 (查询天天低价)`
4. 把获取 Cookie 的脚本注释或删掉

> 第 1 条脚本是用来获取 cookie 的, 用浏览器访问一次获取 cookie 成功后就可以删掉或注释掉了, 但请确保在`登录成功`后再获取 cookie.
Expand Down
20 changes: 20 additions & 0 deletions suning/suning.cookie.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ 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'
const KEY_signgameurl = 'chavy_signgame_url_suning'
const KEY_signgameheader = 'chavy_signgame_header_suning'
const KEY_signgetgameurl = 'chavy_signgetgame_url_suning'
const KEY_signgetgameheader = 'chavy_signgetgame_header_suning'

if ($request.url.match(/\/ids\/login/)) {
const VAL_loginurl = $request.url
Expand Down Expand Up @@ -35,6 +39,22 @@ if ($request.url.match(/\/ids\/login/)) {
chavy.msg(`${cookieName}`, '获取Cookie: 成功 (每日红包)', '')
chavy.log(`❕ ${cookieName} 获取Cookie: 成功, VAL_signweburl: ${VAL_signweburl}`)
chavy.log(`❕ ${cookieName} 获取Cookie: 成功, VAL_signwebheader: ${VAL_signwebheader}`)
} else if ($request.url.match(/customerSignOperation.do/)) {
const VAL_signgameurl = $request.url
const VAL_signgameheader = JSON.stringify($request.headers)
if (VAL_signgameurl) chavy.setdata(VAL_signgameurl, KEY_signgameurl)
if (VAL_signgameheader) chavy.setdata(VAL_signgameheader, KEY_signgameheader)
chavy.msg(`${cookieName}`, '获取Cookie: 成功 (天天低价)', '')
chavy.log(`❕ ${cookieName} 获取Cookie: 成功, VAL_signgameurl: ${VAL_signgameurl}`)
chavy.log(`❕ ${cookieName} 获取Cookie: 成功, VAL_signgameheader: ${VAL_signgameheader}`)
} else if ($request.url.match(/queryPrize.do/)) {
const VAL_signgetgameurl = $request.url
const VAL_signgetgameheader = JSON.stringify($request.headers)
if (VAL_signgetgameurl) chavy.setdata(VAL_signgetgameurl, KEY_signgetgameurl)
if (VAL_signgetgameheader) chavy.setdata(VAL_signgetgameheader, KEY_signgetgameheader)
chavy.msg(`${cookieName}`, '获取Cookie: 成功 (查询天天低价)', '')
chavy.log(`❕ ${cookieName} 获取Cookie: 成功, VAL_signgetgameurl: ${VAL_signgetgameurl}`)
chavy.log(`❕ ${cookieName} 获取Cookie: 成功, VAL_signgetgameheader: ${VAL_signgetgameheader}`)
}

function init() {
Expand Down
74 changes: 74 additions & 0 deletions suning/suning.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ const KEY_signheader = 'chavy_sign_header_suning'
const KEY_signweburl = 'chavy_signweb_url_suning'
const KEY_signweburlBarry = 'snyg_userTokenKey'
const KEY_signwebheader = 'chavy_signweb_header_suning'
const KEY_signgameurl = 'chavy_signgame_url_suning'
const KEY_signgameheader = 'chavy_signgame_header_suning'
const KEY_signgetgameurl = 'chavy_signgetgame_url_suning'
const KEY_signgetgameheader = 'chavy_signgetgame_header_suning'
const KEY_runflag = 'chavy_runflag_suning'

const signinfo = {}
Expand All @@ -19,6 +23,10 @@ let VAL_signheader = chavy.getdata(KEY_signheader)
let VAL_signweburl = chavy.getdata(KEY_signweburl)
let VAL_signweburlBarry = chavy.getdata(KEY_signweburlBarry)
let VAL_signwebheader = chavy.getdata(KEY_signwebheader)
let VAL_signgameurl = chavy.getdata(KEY_signgameurl)
let VAL_signgameheader = chavy.getdata(KEY_signgameheader)
let VAL_signgetgameurl = chavy.getdata(KEY_signgetgameurl)
let VAL_signgetgameheader = chavy.getdata(KEY_signgetgameheader)
let VAL_runflag = chavy.getdata(KEY_runflag)

;(sign = async () => {
Expand All @@ -27,6 +35,7 @@ let VAL_runflag = chavy.getdata(KEY_runflag)
if (VAL_signurl) await signapp()
await getinfo()
if (VAL_signweburl || VAL_signweburlBarry) await signweb(), await getwebinfo()
if (VAL_signgameurl && VAL_signgetgameurl) await signgame(), await getgameinfo()
showmsg()
})().catch((e) => chavy.log(`❌ ${cookieName} 签到失败: ${e}`))

Expand Down Expand Up @@ -61,6 +70,25 @@ function signapp() {
})
}

function signgame() {
return new Promise((resolve, reject) => {
const url = { url: VAL_signgameurl, headers: JSON.parse(VAL_signgameheader) }
delete url.headers['Cookie']
chavy.get(url, (error, response, data) => {
try {
chavy.log(`❕ ${cookieName} signgame - response: ${JSON.stringify(response)}`)
signinfo.signgame = JSON.parse(data)
resolve()
} catch (e) {
chavy.msg(cookieName, `天天低价: 失败`, `说明: ${e}`)
chavy.log(`❌ ${cookieName} signgame - 签到失败: ${e}`)
chavy.log(`❌ ${cookieName} signgame - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}

function signweb() {
return new Promise((resolve, reject) => {
let url = null
Expand Down Expand Up @@ -116,6 +144,25 @@ function getwebinfo() {
})
}

function getgameinfo() {
return new Promise((resolve, reject) => {
const url = { url: VAL_signgetgameurl, headers: JSON.parse(VAL_signgetgameheader) }
delete url.headers['Cookie']
chavy.get(url, (error, response, data) => {
try {
chavy.log(`❕ ${cookieName} getgameinfo - response: ${JSON.stringify(response)}`)
signinfo.gameinfo = JSON.parse(data.match(/\((.*)\)/)[1])
resolve()
} catch (e) {
chavy.msg(cookieName, `查询天天低价: 失败`, `说明: ${e}`)
chavy.log(`❌ ${cookieName} getgameinfo - 查询天天低价失败: ${e}`)
chavy.log(`❌ ${cookieName} getgameinfo - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}

function getinfo() {
return new Promise((resolve, reject) => {
const timestamp = Math.round(new Date().getTime()).toString()
Expand Down Expand Up @@ -176,6 +223,21 @@ function showmsg() {
chavy.log(`❌ ${cookieName} showmsg - 每日红包 - signweb: ${JSON.stringify(signinfo.signweb)}`)
}

subTitle += subTitle == '' ? '' : ', '
if (signinfo.signgame && signinfo.signgame.code == '1') {
if (signinfo.signgame.data.resultCode == 'SG0000') {
subTitle += '低价: 成功'
} else if (signinfo.signgame.data.resultCode == 'SG0103') {
subTitle += '低价: 重复'
} else {
subTitle += '低价: 失败'
chavy.log(`❌ ${cookieName} showmsg - 每日红包 - signweb: ${JSON.stringify(signinfo.signgame)}`)
}
} else {
subTitle += '红包: 失败'
chavy.log(`❌ ${cookieName} showmsg - 每日红包 - signweb: ${JSON.stringify(signinfo.signgame)}`)
}

if (signinfo.webinfo && signinfo.webinfo.respData) {
const currentIndex = signinfo.webinfo.respData.currentIndex
const detailTreeMap = signinfo.webinfo.respData.detailTreeMap
Expand All @@ -191,6 +253,18 @@ function showmsg() {
chavy.log(`❌ ${cookieName} showmsg - 每日红包 - webinfo: ${JSON.stringify(signinfo.webinfo)}`)
}

if (signinfo.signgame && signinfo.gameinfo && signinfo.gameinfo.code == 1) {
if (signinfo.gameinfo.data.resultCode == 0000) {
moreDetail += moreDetail == '' ? '' : '\n'
moreDetail += '\n💰 天天低价: '
for (d of signinfo.gameinfo.data.result.datas) moreDetail += `\n${d.obj.couponRuleName} (${d.obj.remainValue}元)`
} else {
chavy.log(`❌ ${cookieName} showmsg - 天天低价 - gameinfo: ${JSON.stringify(signinfo.gameinfo)}`)
}
} else {
chavy.log(`❌ ${cookieName} showmsg - 天天低价 - gameinfo: ${JSON.stringify(signinfo.gameinfo)}`)
}

if (moreDetail) detail += `\n查看签到详情\n${moreDetail}`
chavy.msg(cookieName, subTitle, detail)
}
Expand Down

0 comments on commit 9e27741

Please sign in to comment.