parent
24706c9561
commit
e2005397d7
|
@ -0,0 +1,68 @@
|
|||
const cookieName = '中国移动'
|
||||
const tokenurlKey = 'chavy_tokenurl_10086'
|
||||
const tokenheaderKey = 'chavy_tokenheader_10086'
|
||||
const signurlKey = 'chavy_signurl_10086'
|
||||
const signheaderKey = 'chavy_signheader_10086'
|
||||
const chavy = init()
|
||||
|
||||
const requrl = $request.url
|
||||
const reqRef = $request.headers.Referer
|
||||
if ($request && $request.method != 'OPTIONS' && requrl.indexOf('website/taskCenter/index') >= 0 && requrl.indexOf('mobile=') >= 0) {
|
||||
const tokenurlVal = requrl
|
||||
const tokenheaderVal = JSON.stringify($request.headers)
|
||||
if (tokenurlVal) chavy.setdata(tokenurlVal, tokenurlKey)
|
||||
if (tokenheaderVal) chavy.setdata(tokenheaderVal, tokenheaderKey)
|
||||
title = chavy.msg(cookieName, `获取刷新链接: 成功`, ``)
|
||||
} else if ($request && $request.method != 'OPTIONS' && requrl.indexOf('website/taskCenter/sign') >= 0) {
|
||||
const signurlVal = requrl
|
||||
const signheaderVal = JSON.stringify($request.headers)
|
||||
if (signurlVal) chavy.setdata(signurlVal, signurlKey)
|
||||
if (signheaderVal) chavy.setdata(signheaderVal, signheaderKey)
|
||||
title = chavy.msg(cookieName, `获取Cookie: 成功`, ``)
|
||||
}
|
||||
|
||||
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()
|
|
@ -0,0 +1,157 @@
|
|||
/**
|
||||
*
|
||||
* hostname = clientaccess.10086.cn
|
||||
*
|
||||
* # Surge
|
||||
* Rewrite: CMCC = type=http-request,pattern=^https:\/\/clientaccess.10086.cn\/biz-orange\/LN\/uamrandcodelogin\/autoLogin,script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/10086/10086.fee.cookie.js,requires-body=true,debug=true
|
||||
* Rewrite: CMCC = type=http-request,pattern=^https:\/\/clientaccess.10086.cn\/biz-orange\/BN\/realFeeQuery\/getRealFee,script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/10086/10086.fee.cookie.js,requires-body=true,debug=true
|
||||
* Tasks: 10086-查话费 = type=cron,cronexp=10 0 * * *,script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/10086/10086.fee.js,wake-system=true
|
||||
*
|
||||
* # QuanX
|
||||
* ^https:\/\/clientaccess.10086.cn\/biz-orange\/LN\/uamrandcodelogin\/autoLogin url script-request-body https://raw.githubusercontent.com/chavyleung/scripts/master/10086/10086.fee.cookie.js
|
||||
* ^https:\/\/clientaccess.10086.cn\/biz-orange\/BN\/realFeeQuery\/getRealFee url script-request-body https://raw.githubusercontent.com/chavyleung/scripts/master/10086/10086.fee.cookie.js
|
||||
* 10 0 * * * https://raw.githubusercontent.com/chavyleung/scripts/master/10086/10086.fee.js, tag=10086-查话费
|
||||
*
|
||||
* # Loon
|
||||
* http-response ^https:\/\/clientaccess.10086.cn\/biz-orange\/LN\/uamrandcodelogin\/autoLogin script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/10086/10086.fee.cookie.js, requires-body=true
|
||||
* http-response ^https:\/\/clientaccess.10086.cn\/biz-orange\/BN\/realFeeQuery\/getRealFee script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/10086/10086.fee.cookie.js, requires-body=true
|
||||
* cron "10 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/10086/10086.fee.cookie.js
|
||||
*
|
||||
*/
|
||||
|
||||
const $ = new Env('中国移动')
|
||||
$.KEY_autologin = 'chavy_autologin_cmcc'
|
||||
$.KEY_getfee = 'chavy_getfee_cmcc'
|
||||
|
||||
!(async () => {
|
||||
const session = {}
|
||||
session.url = $request.url
|
||||
session.body = $request.body
|
||||
session.headers = $request.headers
|
||||
let key = ''
|
||||
if (/autoLogin/.test(session.url)) {
|
||||
key = $.KEY_autologin
|
||||
} else if (/getRealFee/.test(session.url)) {
|
||||
key = $.KEY_getfee
|
||||
}
|
||||
if ($.setdata(JSON.stringify(session), key)) {
|
||||
$.subt = `获取会话: 成功! (${key})`
|
||||
} else {
|
||||
$.subt = `获取会话: 失败! (${key})`
|
||||
}
|
||||
$.msg($.name, $.subt, $.desc)
|
||||
})()
|
||||
.catch((e) => $.logErr(e))
|
||||
.finally(() => $.done())
|
||||
|
||||
// prettier-ignore
|
||||
function Env(t, s) {
|
||||
return new class {
|
||||
constructor(t, s) {
|
||||
this.name = t, this.data = null, this.dataFile = "box.dat", this.logs = [], this.logSeparator = "\n", this.startTime = (new Date).getTime(), Object.assign(this, s), this.log("", `\ud83d\udd14${this.name}, \u5f00\u59cb!`)
|
||||
}
|
||||
|
||||
isNode() {
|
||||
return "undefined" != typeof module && !!module.exports
|
||||
}
|
||||
|
||||
isQuanX() {
|
||||
return "undefined" != typeof $task
|
||||
}
|
||||
|
||||
isSurge() {
|
||||
return "undefined" != typeof $httpClient
|
||||
}
|
||||
|
||||
isLoon() {
|
||||
return "undefined" != typeof $loon
|
||||
}
|
||||
|
||||
loaddata() {
|
||||
if (!this.isNode) return {};
|
||||
{
|
||||
this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path");
|
||||
const t = this.path.resolve(this.dataFile), s = this.path.resolve(process.cwd(), this.dataFile),
|
||||
e = this.fs.existsSync(t), i = !e && this.fs.existsSync(s);
|
||||
if (!e && !i) return {};
|
||||
{
|
||||
const i = e ? t : s;
|
||||
try {
|
||||
return JSON.parse(this.fs.readFileSync(i))
|
||||
} catch {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
writedata() {
|
||||
if (this.isNode) {
|
||||
this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path");
|
||||
const t = this.path.resolve(this.dataFile), s = this.path.resolve(process.cwd(), this.dataFile),
|
||||
e = this.fs.existsSync(t), i = !e && this.fs.existsSync(s), h = JSON.stringify(this.data);
|
||||
e ? this.fs.writeFileSync(t, h) : i ? this.fs.writeFileSync(s, h) : this.fs.writeFileSync(t, h)
|
||||
}
|
||||
}
|
||||
|
||||
getdata(t) {
|
||||
return this.isSurge() || this.isLoon() ? $persistentStore.read(t) : this.isQuanX() ? $prefs.valueForKey(t) : this.isNode() ? (this.data = this.loaddata(), this.data[t]) : this.data && this.data[t] || null
|
||||
}
|
||||
|
||||
setdata(t, s) {
|
||||
return this.isSurge() || this.isLoon() ? $persistentStore.write(t, s) : this.isQuanX() ? $prefs.setValueForKey(t, s) : this.isNode() ? (this.data = this.loaddata(), this.data[s] = t, this.writedata(), !0) : this.data && this.data[s] || null
|
||||
}
|
||||
|
||||
get(t, s = (() => {
|
||||
})) {
|
||||
t.headers && (delete t.headers["Content-Type"], delete t.headers["Content-Length"]), this.isSurge() || this.isLoon() ? $httpClient.get(t, (t, e, i) => {
|
||||
!t && e && (e.body = i, e.statusCode = e.status, s(t, e, i))
|
||||
}) : this.isQuanX() ? $task.fetch(t).then(t => {
|
||||
const {statusCode: e, statusCode: i, headers: h, body: o} = t;
|
||||
s(null, {status: e, statusCode: i, headers: h, body: o}, o)
|
||||
}, t => s(t)) : this.isNode() && (this.got = this.got ? this.got : require("got"), this.got(t).then(t => {
|
||||
const {statusCode: e, statusCode: i, headers: h, body: o} = t;
|
||||
s(null, {status: e, statusCode: i, headers: h, body: o}, o)
|
||||
}, t => s(t)))
|
||||
}
|
||||
|
||||
post(t, s = (() => {
|
||||
})) {
|
||||
if (t.body && t.headers && !t.headers["Content-Type"] && (t.headers["Content-Type"] = "application/x-www-form-urlencoded"), delete t.headers["Content-Length"], this.isSurge() || this.isLoon()) $httpClient.post(t, (t, e, i) => {
|
||||
!t && e && (e.body = i, e.statusCode = e.status, s(t, e, i))
|
||||
}); else if (this.isQuanX()) t.method = "POST", $task.fetch(t).then(t => {
|
||||
const {statusCode: e, statusCode: i, headers: h, body: o} = t;
|
||||
s(null, {status: e, statusCode: i, headers: h, body: o}, o)
|
||||
}, t => s(t)); else if (this.isNode()) {
|
||||
this.got = this.got ? this.got : require("got");
|
||||
const {url: e, ...i} = t;
|
||||
this.got.post(e, i).then(t => {
|
||||
const {statusCode: e, statusCode: i, headers: h, body: o} = t;
|
||||
s(null, {status: e, statusCode: i, headers: h, body: o}, o)
|
||||
}, t => s(t))
|
||||
}
|
||||
}
|
||||
|
||||
msg(s = t, e = "", i = "", h) {
|
||||
this.isSurge() || this.isLoon() ? $notification.post(s, e, i) : this.isQuanX() && $notify(s, e, i), this.logs.push("", "==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="), this.logs.push(s), e && this.logs.push(e), i && this.logs.push(i)
|
||||
}
|
||||
|
||||
log(...t) {
|
||||
t.length > 0 ? this.logs = [...this.logs, ...t] : console.log(this.logs.join(this.logSeparator))
|
||||
}
|
||||
|
||||
logErr(t, s) {
|
||||
const e = !this.isSurge() && !this.isQuanX() && !this.isLoon();
|
||||
e ? $.log("", `\u2757\ufe0f${this.name}, \u9519\u8bef!`, t.stack) : $.log("", `\u2757\ufe0f${this.name}, \u9519\u8bef!`, t.message)
|
||||
}
|
||||
|
||||
wait(t) {
|
||||
return new Promise(s => setTimeout(s, t))
|
||||
}
|
||||
|
||||
done(t = null) {
|
||||
const s = (new Date).getTime(), e = (s - this.startTime) / 1e3;
|
||||
this.log("", `\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${e} \u79d2`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t)
|
||||
}
|
||||
}(t, s)
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,97 @@
|
|||
const cookieName = '中国移动'
|
||||
const tokenurlKey = 'chavy_tokenurl_10086'
|
||||
const tokenheaderKey = 'chavy_tokenheader_10086'
|
||||
const signurlKey = 'chavy_signurl_10086'
|
||||
const signheaderKey = 'chavy_signheader_10086'
|
||||
const chavy = init()
|
||||
const tokenurlVal = chavy.getdata(tokenurlKey)
|
||||
const tokenheaderVal = chavy.getdata(tokenheaderKey)
|
||||
const signurlVal = chavy.getdata(signurlKey)
|
||||
let signheaderVal = chavy.getdata(signheaderKey)
|
||||
const signinfo = {}
|
||||
|
||||
sign()
|
||||
|
||||
function loginapp(cb) {
|
||||
const url = {url: tokenurlVal, headers: JSON.parse(tokenheaderVal)}
|
||||
chavy.get(url, (error, response, data) => {
|
||||
const respcookie = response.headers['Set-Cookie']
|
||||
chavy.log(`${cookieName}, loginapp - respcookie: ${respcookie}`)
|
||||
if (respcookie && respcookie.indexOf('d.sid=') >= 0) {
|
||||
const signheaderObj = JSON.parse(signheaderVal)
|
||||
let signcookie = signheaderObj['Cookie']
|
||||
signcookie = signcookie.replace(/d\.sid=([^;]*)/, respcookie.match(/d\.sid=([^;]*)/)[0])
|
||||
signheaderObj['Cookie'] = signcookie
|
||||
signheaderVal = JSON.stringify(signheaderObj)
|
||||
}
|
||||
cb()
|
||||
})
|
||||
}
|
||||
|
||||
function sign() {
|
||||
loginapp(() => {
|
||||
const url = {url: signurlVal, headers: JSON.parse(signheaderVal)}
|
||||
chavy.get(url, (error, response, data) => {
|
||||
chavy.log(`${cookieName}, data: ${data}`)
|
||||
const result = JSON.parse(data)
|
||||
let subTitle = ``
|
||||
let detail = ``
|
||||
if (result.rtnCode == '0') {
|
||||
subTitle = `签到结果: 成功`
|
||||
detail = `连签: ${result.object.signDays}天`
|
||||
} else if (result.rtnCode == '-9999' && result.object.status == '50001') {
|
||||
subTitle = `签到结果: 成功 (重复签到)`
|
||||
detail = `说明: ${result.object.message}`
|
||||
} else {
|
||||
subTitle = `签到结果: 失败`
|
||||
detail = `说明: 详见日志`
|
||||
}
|
||||
chavy.msg(cookieName, subTitle, detail)
|
||||
chavy.done()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
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, resp.body))
|
||||
}
|
||||
}
|
||||
post = (url, cb) => {
|
||||
if (isSurge()) {
|
||||
$httpClient.post(url, cb)
|
||||
}
|
||||
if (isQuanX()) {
|
||||
url.method = 'POST'
|
||||
$task.fetch(url).then((resp) => cb(null, resp, resp.body))
|
||||
}
|
||||
}
|
||||
done = (value = {}) => {
|
||||
$done(value)
|
||||
}
|
||||
return {isSurge, isQuanX, msg, log, getdata, setdata, get, post, done}
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
# 中国移动
|
||||
|
||||
> 代码已同时兼容 Surge & QuanX, 使用同一份签到脚本即可
|
||||
|
||||
> 注意: 中国移动是指名字为`10086`这款的 APP [点这里下载](https://apps.apple.com/cn/app/10086-%E4%B8%AD%E5%9B%BD%E7%A7%BB%E5%8A%A8%E5%87%BA%E5%93%81/id1004816017)
|
||||
|
||||
## 配置 (Surge)
|
||||
|
||||
```properties
|
||||
[MITM]
|
||||
wx.10086.cn
|
||||
|
||||
[Script]
|
||||
# 注意获取Cookie有两条脚本
|
||||
http-request ^http:\/\/wx.10086.cn\/website\/taskCenter\/index\? script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/10086/10086.cookie.js
|
||||
http-request ^http:\/\/wx.10086.cn\/website\/taskCenter\/sign\? script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/10086/10086.cookie.js
|
||||
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/10086/10086.js
|
||||
```
|
||||
|
||||
## 配置 (QuanX)
|
||||
|
||||
```properties
|
||||
[MITM]
|
||||
wx.10086.cn
|
||||
|
||||
[rewrite_local]
|
||||
# 注意获取Cookie有两条脚本
|
||||
^http:\/\/wx.10086.cn\/website\/taskCenter\/index\? url script-request-header 10086.cookie.js
|
||||
^http:\/\/wx.10086.cn\/website\/taskCenter\/sign\? url script-request-header 10086.cookie.js
|
||||
|
||||
[task_local]
|
||||
1 0 * * * 10086.js
|
||||
```
|
||||
|
||||
## 说明
|
||||
|
||||
1. 先把`wx.10086.cn`加到`[MITM]`
|
||||
2. 再配置重写规则:
|
||||
- Surge: 把两条远程脚本放到`[Script]`
|
||||
- QuanX: 把`10086.cookie.js`和`10086.js`传到`On My iPhone - Quantumult X - Scripts` (传到 iCloud 相同目录也可, 注意要打开 quanx 的 iCloud 开关)
|
||||
3. 打开 APP , 进入签到页面, 系统提示: `获取刷新链接: 成功`
|
||||
4. 然后手动签到 1 次, 系统提示: `获取Cookie: 成功`
|
||||
5. 把获取 Cookie 的脚本注释掉
|
||||
6. 运行一次脚本, 如果提示重复签到, 那就算成功了!
|
||||
|
||||
> 第 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)
|
Loading…
Reference in New Issue