del: 资源架构调整. 去除无用文件

This commit is contained in:
sve1r 2023-02-17 16:05:40 +08:00
parent af747850b3
commit bbe17c42f9
192 changed files with 0 additions and 30654 deletions

View File

@ -1,58 +0,0 @@
const cookieName = '电信营业厅'
const KEY_signheader = 'chavy_signheader_10000'
const KEY_signbody = 'chavy_signbody_10000'
const KEY_mobile = 'chavy_mobile_10000'
const chavy = init()
if (this.$request && this.$request.headers && this.$request.body) {
const VAL_signheader = JSON.stringify($request.headers)
const VAL_signbody = this.$request.body
if (VAL_signheader) chavy.setdata(VAL_signheader, KEY_signheader)
if (VAL_signbody) chavy.setdata(VAL_signbody, KEY_signbody)
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()

File diff suppressed because it is too large Load Diff

View File

@ -1,98 +0,0 @@
# 电信营业厅
> 2020.5.6 更新签到脚本 (正则和 rewrite 类型都有变化, 需要重取 Cookie)
## 配置 (Surge)
```properties
[MITM]
wapside.189.cn:9001
[Script]
http-request ^https:\/\/wapside.189.cn:9001\/api\/home\/sign script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/10000/10000.cookie.js, requires-body=true
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/10000/10000.js
```
## 配置 (QuanX)
```properties
[MITM]
wapside.189.cn
[rewrite_local]
# 190及以后版本
^https:\/\/wapside.189.cn:9001\/api\/home\/sign url script-request-body 10000.cookie.js
[task_local]
1 0 * * * 10000.js
```
## 说明
> 先在登录成功后, 再打开获取 Cookie 的脚本
1. 先配置`[MITM]`
- Surge: wapside.189.cn:9001
- QuanX: wapside.189.cn
2. 再配置重写规则:
- Surge: 把两条远程脚本放到`[Script]`
- QuanX: 把`10000.cookie.js`和`10000.js`传到`On My iPhone - Quantumult X - Scripts` (传到 iCloud 相同目录也可, 注意要打开 quanx 的 iCloud 开关)
3. 打开 APP 手动签到一次: 访问下右下角 `我` > `签到` (头像下面)
4. 系统提示: `获取Cookie: 成功`
5. 最后就可以把第 1 条脚本注释掉了
> 第 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)
[@sazs34](https://github.com/sazs34/)

View File

@ -1,82 +0,0 @@
const cookieName = '中国联通'
const tokenurlKey = 'chavy_tokenurl_10010'
const tokenheaderKey = 'chavy_tokenheader_10010'
const signurlKey = 'chavy_signurl_10010'
const signheaderKey = 'chavy_signheader_10010'
const loginlotteryurlKey = 'chavy_loginlotteryurl_10010'
const loginlotteryheaderKey = 'chavy_loginlotteryheader_10010'
const findlotteryurlKey = 'chavy_findlotteryurl_10010'
const findlotteryheaderKey = 'chavy_findlotteryheader_10010'
const chavy = init()
if ($request && $request.method != 'OPTIONS' && $request.url.indexOf('querySigninActivity.htm') >= 0) {
const tokenurlVal = $request.url
const tokenheaderVal = JSON.stringify($request.headers)
if (tokenurlVal) chavy.setdata(tokenurlVal, tokenurlKey)
if (tokenheaderVal) chavy.setdata(tokenheaderVal, tokenheaderKey)
chavy.msg(cookieName, `获取刷新链接: 成功`, ``)
} else if ($request && $request.method != 'OPTIONS' && $request.url.indexOf('daySign') >= 0) {
const signurlVal = $request.url
const signheaderVal = JSON.stringify($request.headers)
if (signurlVal) chavy.setdata(signurlVal, signurlKey)
if (signheaderVal) chavy.setdata(signheaderVal, signheaderKey)
chavy.msg(cookieName, `获取Cookie: 成功 (每日签到)`, ``)
} else if ($request && $request.method != 'OPTIONS' && $request.url.indexOf('userLogin') >= 0) {
const loginlotteryurlVal = $request.url
const loginlotteryheaderVal = JSON.stringify($request.headers)
if (loginlotteryurlVal) chavy.setdata(loginlotteryurlVal, loginlotteryurlKey)
if (loginlotteryheaderVal) chavy.setdata(loginlotteryheaderVal, loginlotteryheaderKey)
chavy.msg(cookieName, `获取Cookie: 成功 (登录抽奖)`, ``)
} else if ($request && $request.method != 'OPTIONS' && $request.url.indexOf('findActivityInfo') >= 0) {
const findlotteryurlVal = $request.url
const findlotteryheaderVal = JSON.stringify($request.headers)
if (findlotteryurlVal) chavy.setdata(findlotteryurlVal, findlotteryurlKey)
if (findlotteryheaderVal) chavy.setdata(findlotteryheaderVal, findlotteryheaderKey)
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()

View File

@ -1,256 +0,0 @@
const chavy = init()
const cookieName = '中国联通'
const KEY_loginurl = 'chavy_tokenurl_10010'
const KEY_loginheader = 'chavy_tokenheader_10010'
const KEY_signurl = 'chavy_signurl_10010'
const KEY_signheader = 'chavy_signheader_10010'
const KEY_loginlotteryurl = 'chavy_loginlotteryurl_10010'
const KEY_loginlotteryheader = 'chavy_loginlotteryheader_10010'
const KEY_findlotteryurl = 'chavy_findlotteryurl_10010'
const KEY_findlotteryheader = 'chavy_findlotteryheader_10010'
const signinfo = {}
let VAL_loginurl = chavy.getdata(KEY_loginurl)
let VAL_loginheader = chavy.getdata(KEY_loginheader)
let VAL_signurl = chavy.getdata(KEY_signurl)
let VAL_signheader = chavy.getdata(KEY_signheader)
let VAL_loginlotteryurl = chavy.getdata(KEY_loginlotteryurl)
let VAL_loginlotteryheader = chavy.getdata(KEY_loginlotteryheader)
let VAL_findlotteryurl = chavy.getdata(KEY_findlotteryurl)
let VAL_findlotteryheader = chavy.getdata(KEY_findlotteryheader)
;(sign = async () => {
chavy.log(`🔔 ${cookieName}`)
await loginapp()
await signapp()
if (VAL_loginlotteryurl && VAL_findlotteryurl) await loginlottery()
if (signinfo.encryptmobile) {
await findlottery()
if (signinfo.findlottery && signinfo.findlottery.acFrequency && signinfo.findlottery.acFrequency.usableAcFreq) {
for (let i = 0; i < signinfo.findlottery.acFrequency.usableAcFreq; i++) {
await lottery()
}
}
}
await getinfo()
showmsg()
chavy.done()
})().catch((e) => chavy.log(`${cookieName} 签到失败: ${e}`), chavy.done())
function loginapp() {
return new Promise((resolve, reject) => {
const url = {url: VAL_loginurl, headers: JSON.parse(VAL_loginheader)}
chavy.post(url, (error, response, data) => {
try {
resolve()
} catch (e) {
chavy.msg(cookieName, `登录结果: 失败`, `说明: ${e}`)
chavy.log(`${cookieName} loginapp - 登录失败: ${e}`)
chavy.log(`${cookieName} loginapp - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
function signapp() {
return new Promise((resolve, reject) => {
if (VAL_signurl.endsWith('.do')) VAL_signurl = VAL_signurl.replace('.do', '')
const url = {url: 'https://act.10010.com/SigninApp/signin/daySign', headers: JSON.parse(VAL_signheader)}
chavy.post(url, (error, response, data) => {
try {
signinfo.signapp = JSON.parse(data)
resolve()
} catch (e) {
chavy.msg(cookieName, `签到结果: 失败`, `说明: ${e}`)
chavy.log(`${cookieName} signapp - 签到失败: ${e}`)
chavy.log(`${cookieName} signapp - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
function loginlottery() {
return new Promise((resolve, reject) => {
const url = {url: VAL_loginlotteryurl, headers: JSON.parse(VAL_loginlotteryheader)}
chavy.get(url, (error, response, data) => {
try {
const encryptmobileMatch = data.match(/encryptmobile=([^('|")]*)/)
if (encryptmobileMatch) {
signinfo.encryptmobile = encryptmobileMatch[1]
} else {
chavy.msg(cookieName, `获取抽奖令牌: 失败`, `说明: ${e}`)
chavy.log(`${cookieName} loginlottery - 获取抽奖令牌失败: ${e}`)
chavy.log(`${cookieName} loginlottery - response: ${JSON.stringify(response)}`)
}
resolve()
} catch (e) {
chavy.msg(cookieName, `登录抽奖: 失败`, `说明: ${e}`)
chavy.log(`${cookieName} loginlottery - 登录抽奖失败: ${e}`)
chavy.log(`${cookieName} loginlottery - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
function findlottery() {
return new Promise((resolve, reject) => {
VAL_findlotteryurl = VAL_findlotteryurl.replace(/encryptmobile=[^(&|$)]*/, `encryptmobile=${signinfo.encryptmobile}`)
VAL_findlotteryurl = VAL_findlotteryurl.replace(/mobile=[^(&|$)]*/, `mobile=${signinfo.encryptmobile}`)
const url = {url: VAL_findlotteryurl, headers: JSON.parse(VAL_findlotteryheader)}
chavy.get(url, (error, response, data) => {
try {
signinfo.findlottery = JSON.parse(data)
resolve()
} catch (e) {
chavy.msg(cookieName, `获取抽奖次数: 失败`, `说明: ${e}`)
chavy.log(`${cookieName} findlottery - 获取抽奖次数失败: ${e}`)
chavy.log(`${cookieName} findlottery - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
function lottery() {
return new Promise((resolve, reject) => {
const url = {
url: `https://m.client.10010.com/dailylottery/static/doubleball/choujiang?usernumberofjsp=${signinfo.encryptmobile}`,
headers: JSON.parse(VAL_loginlotteryheader)
}
url.headers['Referer'] = `https://m.client.10010.com/dailylottery/static/doubleball/firstpage?encryptmobile=${signinfo.encryptmobile}`
chavy.post(url, (error, response, data) => {
try {
signinfo.lotterylist = signinfo.lotterylist ? signinfo.lotterylist : []
signinfo.lotterylist.push(JSON.parse(data))
resolve()
} catch (e) {
chavy.msg(cookieName, `抽奖结果: 失败`, `说明: ${e}`)
chavy.log(`${cookieName} lottery - 抽奖失败: ${e}`)
chavy.log(`${cookieName} lottery - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
function gettel() {
const reqheaders = JSON.parse(VAL_signheader)
const reqreferer = reqheaders.Referer
const reqCookie = reqheaders.Cookie
let tel = ''
if (reqreferer.indexOf(`desmobile=`) >= 0) tel = reqreferer.match(/desmobile=(.*?)(&|$)/)[1]
if (tel == '' && reqCookie.indexOf(`u_account=`) >= 0) tel = reqCookie.match(/u_account=(.*?);/)[1]
return tel
}
function getinfo() {
return new Promise((resolve, reject) => {
const url = {url: `https://mina.10010.com/wxapplet/bind/getIndexData/alipay/alipaymini?user_id=${gettel()}`}
chavy.get(url, (error, response, data) => {
try {
signinfo.info = JSON.parse(data)
resolve()
} catch (e) {
chavy.msg(cookieName, `获取余量: 失败`, `说明: ${e}`)
chavy.log(`${cookieName} getinfo - 获取余量失败: ${e}`)
chavy.log(`${cookieName} getinfo - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
function showmsg() {
let subTitle = ''
let detail = ''
// 签到结果
if (signinfo.signapp.signinMedal) {
subTitle = `签到: 成功`
detail = `积分: +${signinfo.signapp.prizeCount}, 成长值: +${signinfo.signapp.growthV}, 鲜花: +${signinfo.signapp.flowerCount}`
} else if (JSON.stringify(signinfo.signapp) == '{}') {
subTitle = `签到: 重复`
} else {
subTitle = `签到: 失败`
chavy.log(`${cookieName} signapp - response: ${JSON.stringify(signinfo.signapp)}`)
}
if (signinfo.info.code == '0000') {
// 基本信息
detail = detail ? `${detail}\n` : ``
const free = signinfo.info.dataList[0]
const flow = signinfo.info.dataList[1]
const voice = signinfo.info.dataList[2]
detail = `话费: ${free.number}${free.unit}, 已用: ${flow.number}${flow.unit}, 剩余: ${voice.number}${voice.unit}`
} else {
chavy.log(`${cookieName} signapp - response: ${JSON.stringify(signinfo.info)}`)
}
if (signinfo.findlottery && signinfo.findlottery.acFrequency && signinfo.lotterylist) {
subTitle += `; 抽奖: ${signinfo.findlottery.acFrequency.usableAcFreq}`
detail += '\n查看详情\n'
for (let i = 0; i < signinfo.findlottery.acFrequency.usableAcFreq; i++) {
detail += `\n抽奖 (${i + 1}): ${signinfo.lotterylist[i].RspMsg}`
}
} else {
chavy.log(`${cookieName} signapp - response: ${JSON.stringify(signinfo.findlottery)}`)
}
chavy.msg(cookieName, subTitle, detail)
}
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 (url['headers'] != undefined) {
delete url['headers']['Content-Length']
console.log(url['headers'])
}
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 (url['headers'] != undefined) {
delete url['headers']['Content-Length']
console.log(url['headers'])
}
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}
}

View File

@ -1,107 +0,0 @@
# 中国联通
> 代码已同时兼容 Surge & QuanX, 使用同一份签到脚本即可
> 注意获取 Cookie 有两条脚本
> 如果你希望显示话费、语音、流量信息,请在支付宝中搜索小程序“中国联通”并授权登录一次
> 2020.3.12 增加每日抽奖 (需要进抽奖页面获取 Cookie) (进抽奖页会弹两个获取 Cookie 成功的消息) (签到 Cookie 不用重新获取) (增加了 rewrite 和 mitm), 注意看操作步骤说明
> 2020.5.6 修复签到报错问题
## 配置 (Surge)
```properties
[MITM]
hostname = act.10010.com, m.client.10010.com
[Script]
# 注意获取Cookie有两条脚本
http-request ^https:\/\/act.10010.com\/SigninApp\/signin\/querySigninActivity.htm script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/10010/10010.cookie.js
http-request ^https:\/\/act.10010.com\/SigninApp(.*?)\/signin\/daySign script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/10010/10010.cookie.js
http-request ^https:\/\/m.client.10010.com\/dailylottery\/static\/(textdl\/userLogin|active\/findActivityInfo) script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/10010/10010.cookie.js
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/10010/10010.js
```
## 配置 (QuanX)
```properties
[MITM]
hostname = act.10010.com, m.client.10010.com
[rewrite_local]
# 注意获取Cookie有两条脚本
^https:\/\/act.10010.com\/SigninApp\/signin\/querySigninActivity.htm url script-request-header 10010.cookie.js
^https:\/\/act.10010.com\/SigninApp(.*?)\/signin\/daySign url script-request-header 10010.cookie.js
^https:\/\/m.client.10010.com\/dailylottery\/static\/(textdl\/userLogin|active\/findActivityInfo) url script-request-header 10010.cookie.js
[task_local]
1 0 * * * 10010.js
```
## 说明
1. 先把`act.10010.com, m.client.10010.com`加到`[MITM]`
2. 再配置重写规则:
- Surge: 把两条远程脚本放到`[Script]`
- QuanX: 把`10010.cookie.js`和`10010.js`传到`On My iPhone - Quantumult X - Scripts` (传到 iCloud 相同目录也可, 注意要打开 quanx 的 iCloud 开关)
3. 打开 APP , 进入签到页面, 系统提示: `获取刷新链接: 成功`
4. 然后手动签到 1 次, 系统提示: `获取Cookie: 成功 (每日签到)`
5. 首页>天天抽奖, 系统提示 `2` 次: `获取Cookie: 成功 (登录抽奖)``获取Cookie: 成功 (抽奖次数)`
6. 把获取 Cookie 的脚本注释掉
7. 运行一次脚本, 如果提示重复签到, 那就算成功了!
> 第 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)

View File

@ -1,68 +0,0 @@
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()

View File

@ -1,157 +0,0 @@
/**
*
* 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

View File

@ -1,97 +0,0 @@
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}
}

View File

@ -1,98 +0,0 @@
# 中国移动
> 代码已同时兼容 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)

View File

@ -1,101 +0,0 @@
# AcFun
# 此 Readme Copied From [@chavyleung](https://github.com/chavyleung/scripts/blob/master/wps/README.md)
> 代码已同时兼容 Surge & QuanX, 使用同一份签到脚本即可
> 只支持 APP 端签到 (什么? 你想用 Mac 签? emm...看需求人数吧...)
> 测试版有可能出现任何情况, 如虫子(bug)、cookie(有效期)等各种问题, 希望大家能抱着共同完善的心态来玩
> 2020.1.11 QuanX 在`190`版本开始, 获取 Cookie 方式需要从`script-response-body`改为`script-request-header`
## 配置 (Surge)
```properties
[MITM]
*.acfun.cn
[Script]
http-request ^https:\/\/api\-new\.app\.acfun\.cn\/rest\/app\/user\/personalInfo script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/acfun/acfun.cookie.js
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/acfun/acfun.js
```
## 配置 (QuanX)
```properties
[MITM]
*.acfun.cn
[rewrite_local]
# 189及以前版本
^https:\/\/api\-new\.app\.acfun\.cn\/rest\/app\/user\/personalInfo url script-response-body acfun.cookie.js
# 190及以后版本
^https:\/\/api\-new\.app\.acfun\.cn\/rest\/app\/user\/personalInfo url script-request-header acfun.cookie.js
[task_local]
1 0 * * * acfun.js
```
## 说明
1. 先把`*.acfun.cn`加到`[MITM]`
2. 再配置重写规则:
- Surge: 把两条远程脚本放到`[Script]`
- QuanX: 把`acfun.cookie.js`和`acfun.js`传到`On My iPhone - Quantumult X - Scripts` (传到 iCloud 相同目录也可, 注意要打开 quanx 的 iCloud 开关)
3. 打开 APP, 访问下`我的`
4. 系统提示: `获取Cookie: 成功` & `获取Token: 成功`(如果不提示获取成功, 尝试杀进程再进我的)
5. 最后就可以把第 1 条脚本注释掉了
> 第 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)

View File

@ -1,62 +0,0 @@
const cookieName = 'AcFun'
const cookieKey = 'chavy_cookie_acfun'
const tokenKey = 'chavy_token_acfun'
const chavy = init()
const cookieVal = $request.headers['Cookie']
const tokenVal = $request.headers['access_token']
if (cookieVal) {
if (chavy.setdata(cookieVal, cookieKey)) {
chavy.msg(`${cookieName}`, '获取Cookie: 成功', '')
chavy.log(`[${cookieName}] 获取Cookie: 成功, cookie: ${cookieVal}`)
}
if (chavy.setdata(tokenVal, tokenKey)) {
chavy.msg(`${cookieName}`, '获取Token: 成功', '')
chavy.log(`[${cookieName}] 获取Token: 成功, token: ${tokenVal}`)
}
}
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()

View File

@ -1,97 +0,0 @@
const cookieName = 'AcFun'
const cookieKey = 'chavy_cookie_acfun'
const tokenKey = 'chavy_token_acfun'
const chavy = init()
const cookieVal = chavy.getdata(cookieKey)
const tokenVal = chavy.getdata(tokenKey)
sign()
function sign() {
let url = {url: `https://api-new.acfunchina.com/rest/app/user/signIn`, headers: {Cookie: cookieVal}}
url.headers['access_token'] = `${tokenVal}`
url.headers['acPlatform'] = 'IPHONE'
url.headers['User-Agent'] = 'AcFun/6.14.2 (iPhone; iOS 13.3; Scale/2.00)'
url.body = `access_token=${cookieVal}`
chavy.post(url, (error, response, data) => {
const result = JSON.parse(data)
const title = `${cookieName}`
let subTitle = ``
let detail = ``
if (result.result == 0 || result.result == 122) {
getinfo(result)
} else {
subTitle = `签到结果: 失败`
detail = `编码: ${result.result}, 说明: ${result.error_msg}`
chavy.msg(title, subTitle, detail)
}
chavy.log(`${cookieName}, data: ${data}`)
})
chavy.done()
}
function getinfo(signresult) {
let url = {url: `https://api-new.acfunchina.com/rest/app/user/hasSignedIn`, headers: {Cookie: cookieVal}}
url.headers['access_token'] = `${tokenVal}`
url.headers['acPlatform'] = 'IPHONE'
url.headers['User-Agent'] = 'AcFun/6.14.2 (iPhone; iOS 13.3; Scale/2.00)'
url.body = `access_token=${cookieVal}`
chavy.post(url, (error, response, data) => {
const result = JSON.parse(data)
const title = `${cookieName}`
let subTitle = ``
let detail = ``
if (signresult.result == 0) {
subTitle = `签到结果: 成功`
} else if (signresult.result == 122) {
subTitle = `签到结果: 成功 (重复签到)`
}
detail = `共签: ${result.cumulativeDays}次, 连签: ${result.continuousDays}次, 说明: ${signresult.msg}`
chavy.msg(title, subTitle, detail)
chavy.log(`${cookieName}, data: ${data}`)
})
}
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}
}

View File

@ -1,87 +0,0 @@
# APK.TW
> 调整获取会话正则 (使用账号密码登录获取)
## 配置 (Surge)
```properties
[MITM]
apk.tw
[Script]
http-request ^https://apk.tw\/member.php(.*?)action=login script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/apktw/apktw.cookie.js,requires-body=true
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/apktw/apktw.js
```
## 配置 (QuanX)
```properties
[MITM]
apk.tw
[rewrite_local]
^https://apk.tw\/member.php(.*?)action=login url script-request-body apktw.cookie.js
[task_local]
1 0 * * * apktw.js
```
## 说明
1. 访问: `https://apk.tw/` (如果你已经登录, 请先注销)
2. 使用账号密码登录
3. 系统提示: `获取会话: 成功` (以登录成功后弹出的通知为准!)
> 第 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)

View File

@ -1,46 +0,0 @@
const $ = new Env('ApkTw')
!(async () => {
$.log('', `🔔 ${$.name}, 获取会话: 开始!`, '')
const session = {}
session.url = $request.url
session.body = $request.body
session.headers = $request.headers
delete session.headers['Content-Length']
delete session.headers['Cookie']
$.log('', `url: ${session.url}`, `body: ${session.body}`, `headers: ${JSON.stringify(session.headers)}`)
if ($.setdata(JSON.stringify(session), 'chavy_cookie_apktw')) {
$.subt = '获取会话: 成功!'
} else {
$.subt = '获取会话: 失败!'
}
})()
.catch((e) => {
$.subt = '获取会话: 失败!'
$.desc = `原因: ${e}`
$.log(`${$.name}, 获取会话: 失败! 原因: ${e}!`)
})
.finally(() => {
$.msg($.name, $.subt, $.desc), $.log('', `🔔 ${$.name}, 获取会话: 结束!`, ''), $.done()
})
// prettier-ignore
function Env(t) {
this.name = t, this.logs = [], this.isSurge = (() => "undefined" != typeof $httpClient), this.isQuanX = (() => "undefined" != typeof $task), this.log = ((...t) => {
this.logs = [...this.logs, ...t], t ? console.log(t.join("\n")) : console.log(this.logs.join("\n"))
}), this.msg = ((t = this.name, s = "", i = "") => {
this.isSurge() && $notification.post(t, s, i), this.isQuanX() && $notify(t, s, i);
const e = ["", "==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];
t && e.push(t), s && e.push(s), i && e.push(i), console.log(e.join("\n"))
}), this.getdata = (t => this.isSurge() ? $persistentStore.read(t) : this.isQuanX() ? $prefs.valueForKey(t) : void 0), this.setdata = ((t, s) => this.isSurge() ? $persistentStore.write(t, s) : this.isQuanX() ? $prefs.setValueForKey(t, s) : void 0), this.get = ((t, s) => this.send(t, "GET", s)), this.wait = ((t, s = t) => i => setTimeout(() => i(), Math.floor(Math.random() * (s - t + 1) + t))), this.post = ((t, s) => this.send(t, "POST", s)), this.send = ((t, s, i) => {
if (this.isSurge()) {
const e = "POST" == s ? $httpClient.post : $httpClient.get;
e(t, (t, s, e) => {
s && (s.body = e, s.statusCode = s.status), i(t, s, e)
})
}
this.isQuanX() && (t.method = s, $task.fetch(t).then(t => {
t.status = t.statusCode, i(null, t, t.body)
}, t => i(t.error, t, t)))
}), this.done = ((t = {}) => $done(t))
}

View File

@ -1,114 +0,0 @@
const $ = new Env('ApkTw')
$.VAL_login = $.getdata('chavy_cookie_apktw')
!(async () => {
$.log('', `🔔 ${$.name}, 开始!`, '')
await login()
await getHash()
await sign()
await showmsg()
})()
.catch((e) => {
$.log('', `${$.name}, 失败! 原因: ${e}!`, '')
})
.finally(() => {
$.msg($.name, $.subt, ''), $.log('', `🔔 ${$.name}, 结束!`, ''), $.done()
})
// 登录
function login() {
const url = JSON.parse($.VAL_login)
return new Promise((resove) => $.post(url, (error, response, data) => resove()))
}
function getHash() {
return new Promise((resove) => {
const url = {url: 'https://apk.tw/', headers: {}}
url.headers['Host'] = 'apk.tw'
url.headers['Referer'] = 'https://apk.tw/forum.php'
url.headers['Accept'] = '*/*'
url.headers['User-Agent'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.4 Safari/605.1.15'
$.get(url, (error, response, data) => {
try {
if (error) throw new Error(error)
if (/\/source\/plugin\/dsu_amupper\/images\/wb\.gif/.test(data)) {
$.isSigned = true
$.isSignSuc = true
} else {
$.isSigned = false
const [hash] = /plugin.php\?id=dsu_amupper:pper([^('|")]*)/.exec(data)
if (hash) {
$.hash = hash
} else {
$.isSignSuc = false
}
}
} catch (e) {
$.log(`❗️ ${$.name}, 执行失败!`, ` error = ${error || e}`, `response = ${JSON.stringify(response)}`, '')
} finally {
resove()
}
})
})
}
function sign() {
if ($.isSigned && !$.hash) return
return new Promise((resove) => {
const url = {url: `https://apk.tw/${$.hash}&inajax=1&ajaxtarget=my_amupper`, headers: {}}
$.log(`${url.url}!`)
url.headers['Host'] = 'apk.tw'
url.headers['Referer'] = 'https://apk.tw/forum.php'
url.headers['Accept'] = '*/*'
url.headers['User-Agent'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.4 Safari/605.1.15'
$.get(url, (error, response, data) => {
try {
if (error) throw new Error(error)
if (/\/source\/plugin\/dsu_amupper\/images\/wb\.gif/.test(data)) {
$.isSignSuc = true
} else {
$.isSignSuc = false
}
} catch (e) {
$.isSignSuc = false
$.log(`❗️ ${$.name}, 执行失败!`, ` error = ${error || e}`, `response = ${JSON.stringify(response)}`, '')
} finally {
resove()
}
})
})
}
function showmsg() {
return new Promise((resove) => {
if ($.isSigned) {
$.subt = '签到: 重复'
} else if (!$.isSigned && $.isSignSuc) {
$.subt = '签到: 成功'
} else {
$.subt = '签到: 失败'
}
resove()
})
}
// prettier-ignore
function Env(t) {
this.name = t, this.logs = [], this.isSurge = (() => "undefined" != typeof $httpClient), this.isQuanX = (() => "undefined" != typeof $task), this.log = ((...t) => {
this.logs = [...this.logs, ...t], t ? console.log(t.join("\n")) : console.log(this.logs.join("\n"))
}), this.msg = ((t = this.name, s = "", i = "") => {
this.isSurge() && $notification.post(t, s, i), this.isQuanX() && $notify(t, s, i);
const e = ["", "==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];
t && e.push(t), s && e.push(s), i && e.push(i), console.log(e.join("\n"))
}), this.getdata = (t => this.isSurge() ? $persistentStore.read(t) : this.isQuanX() ? $prefs.valueForKey(t) : void 0), this.setdata = ((t, s) => this.isSurge() ? $persistentStore.write(t, s) : this.isQuanX() ? $prefs.setValueForKey(t, s) : void 0), this.get = ((t, s) => this.send(t, "GET", s)), this.wait = ((t, s = t) => i => setTimeout(() => i(), Math.floor(Math.random() * (s - t + 1) + t))), this.post = ((t, s) => this.send(t, "POST", s)), this.send = ((t, s, i) => {
if (this.isSurge()) {
const e = "POST" == s ? $httpClient.post : $httpClient.get;
e(t, (t, s, e) => {
s && (s.body = e, s.statusCode = s.status), i(t, s, e)
})
}
this.isQuanX() && (t.method = s, $task.fetch(t).then(t => {
t.status = t.statusCode, i(null, t, t.body)
}, t => i(t.error, t, t)))
}), this.done = ((t = {}) => $done(t))
}

View File

@ -1,105 +0,0 @@
# 百词斩
> 参考 chavy 签到脚本制作的百词斩领取铜板的脚本
> 代码已同时兼容 Surge & QuanX, 使用同一份签到脚本即可
> 不需要手动编辑脚本 (获取 Cookie 和手机号码都由脚本自动完成)
> 感谢 [@GideonSenku](https://github.com/GideonSenku) PR
## 配置 (Surge)
```properties
[MITM]
group.baicizhan.com
[Script]
http-request ^https://group\.baicizhan\.com/group/rewards? script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/bcz/bcz.cookie.js
cron "0 50 23 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/bcz/bcz.js
```
## 配置 (QuanX)
```properties
[MITM]
group.baicizhan.com
[rewrite_local]
# 190及以后版本
^https://group\.baicizhan\.com/group/rewards? url script-request-header bcz.cookie.js
[task_local]
50 23 * * * bcz.js
```
## 说明
> 先在登录成功后, 再打开获取 Cookie 的脚本
1. 先配置`[MITM]`
- Surge&QuanX: group.baicizhan.com
2. 再配置重写规则:
- Surge: 把两条远程脚本放到`[Script]`
- QuanX: 把`bcz.cookie.js`和`bcz.js`传到`On My iPhone - Quantumult X - Scripts` (传到 iCloud 相同目录也可, 注意要打开 quanx 的 iCloud 开关)
3. 打开 APP 手动签到一次: 访问下右下角 `我` > `我的铜板` > `加入百词斩小班` > `去查看` > `我的小班进去 领铜板`
4. 系统提示: `获取Cookie: 成功`
5. 最后就可以把第 1 条脚本注释掉了
> 第 1 条脚本是用来获取 cookie 的, 用浏览器访问一次获取 cookie 成功后就可以删掉或注释掉了, 但请确保在`登录成功`后再获取 cookie.
> 第 2 条脚本是签到脚本, 每天`23:50`执行一次.
7. 也可将脚本的cron语法自行更改,如我设置成 `0 */4 * * *` 则每4小时可提醒我背单词
## 常见问题
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)
[@GideonSenku](https://github.com/GideonSenku)

View File

@ -1,64 +0,0 @@
const cookieName = '百词斩'
const cookieKey = 'senku_cookie_bcz'
const shareKey = 'senku_key_bcz'
const senku = init()
if (this.$request && this.$request.headers) {
const cookieVal = $request.headers['Cookie']
const url = $request.url
const index1 = url.indexOf('=')
const index2 = url.indexOf('&')
const shareVal = url.substring(index1 + 1, index2)
if (cookieVal && shareVal) {
if (senku.setdata(cookieVal, cookieKey) && senku.setdata(shareVal, shareKey)) {
senku.msg(`${cookieName}`, '获取Cookie: 成功', '')
senku.log(`[${cookieName}] 获取Cookie: 成功, cookie: ${cookieVal}`)
}
}
}
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}
}
senku.done()

View File

@ -1,83 +0,0 @@
const cookieName = '百词斩'
const cookieKey = 'senku_cookie_bcz'
const shareKey = 'senku_key_bcz'
const senku = init()
const cookieVal = senku.getdata(cookieKey)
const shareVal = senku.getdata(shareKey)
let signinfo = {}
senku.log()
check()
function check(cb) {
const url = {url: `https://group.baicizhan.com/group/apply_reward`, headers: {Cookie: cookieVal}}
url.headers['Content-Type'] = `text/plain;charset=utf-8`
url.headers['User-Agent'] = `Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/7.0.10(0x17000a21) NetType/4G Language/zh_CN`
const key = {share_key: shareVal}
url.body = JSON.stringify(key)
senku.log(url.body)
senku.post(url, (error, response, data) => {
signinfo = JSON.parse(data)
senku.log(JSON.stringify(signinfo))
const title = `${cookieName}`
let subTitle = ``
let detail = ''
if (signinfo.code == 1) {
if (signinfo.data.is_new) {
subTitle += `成功`
detail = `获取铜板数${signinfo.data.reward[2]}`
} else {
subTitle += `今天的铜板已经领取,但是单词还是可以继续背的`
}
} else {
detail = `状态: 还玩手机?快去背单词`
subTitle += '失败'
}
senku.msg(title, subTitle, detail)
senku.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.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}
}

View File

@ -1,240 +0,0 @@
/*
哔哩哔哩漫画, 积分商城自动抢购脚本
脚本兼容: Surge, QuantumultX, Loon
*************************
抢购脚本注意事项 :
*************************
该脚本需要使用签到脚本获取Cookie后方可使用.
默认兑换积分商城中的"积分兑换", 兑换数量为用户积分可兑换的最大值 (可于BoxJs内修改)
默认执行时间为中午12:00:1012:00:2012:00:30
BoxJs订阅地址: https://raw.githubusercontent.com/NobyDa/Script/master/NobyDa_BoxJs.json
*************************
Surge & Loon 脚本配置 :
*************************
[Script]
cron "10,20,30 0 12 * * *" script-path=https://raw.githubusercontent.com/NobyDa/Script/master/Bilibili-DailyBonus/ExchangePoints.js, wake-system=1, timeout=60
*************************
QX 1.0.10+ 脚本配置 :
*************************
[task_local]
10,20,30 0 12 * * * https://raw.githubusercontent.com/NobyDa/Script/master/Bilibili-DailyBonus/ExchangePoints.js, tag=哔哩哔哩漫画抢券, enabled=true
*/
// 新建一个实例对象, 把兼容函数定义到$中, 以便统一调用
let $ = new nobyda();
// 读取兑换商品名, 默认兑换积分商城中的"积分兑换"; 该接口为BoxJs预留, 以便修改
let productName = $.read('BM_ProductName') || '积分兑换';
// 读取兑换数量, 默认兑换最大值; 该接口为BoxJs预留, 以便修改
let productNum = $.read('BM_ProductNum');
// 读取循环抢购次数, 默认100次; 该接口为BoxJs预留, 以便修改
let exchangeNum = $.read('BM_ExchangeNum') || '100';
// 读取哔哩哔哩漫画签到脚本所使用的Cookie
let cookie = $.read('CookieBM');
// 预留的空对象, 便于函数之间读取数据
let user = {};
(async function() { // 立即运行的匿名异步函数
// 使用await关键字声明, 表示以同步方式执行异步函数, 可以简单理解为顺序执行
await Promise.all([ //该方法用于将多个实例包装成一个新的实例, 可以简单理解为同时调用函数, 以进一步提高执行速度
GetUserPoint(), //查询积分函数
ListProduct() //查询商品函数
]);
await ExchangeProduct(); //上面的查询都完成后, 则执行抢购
$.done(); //抢购完成后调用Surge、QX内部特有的函数, 用于退出脚本执行
})();
function GetUserPoint() {
const pointUrl = { //查询积分接口
url: 'https://manga.bilibili.com/twirp/pointshop.v1.Pointshop/GetUserPoint',
headers: { //请求头
'Cookie': cookie //用户鉴权Cookie
}
}
return new Promise((resolve) => { //主函数返回Promise实例对象, 以便后续调用时可以实现顺序执行异步函数
$.post(pointUrl, (error, resp, data) => { //使用post请求查询, 再使用回调函数处理返回的结果
try { //使用try方法捕获可能出现的代码异常
if (error) {
throw new Error(error); //如果请求失败, 例如无法联网, 则抛出一个异常
} else {
const body = JSON.parse(data); //解析响应体json并转化为对象
if (body.code == 0 && body.data) { //如果响应体为预期格式
user.point = parseInt(body.data.point); //把查询的积分赋值到全局变量user中
console.log(`\n当前积分: ${body.data.point}`); //打印日志
} else { //否则抛出一个异常
throw new Error(body.msg || data);
}
}
} catch (e) { //接住try代码块中抛出的异常, 并打印日志
console.log(`\n查询积分: 失败\n出现错误: ${e.message}`);
} finally { //finally语句在try和catch之后无论有无异常都会执行
resolve(); //异步操作成功时调用, 将Promise对象的状态标记为"成功", 表示已完成查询积分
}
})
})
}
function ListProduct() {
const listUrl = { //查询商品接口
url: 'https://manga.bilibili.com/twirp/pointshop.v1.Pointshop/ListProduct',
headers: {}
}
return new Promise((resolve) => { //主函数返回Promise实例对象, 以便后续调用时可以实现顺序执行异步函数
$.post(listUrl, (error, resp, data) => { //使用post请求查询, 再使用回调函数处理返回的结果
try { //使用try方法捕获可能出现的代码异常
if (error) {
throw new Error(error); //如果请求失败, 例如无法联网, 则抛出一个异常
} else {
const body = JSON.parse(data); //解析响应体json并转化为对象
if (body.code == 0 && body.data.length >= 1) { //如果接口正常返回商品信息
// 按全局变量所填写的商品名进行过滤, 并把商品信息赋值到全局变量user中
user.list = body.data.filter(t => t.title == productName).pop();
if (!user.list) {
throw new Error('请检查商品名'); //如果填错商品名则抛出一个异常
} else { //否则打印日志
console.log(`\n查询商品: ${productName}\n商品库存: ${user.list.remain_amount}`)
}
} else { //否则抛出一个异常
throw new Error('无商品列表');
}
}
} catch (e) { //接住try代码块中抛出的异常并打印日志
console.log(`\n查询商品: ${productName}\n出现错误: ${e.message}`);
} finally { //finally语句在try和catch之后无论有无异常都会执行
resolve(); //异步操作成功时调用, 将Promise对象的状态标记为"成功", 表示已完成查询商品
}
})
})
}
function ExchangeProduct() {
return new Promise(async (resolve) => { //主函数返回Promise实例对象, 以便后续调用时可以实现顺序执行异步函数, 该实例函数带有async关键字, 表示里面有异步操作, 例如可使用await得到异步结果
if (user.list && user.list.remain_amount && user.point >= 100) { //如果商品有库存并且用户积分大于100则进行抢购
//兑换商品数量(用户积分 除与 商品单价得到兑换数量), 并转成整数; 默认兑换最大数量
const num = parseInt(productNum || (user.point / user.list.real_cost));
const exchangeUrl = {
url: 'https://manga.bilibili.com/twirp/pointshop.v1.Pointshop/Exchange', //兑换商品接口
headers: { //请求头
'Content-Type': 'application/json', //声明请求体数据格式
'Cookie': cookie //用户鉴权Cookie
},
body: JSON.stringify({ //请求体转成字符串类型
product_id: user.list.id, //兑换的商品id
product_num: num, //兑换的商品数量
point: num * user.list.real_cost //消耗的积分总数 (兑换数量乘单价得到积分总数)
})
};
for (let i = 0; i < parseInt(exchangeNum); i++) { //根据全局变量定义的次数, 暴力循环抢购
// 循环内调用另一个抢购函数, 并传入请求、第几次循环、兑换数量等参数,
// 使用await关键字声明, 表示需要等待每一次的执行结果
const run = await startExchange(exchangeUrl, i, num);
if (run) {
break; //如果函数返回布尔值true, 则跳出循环, 脚本结束
}
}
} else { //商品无库存或用户积分小于100等情况, 则不执行抢购, 脚本结束
console.log(`\n抢购终止: 不具备兑换条件`); //打印日志
}
resolve(); //将主函数的Promise对象状态标记为"成功", 表示已完成抢购任务
})
}
function startExchange(url, item, amount) {
return new Promise((resolve) => { //主函数返回Promise实例对象, 以便后续调用时可以实现顺序执行异步函数
$.post(url, (error, resp, data) => { //使用post请求查询, 再使用回调函数处理返回的结果
try { //使用try方法捕获可能出现的代码异常
if (error) {
throw new Error(error); //如果请求失败, 例如无法联网, 则抛出一个异常
} else {
const body = JSON.parse(data); //解析响应体json并转化为对象
if (body.code == 0) { //如果抢购成功, 则输出日志和通知
console.log(`\n抢购成功: 第${item+1}\n抢购数量: ${amount}\n消耗积分: ${amount * user.list.real_cost}`);
$.notify('哔哩哔哩漫画抢券', '', `"${productName}"抢购成功, 数量: ${amount}, 消耗积分: ${amount * user.list.real_cost}`);
resolve(true); //将Promise对象的状态标记为"成功", 然后返回一个布尔值true用于跳出循环
} else {
throw new Error(body.msg || '未知'); //抢购失败则抛出异常
}
}
} catch (e) { //接住try代码块中抛出的异常并打印日志
console.log(`\n抢购失败: 第${item+1}\n失败原因: ${e.message}`);
resolve(); //将Promise对象的状态标记为"成功", 但不返回任何值, 表示继续循环抢购
}
})
})
}
function nobyda() {
const isSurge = typeof $httpClient != "undefined";
const isQuanX = typeof $task != "undefined";
const isNode = typeof require == "function";
const node = (() => {
if (isNode) {
const request = require('request');
return {
request
}
} else {
return null;
}
})()
const adapterStatus = (response) => {
if (response) {
if (response.status) {
response["statusCode"] = response.status
} else if (response.statusCode) {
response["status"] = response.statusCode
}
}
return response
}
this.read = (key) => {
if (isQuanX) return $prefs.valueForKey(key)
if (isSurge) return $persistentStore.read(key)
}
this.notify = (title, subtitle, message) => {
if (isQuanX) $notify(title, subtitle, message)
if (isSurge) $notification.post(title, subtitle, message)
if (isNode) console.log(`${title}\n${subtitle}\n${message}`)
}
this.post = (options, callback) => {
options.headers['User-Agent'] = 'User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 13_6_1 like Mac OS X) AppleWebKit/609.3.5.0.2 (KHTML, like Gecko) Mobile/17G80 BiliApp/822 mobi_app/ios_comic channel/AppStore BiliComic/822'
if (isQuanX) {
if (typeof options == "string") options = {
url: options
}
options["method"] = "POST"
$task.fetch(options).then(response => {
callback(null, adapterStatus(response), response.body)
}, reason => callback(reason.error, null, null))
}
if (isSurge) {
options.headers['X-Surge-Skip-Scripting'] = false
$httpClient.post(options, (error, response, body) => {
callback(error, adapterStatus(response), body)
})
}
if (isNode) {
node.request.post(options, (error, response, body) => {
callback(error, adapterStatus(response), body)
})
}
}
this.done = () => {
if (isQuanX || isSurge) {
$done()
}
}
};

File diff suppressed because one or more lines are too long

View File

@ -1,107 +0,0 @@
# bilibili
> 代码已同时兼容 Surge & QuanX, 使用同一份签到脚本即可
> 目前可签 bilibili 直播 (直播!直播!直播!) + 银瓜子转硬币
> 2020.1.11 QuanX 在`190`版本开始, 获取 Cookie 方式需要从`script-response-body`改为`script-request-header`
> 2020.3.16 添加银瓜子转硬币脚本 感谢[@lcandy2](https://github.com/lcandy2) PR
## 配置 (Surge)
```properties
[MITM]
*.bilibili.com
[Script]
http-request ^https:\/\/(www|live)\.bilibili\.com\/?.? script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/bilibili/bilibili.cookie.js
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/bilibili/bilibili.js
# 如需银瓜子转硬币,添加以下内容
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/bilibili/bilibili.silver2coin.js
```
## 配置 (QuanX)
```properties
[MITM]
*.bilibili.com
[rewrite_local]
# 189及以前版本
^https:\/\/(www|live)\.bilibili\.com\/?.? url script-response-body bilibili.cookie.js
# 190及以后版本
^https:\/\/(www|live)\.bilibili\.com\/?.? url script-request-header bilibili.cookie.js
[task_local]
1 0 * * * bilibili.js
# 如需银瓜子转硬币,添加以下内容
1 0 * * * bilibili.silver2coin.js
```
## 说明
1. 先在浏览器登录 `(先登录! 先登录! 先登录!)`
2. 先把`*.bilibili.com`加到`[MITM]`
3. 再配置重写规则:
- Surge: 把两条远程脚本放到`[Script]`
- QuanX: 把`bilibili.cookie.js`和`bilibili.js`传到`On My iPhone - Quantumult X - Scripts` (传到 iCloud 相同目录也可, 注意要打开 quanx 的 iCloud 开关)
4. 打开浏览器访问: https://www.bilibili.com 或 https://live.bilibili.com
5. 系统提示: `获取Cookie: 成功`
6. 最后就可以把第 1 条脚本注释掉了
> 第 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)
[@lcandy2](https://github.com/lcandy2)

View File

@ -1,56 +0,0 @@
const cookieName = 'bilibili'
const cookieKey = 'chavy_cookie_bilibili'
const chavy = init()
const cookieVal = $request.headers['Cookie']
if (cookieVal) {
if (chavy.setdata(cookieVal, cookieKey)) {
chavy.msg(`${cookieName}`, '获取Cookie: 成功', '')
chavy.log(`[${cookieName}] 获取Cookie: 成功, cookie: ${cookieVal}`)
}
}
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()

View File

@ -1,110 +0,0 @@
const cookieName = 'bilibili'
const cookieKey = 'chavy_cookie_bilibili'
const chavy = init()
const cookieVal = chavy.getdata(cookieKey)
sign()
function sign() {
let url = {
url: `https://api.live.bilibili.com/sign/doSign`,
headers: {
Cookie: cookieVal
}
}
url.headers['Origin'] = 'api.live.bilibili.com'
url.headers['Referer'] = 'http://live.bilibili.com/'
url.headers['Accept'] = 'application/json, text/javascript, */*; q=0.01'
url.headers['User-Agent'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.4 Safari/605.1.15'
chavy.get(url, (error, response, data) => {
let result = JSON.parse(data)
let title = `${cookieName}`
// 签到成功
if (result && result.code == 0) {
let subTitle = `签到结果: 成功`
let detail = `本月累计: ${result.data.hadSignDays}/${result.data.allDays}次, 说明: ${result.data.text}`
chavy.msg(title, subTitle, detail)
}
// 签到重复
else if (result && result.code == 1011040) {
getsigninfo()
}
// 签到失败
else {
let subTitle = `签到结果: 失败`
let detail = `说明: ${result.message}`
chavy.msg(title, subTitle, detail)
}
chavy.log(`${cookieName}, data: ${data}`)
})
chavy.done()
}
function getsigninfo() {
let url = {
url: `https://api.live.bilibili.com/sign/GetSignInfo`,
headers: {
Cookie: cookieVal
}
}
url.headers['Host'] = 'api.live.bilibili.com'
url.headers['Origin'] = 'http://live.bilibili.com'
url.headers['Referer'] = 'http://live.bilibili.com/'
url.headers['Accept'] = 'application/json, text/javascript, */*; q=0.01'
url.headers['User-Agent'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.4 Safari/605.1.15'
chavy.get(url, (error, response, data) => {
let title = `${cookieName}`
let subTitle = `签到结果: 成功 (重复签到)`
let detail = ``
let result = JSON.parse(data)
if (result && result.code == 0) detail = `本月累计: ${result.data.hadSignDays}/${result.data.allDays}次, 说明: ${result.data.text}`
chavy.msg(title, subTitle, detail)
})
}
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}
}

View File

@ -1,89 +0,0 @@
const cookieName = 'bilibili'
const cookieKey = 'chavy_cookie_bilibili'
const chavy = init()
const cookieVal = chavy.getdata(cookieKey)
sign()
function sign() {
let url = {
url: `https://api.live.bilibili.com/pay/v1/Exchange/silver2coin`,
headers: {
Cookie: cookieVal
}
}
url.headers['Origin'] = 'api.live.bilibili.com'
url.headers['Referer'] = 'http://live.bilibili.com/'
url.headers['Accept'] = 'application/json, text/javascript, */*; q=0.01'
url.headers['User-Agent'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.4 Safari/605.1.15'
chavy.get(url, (error, response, data) => {
let result = JSON.parse(data)
let title = `${cookieName} 银瓜子转硬币`
// 兑换成功
if (result && result.code == 0) {
let subTitle = `${result.message}`
let detail = `成功兑换: ${result.data.coin} 个硬币\n当前银瓜子: ${result.data.silver} , 当前金瓜子: ${result.data.gold}`
chavy.msg(title, subTitle, detail)
}
// 兑换中止(重复兑换&银瓜子不足)
else if (result && result.code == 403) {
let subTitle = `未成功兑换`
let detail = `${result.message}`
chavy.msg(title, subTitle, detail)
}
// 兑换失败
else {
let subTitle = `兑换失败`
let detail = `说明: ${result.message}`
chavy.msg(title, subTitle, detail)
}
chavy.log(`${cookieName}, data: ${data}`)
})
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.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}
}

View File

@ -1,275 +0,0 @@
{
"id": "chavyleung.app.sub",
"name": "chavyleung应用订阅",
"author": "@chavyleung",
"icon": "https://avatars3.githubusercontent.com/u/29748519?s=460&u=392a19e85465abbcb1791c9b8b32184a16e6795e&v=4",
"repo": "https://github.com/chavyleung/scripts",
"apps": [
{
"id": "10000",
"name": "10000",
"keys": [],
"settings": [
{
"id": "chavy_mobile_10000",
"name": "手机号码",
"val": "",
"type": "textarea",
"placeholder": "18918920000,\n18918920000",
"autoGrow": true,
"rows": 5,
"desc": "以英文逗号分隔多个号码, 可加回车"
}
],
"author": "@wangfei021325, @chavyleung",
"repo": "https://github.com/chavyleung/scripts/blob/master/10000/10000.js",
"icons": [
"https://raw.githubusercontent.com/Orz-3/mini/master/10000.png",
"https://raw.githubusercontent.com/Orz-3/task/master/10000.png"
]
},
{
"id": "chavyleung.10086",
"name": "10086",
"keys": [
"chavy_autologin_cmcc",
"chavy_getfee_cmcc",
"chavy_tokenurl_10086",
"chavy_tokenheader_10086",
"chavy_signurl_10086",
"chavy_signheader_10086"
],
"author": "@wangfei021325, @chavyleung",
"repo": "https://github.com/chavyleung/scripts/blob/master/10086/10086.js",
"icons": [
"https://raw.githubusercontent.com/Orz-3/mini/master/10086.png",
"https://raw.githubusercontent.com/Orz-3/task/master/10086.png"
]
},
{
"id": "chavyleung.suning",
"name": "苏宁易购",
"keys": [
"chavy_login_url_suning",
"chavy_login_body_suning",
"chavy_login_header_suning",
"chavy_sign_url_suning",
"chavy_sign_header_suning",
"chavy_signweb_url_suning",
"snyg_userTokenKey",
"chavy_signweb_header_suning",
"chavy_signgame_url_suning",
"chavy_signgame_header_suning",
"chavy_signgetgame_url_suning",
"chavy_signgetgame_header_suning"
],
"author": "@chavyleung",
"repo": "https://github.com/chavyleung/scripts/blob/master/suning/suning.js",
"icons": [
"https://raw.githubusercontent.com/Orz-3/mini/master/suning.png",
"https://raw.githubusercontent.com/Orz-3/task/master/suning.png"
]
},
{
"id": "chavyleung.bilibili.live",
"name": "bilibili直播",
"keys": [
"chavy_cookie_bilibili"
],
"author": "@chavyleung",
"repo": "https://github.com/chavyleung/scripts/blob/master/bilibili/bilibili.js",
"icons": [
"https://raw.githubusercontent.com/Orz-3/mini/master/bilibili.png",
"https://raw.githubusercontent.com/Orz-3/task/master/bilibili.png"
]
},
{
"id": "chavyleung.meituan",
"name": "美团",
"keys": [
"chavy_tokenurl_meituan",
"chavy_tokenheader_meituan",
"chavy_signurl_meituan",
"chavy_signheader_meituan",
"chavy_signbody_meituan"
],
"author": "@chavyleung",
"repo": "https://github.com/chavyleung/scripts/blob/master/meituan/meituan.js",
"icons": [
"https://raw.githubusercontent.com/Orz-3/mini/master/meituan.png",
"https://raw.githubusercontent.com/Orz-3/task/master/meituan.png"
]
},
{
"id": "chavyleung.mgtv",
"name": "芒果TV",
"keys": [
"chavy_signurl_mgtv",
"chavy_signheader_mgtv"
],
"author": "@chavyleung",
"repo": "https://github.com/chavyleung/scripts/blob/master/mgtv/mgtv.js",
"icons": [
"https://raw.githubusercontent.com/Orz-3/mini/master/mgtv.png",
"https://raw.githubusercontent.com/Orz-3/task/master/mgtv.png"
]
},
{
"id": "gdoil",
"name": "加油广东",
"keys": [
"chavy_signurl_gdoil",
"chavy_signheader_gdoil"
],
"author": "@chavyleung",
"repo": "https://github.com/chavyleung/scripts/tree/master/gdoil",
"icons": [
"https://raw.githubusercontent.com/Orz-3/mini/master/gdoil.png",
"https://raw.githubusercontent.com/Orz-3/task/master/gdoil.png"
]
},
{
"id": "feng",
"name": "威锋网",
"settings": [
{
"id": "chavy_accounts_feng",
"name": "威锋账号",
"val": "",
"type": "textarea",
"placeholder": "账号,密码 (回车) 账号,密码",
"autoGrow": true,
"rows": 5,
"desc": "以英文逗号分隔账号与密码, 回车添加多个账号"
}
],
"keys": [],
"author": "@chavyleung",
"repo": "https://github.com/chavyleung/scripts/tree/master/feng",
"icons": [
"https://raw.githubusercontent.com/Orz-3/mini/master/feng.png",
"https://raw.githubusercontent.com/Orz-3/task/master/feng.png"
]
},
{
"id": "wanda",
"name": "万达电影",
"keys": [
"senku_wanda_mi_"
],
"author": "@GideonSenku",
"repo": "https://github.com/chavyleung/scripts/tree/master/wanda",
"icons": [
"https://raw.githubusercontent.com/Orz-3/mini/master/wanda.png",
"https://raw.githubusercontent.com/Orz-3/task/master/wanda.png"
]
},
{
"id": "qtt",
"name": "趣头条",
"keys": [
"senku_signKey_qtt",
"senku_signXTK_qtt",
"senku_readKey_qtt",
"senku_navCoinKey_qtt"
],
"author": "@GideonSenku",
"repo": "https://github.com/chavyleung/scripts/tree/master/qtt",
"icons": [
"https://raw.githubusercontent.com/Orz-3/mini/master/qtt.png",
"https://raw.githubusercontent.com/Orz-3/task/master/qtt.png"
]
},
{
"id": "qmkg",
"name": "全民K歌",
"keys": [
"senku_signurl_qmkg",
"senku_signheader_qmkg",
"senku_signbody_qmkg"
],
"author": "@GideonSenku",
"repo": "https://github.com/chavyleung/scripts/tree/master/qmkg",
"icons": [
"https://raw.githubusercontent.com/Orz-3/mini/master/qmkg.png",
"https://raw.githubusercontent.com/Orz-3/task/master/qmkg.png"
]
},
{
"id": "bcz",
"name": "百词斩",
"keys": [
"senku_cookie_bcz",
"senku_key_bcz"
],
"author": "@GideonSenku",
"repo": "https://github.com/chavyleung/scripts/tree/master/bcz",
"icons": [
"https://raw.githubusercontent.com/Orz-3/mini/master/bcz.png",
"https://raw.githubusercontent.com/Orz-3/task/master/bcz.png"
]
},
{
"id": "zxhc",
"name": "智行火车票",
"keys": [
"senku_signurl_zxhc",
"senku_signheader_zxhc",
"senku_signbody_zxhc"
],
"author": "@GideonSenku",
"repo": "https://github.com/chavyleung/scripts/tree/master/zxhc",
"icons": [
"https://raw.githubusercontent.com/Orz-3/mini/master/zxhc.png",
"https://raw.githubusercontent.com/Orz-3/task/master/zxhc.png"
]
},
{
"id": "fenqile",
"name": "分期乐",
"keys": [
"senku_signurl_fenqile",
"senku_signheader_fenqile",
"senku_signbody_fenqile",
"senku_signDailyKey_fenqile",
"senku_signDailyUrlKey_fenqile"
],
"author": "@GideonSenku",
"repo": "https://github.com/chavyleung/scripts/tree/master/fenqile",
"icons": [
"https://raw.githubusercontent.com/Orz-3/mini/master/fenqile.png",
"https://raw.githubusercontent.com/Orz-3/task/master/fenqile.png"
]
},
{
"id": "fandeng",
"name": "樊登读书",
"keys": [
"senku_signurl_pandeng",
"senku_signheader_pandeng",
"senku_signbody_pandeng"
],
"author": "@GideonSenku",
"repo": "https://github.com/chavyleung/scripts/tree/master/fandeng",
"icons": [
"https://raw.githubusercontent.com/Orz-3/mini/master/fandeng.png",
"https://raw.githubusercontent.com/Orz-3/task/master/fandeng.png"
]
},
{
"id": "dbsj",
"name": "豆瓣时间",
"keys": [
"senku_signurl_dbsj",
"senku_signheader_dbsj",
"senku_signbody_dbsj"
],
"author": "@GideonSenku",
"repo": "https://github.com/chavyleung/scripts/tree/master/dbsj",
"icons": [
"https://raw.githubusercontent.com/Orz-3/mini/master/dbsj.png",
"https://raw.githubusercontent.com/Orz-3/task/master/dbsj.png"
]
}
]
}

View File

@ -1,127 +0,0 @@
{
"releases": [
{
"version": "0.3.1",
"tags": [
"beta"
],
"author": "@chavyleung",
"icon": "https://avatars3.githubusercontent.com/u/29748519",
"repo": "https://github.com/chavyleung",
"notes": [
{
"name": "修复",
"descs": [
"手动切换会话会导致自动切换顺序错误问题"
]
}
]
},
{
"version": "0.3.0",
"tags": [
"beta"
],
"author": "@chavyleung",
"icon": "https://avatars3.githubusercontent.com/u/29748519",
"repo": "https://github.com/chavyleung",
"notes": [
{
"name": "新增",
"descs": [
"全局搜索"
]
}
]
},
{
"version": "0.2.4",
"tags": [
"beta"
],
"author": "@chavyleung",
"icon": "https://avatars3.githubusercontent.com/u/29748519",
"repo": "https://github.com/chavyleung",
"notes": [
{
"name": "优化",
"descs": [
"帮助页面样式",
"订阅链接多余空格&换行等字符"
]
}
]
},
{
"version": "0.2.2",
"tags": [
"beta"
],
"author": "@chavyleung",
"icon": "https://avatars3.githubusercontent.com/u/29748519",
"repo": "https://github.com/chavyleung",
"notes": [
{
"name": "优化",
"descs": [
"悬浮按钮刷新不用确认",
"侧栏可以隐藏帮助按钮"
]
}
]
},
{
"version": "0.2.1",
"tags": [
"beta"
],
"author": "@chavyleung",
"icon": "https://avatars3.githubusercontent.com/u/29748519",
"repo": "https://github.com/chavyleung",
"notes": [
{
"name": "新增",
"descs": [
"可以设置悬浮按钮的位置"
]
}
]
},
{
"version": "0.2.0",
"tags": [
"beta"
],
"author": "@chavyleung",
"icon": "https://avatars3.githubusercontent.com/u/29748519",
"repo": "https://github.com/chavyleung",
"notes": [
{
"name": "新增",
"descs": [
"版本更新提醒",
"BoxJs升级教程"
]
}
]
},
{
"version": "0.1.3",
"tags": [
"beta"
],
"author": "@chavyleung",
"icon": "https://avatars3.githubusercontent.com/u/29748519",
"repo": "https://github.com/chavyleung",
"notes": [
{
"name": "新增",
"descs": [
"长文本控件",
"读写表达式"
]
}
]
}
]
}

View File

@ -1,236 +0,0 @@
const $ = new Env('会话切换')
$.KEY_sessions = 'chavy_boxjs_sessions'
$.KEY_curSessions = 'chavy_boxjs_cur_sessions'
$.CFG_isSilent = $.getdata('CFG_BoxSwitcher_isSilent')
!(async () => {
await execSwitch()
await showmsg()
})()
.catch((e) => $.logErr(e))
.finally(() => $.done())
function execSwitch() {
$.subt = ''
$.desc = []
return new Promise((resove) => {
const sessions = getSessions()
const curSessions = getCurSessions()
// 会话排序: `创建时间`升序
sessions.sort((a, b) => a.createTime.replace(/-|:| /g, '') - b.createTime.replace(/-|:| /g, ''))
const apps = {}
sessions.forEach((session) => {
const appId = session.appId
const appName = session.appName
apps[appId] = apps[appId] ? apps[appId] : {id: appId, name: appName, sessions: []}
const app = apps[appId]
app.sessions.push(session)
})
Object.keys(apps).forEach((appId) => {
const app = apps[appId]
if (app.sessions.length <= 1) {
$.desc.push(`${app.name}: 跳过! 原因: 只有 1 个会话?`)
return true
}
let curSessionIdx = app.sessions.findIndex((session) => session.id === curSessions[appId])
if (curSessionIdx === -1) {
curSessionIdx = app.sessions.length - 1
}
const curSession = app.sessions[curSessionIdx]
const isNewRound = curSessionIdx + 1 === app.sessions.length
const nextSessionIdx = isNewRound ? 0 : curSessionIdx + 1
const nextSession = app.sessions[nextSessionIdx]
nextSession.datas.forEach((_data) => $.setdata([undefined, null, 'undefined', 'null', ''].includes(_data.val) ? '' : _data.val, _data.key))
curSessions[appId] = nextSession.id
$.desc.push(`${curSession.appName}: ${curSession.name} => #${nextSessionIdx + 1} ${nextSession.name} ${isNewRound ? '(新一轮)' : ''}`)
})
$.setdata(JSON.stringify(curSessions), $.KEY_curSessions)
resove()
})
}
function getSessions() {
const sessionstr = $.getdata($.KEY_sessions)
const sessions = ![undefined, null, 'null', ''].includes(sessionstr) ? JSON.parse(sessionstr) : []
return Array.isArray(sessions) ? sessions : []
}
function getCurSessions() {
const sessionstr = $.getdata($.KEY_curSessions)
return ![undefined, null, 'null', ''].includes(sessionstr) ? JSON.parse(sessionstr) : {}
}
function showmsg() {
return new Promise((resove) => {
if (!$.CFG_isSilent || $.CFG_isSilent === 'false') {
$.msg($.name, $.subt, $.desc.join('\n'))
} else {
$.log('', ...$.desc)
}
resove()
})
}
// 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), o = JSON.stringify(this.data);
e ? this.fs.writeFileSync(t, o) : i ? this.fs.writeFileSync(s, o) : this.fs.writeFileSync(t, o)
}
}
lodash_get(t, s, e) {
const i = s.replace(/\[(\d+)\]/g, ".$1").split(".");
let o = t;
for (const t of i) if (o = Object(o)[t], void 0 === o) return e;
return o
}
lodash_set(t, s, e) {
return Object(t) !== t ? t : (Array.isArray(s) || (s = s.toString().match(/[^.[\]]+/g) || []), s.slice(0, -1).reduce((t, e, i) => Object(t[e]) === t[e] ? t[e] : t[e] = Math.abs(s[i + 1]) >> 0 == +s[i + 1] ? [] : {}, t)[s[s.length - 1]] = e, t)
}
getdata(t) {
let s = this.getval(t);
if (/^@/.test(t)) {
const [, e, i] = /^@(.*?)\.(.*?)$/.exec(t), o = e ? this.getval(e) : "";
if (o) try {
const t = JSON.parse(o);
s = t ? this.lodash_get(t, i, "") : s
} catch (t) {
s = ""
}
}
return s
}
setdata(t, s) {
let e = !1;
if (/^@/.test(s)) {
const [, i, o] = /^@(.*?)\.(.*?)$/.exec(s), h = this.getval(i),
a = i ? "null" === h ? null : h || "{}" : "{}";
try {
const s = JSON.parse(a);
this.lodash_set(s, o, t), e = this.setval(JSON.stringify(s), i), console.log(`${i}: ${JSON.stringify(s)}`)
} catch {
const s = {};
this.lodash_set(s, o, t), e = this.setval(JSON.stringify(s), i), console.log(`${i}: ${JSON.stringify(s)}`)
}
} else e = $.setval(t, s);
return e
}
getval(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
}
setval(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
}
initGotEnv(t) {
this.got = this.got ? this.got : require("got"), this.cktough = this.cktough ? this.cktough : require("tough-cookie"), this.ckjar = this.ckjar ? this.ckjar : new this.cktough.CookieJar, t && (t.headers = t.headers ? t.headers : {}, void 0 === t.headers.Cookie && void 0 === t.cookieJar && (t.cookieJar = this.ckjar))
}
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: o, body: h} = t;
s(null, {status: e, statusCode: i, headers: o, body: h}, h)
}, t => s(t)) : this.isNode() && (this.initGotEnv(t), this.got(t).on("redirect", (t, s) => {
try {
const e = t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();
this.ckjar.setCookieSync(e, null), s.cookieJar = this.ckjar
} catch (t) {
this.logErr(t)
}
}).then(t => {
const {statusCode: e, statusCode: i, headers: o, body: h} = t;
s(null, {status: e, statusCode: i, headers: o, body: h}, h)
}, 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: o, body: h} = t;
s(null, {status: e, statusCode: i, headers: o, body: h}, h)
}, t => s(t)); else if (this.isNode()) {
this.initGotEnv(t);
const {url: e, ...i} = t;
this.got.post(e, i).then(t => {
const {statusCode: e, statusCode: i, headers: o, body: h} = t;
s(null, {status: e, statusCode: i, headers: o, body: h}, h)
}, t => s(t))
}
}
msg(s = t, e = "", i = "", o) {
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)
}

View File

@ -1,104 +0,0 @@
# 不背单词
> 代码已同时兼容 Surge & QuanX, 使用同一份签到脚本即可
> 感谢[@danchaw](https://github.com/danchaw) PR
## 配置 (Surge)
```properties
[MITM]
sapi.beingfine.cn
[Script]
http-request ^https:\/\/sapi\.beingfine\.cn\/v3\/bb\/reward\/by-sign-in script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/bubei/bubei.js
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/bubei/bubei.js
```
## 配置 (QuanX)
```properties
[MITM]
sapi.beingfine.cn
[rewrite_local]
# [商店版]
^https:\/\/sapi\.beingfine\.cn\/v3\/bb\/reward\/by-sign-in url script-request-header bubei.js
# [TestFlight]
^https:\/\/sapi\.beingfine\.cn\/v3\/bb\/reward\/by-sign-in url script-request-header https://raw.githubusercontent.com/chavyleung/scripts/master/bubei/bubei.js
[task_local]
# [商店版]
1 0 * * * bubei.js
# [TestFlight]
1 0 * * * https://raw.githubusercontent.com/chavyleung/scripts/master/bubei/bubei.js
```
## 说明
1. 先把`sapi.beingfine.cn`加到`[MITM]`
2. 再配置重写规则:
- Surge: 把两条远程脚本放到`[Script]`
- QuanX: 把`bubei.js`传到`On My iPhone - Quantumult X - Scripts` (传到 iCloud 相同目录也可, 注意要打开 quanx 的 iCloud 开关)
3. 打开 APP[不背单词](https://apps.apple.com/cn/app/%E4%B8%8D%E8%83%8C%E5%8D%95%E8%AF%8D-%E7%9C%9F%E5%AE%9E%E8%AF%AD%E5%A2%83%E5%AD%A6%E8%8B%B1%E8%AF%AD%E5%8D%95%E8%AF%8D/id698570469) 然后手动签到 1 次, 系统提示: `首次写入不背单词Url成功🎉`和`首次写入不背单词Cookie成功🎉`
4. 最后就可以把第 1 条脚本注释掉了
5. 运行一次脚本, 如果提示说明:aceess_denied#30103, 那就算成功了!
> 第 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)
[@danchaw](https://github.com/danchaw)

View File

@ -1,142 +0,0 @@
var appName = '不背单词'
var bubei = init()
var URL = bubei.getdata("UrlBB")
var KEY = bubei.getdata("CookieBB")
let isGetCookie = typeof $request !== 'undefined'
if (isGetCookie) {
getcookie()
} else {
sign()
}
function getcookie() {
var url = $request.url;
if (url) {
var UrlKeyBB = "UrlBB";
var UrlValueBB = url;
if (bubei.getdata(UrlKeyBB) != (undefined || null)) {
if (bubei.getdata(UrlKeyBB) != UrlValueBB) {
var url = bubei.setdata(UrlValueBB, UrlKeyBB);
if (!url) {
bubei.msg("更新" + appName + "Url失败‼", "", "");
} else {
bubei.msg("更新" + appName + "Url成功🎉", "", "");
}
} else {
bubei.msg(appName + "Url未变化❗", "", "");
}
} else {
var url = bubei.setdata(UrlValueBB, UrlKeyBB);
if (!url) {
bubei.msg("首次写入" + appName + "Url失败‼", "", "");
} else {
bubei.msg("首次写入" + appName + "Url成功🎉", "", "");
}
}
} else {
bubei.msg("写入" + appName + "Url失败‼", "", "配置错误, 无法读取URL, ");
}
if ($request.headers) {
var CookieKeyBB = "CookieBB";
var CookieValueBB = JSON.stringify($request.headers);
if (bubei.getdata(CookieKeyBB) != (undefined || null)) {
if (bubei.getdata(CookieKeyBB) != CookieValueBB) {
var cookie = bubei.setdata(CookieValueBB, CookieKeyBB);
if (!cookie) {
bubei.msg("更新" + appName + "Cookie失败‼", "", "");
} else {
bubei.msg("更新" + appName + "Cookie成功🎉", "", "");
}
} else {
bubei.msg(appName + "Cookie未变化❗", "", "");
}
} else {
var cookie = bubei.setdata(CookieValueBB, CookieKeyBB);
if (!cookie) {
bubei.msg("首次写入" + appName + "Cookie失败‼", "", "");
} else {
bubei.msg("首次写入" + appName + "Cookie成功🎉", "", "");
}
}
} else {
bubei.msg("写入" + appName + "Cookie失败‼", "", "配置错误, 无法读取请求头, ");
}
bubei.done()
}
function sign() {
var t1 = new Date().getTime()
var t2 = t1 + 1
URL = URL.replace(/by-sign-in\/\d*/g, "by-sign-in/" + t1).replace(/timestamp=\d*/g, "timestamp=" + t2)
const url = {url: URL, headers: JSON.parse(KEY)}
bubei.get(url, (error, response, data) => {
bubei.log(`${appName}, data: ${data}`)
const title = `${appName}`
let subTitle = ''
let detail = ''
const result = JSON.parse(data)
if (result.result_code == 200) {
subTitle = `签到结果: 成功`
} else {
subTitle = `签到结果: 未知`
detail = `说明: ${result.error_body.user_msg}`
}
bubei.msg(title, subTitle, detail)
bubei.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.body))
}
}
post = (url, cb) => {
if (isSurge()) {
$httpClient.post(url, cb)
}
if (isQuanX()) {
url.method = 'POST'
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
}
}
put = (url, cb) => {
if (isSurge()) {
$httpClient.put(url, cb)
}
if (isQuanX()) {
url.method = 'PUT'
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
}
}
done = (value = {}) => {
$done(value)
}
return {isSurge, isQuanX, msg, log, getdata, setdata, get, post, put, done}
}

View File

@ -1,102 +0,0 @@
# CSDN
> 代码已同时兼容 Surge & QuanX, 使用同一份签到脚本即可
> 2020.3.11 更新获取刷新链接正则 (更新后打开 App 即可获取刷新链接, 无需重新获取 Cookie)
> 2020.3.12 增加自动抽奖 (如果有抽奖机会的话) (无需重新获取 Cookie)
> 2020.3.12 如果发现无法签到 (后台日志报错), 注销一下 csdn 账号重新登录, 再重新获取下刷新链接
## 配置 (Surge)
```properties
[MITM]
*.csdn.net
[Script]
# 注意获取Cookie有两条脚本
http-request ^https:\/\/passport.csdn.net\/v2\/api\/app\/login\/checkAndRefreshToken script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/csdn/csdn.cookie.js
http-request ^https:\/\/gw.csdn.net\/mini-app\/v2\/lucky_draw\/login\/sign_in\? script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/csdn/csdn.cookie.js
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/csdn/csdn.js
```
## 配置 (QuanX)
```properties
[MITM]
*.csdn.net
[rewrite_local]
# 注意获取Cookie有两条脚本
^https:\/\/passport.csdn.net\/v2\/api\/app\/login\/checkAndRefreshToken url script-request-header csdn.cookie.js
^https:\/\/gw.csdn.net\/mini-app\/v2\/lucky_draw\/login\/sign_in\? url script-request-header csdn.cookie.js
[task_local]
1 0 * * * csdn.js
```
## 说明
1. 先把`*.csdn.net`加到`[MITM]`
2. 再配置重写规则:
- Surge: 把两条远程脚本放到`[Script]`
- QuanX: 把`csdn.cookie.js`和`csdn.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)

View File

@ -1,71 +0,0 @@
const cookieName = 'CSDN'
const tokenurlKey = 'chavy_tokenurl_csdn'
const tokenheaderKey = 'chavy_tokenheader_csdn'
const signurlKey = 'chavy_signurl_csdn'
const signheaderKey = 'chavy_signheader_csdn'
const chavy = init()
let title = ``
let detail = ``
if ($request && $request.method != 'OPTIONS' && $request.headers.Host == 'passport.csdn.net') {
const tokenurlVal = $request.url
const tokenheaderVal = JSON.stringify($request.headers)
if (tokenurlVal) chavy.setdata(tokenurlVal, tokenurlKey)
if (tokenheaderVal) chavy.setdata(tokenheaderVal, tokenheaderKey)
title = `获取刷新链接: 成功`
detail = `请进入 "我的>签到" 并手动签到1次`
chavy.msg(`${cookieName}`, title, detail)
} else if ($request && $request.method != 'OPTIONS' && $request.headers.Host == 'gw.csdn.net') {
const signurlVal = $request.url
const signheaderVal = JSON.stringify($request.headers)
if (signurlVal) chavy.setdata(signurlVal, signurlKey)
if (signheaderVal) chavy.setdata(signheaderVal, signheaderKey)
title = `获取Cookie: 成功 (手动签到)`
chavy.msg(`${cookieName}`, title, detail)
}
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()

View File

@ -1,206 +0,0 @@
const chavy = init()
const cookieName = 'CSDN'
const KEY_loginurl = 'chavy_tokenurl_csdn'
const KEY_loginheader = 'chavy_tokenheader_csdn'
const KEY_signurl = 'chavy_signurl_csdn'
const KEY_signheader = 'chavy_signheader_csdn'
const signinfo = {}
let VAL_loginurl = chavy.getdata(KEY_loginurl)
let VAL_loginheader = chavy.getdata(KEY_loginheader)
let VAL_signurl = chavy.getdata(KEY_signurl)
let VAL_signheader = chavy.getdata(KEY_signheader)
;(sign = async () => {
chavy.log(`🔔 ${cookieName}`)
await loginapp()
await signapp()
await getlucky()
for (let i = 0; i < signinfo.lucky.data.drawTimes; i++) {
await luckyapp()
}
showmsg()
chavy.done()
})().catch((e) => chavy.log(`${cookieName} 签到失败: ${e}`), chavy.done())
function loginapp() {
return new Promise((resolve, reject) => {
const url = {url: VAL_loginurl, headers: JSON.parse(VAL_loginheader)}
chavy.get(url, (error, response, data) => {
try {
signinfo.loginapp = JSON.parse(data)
updateSignAppCookies()
resolve()
} catch (e) {
chavy.msg(cookieName, `登录结果: 失败`, `说明: ${e}`)
chavy.log(`${cookieName} loginapp - 登录失败: ${e}`)
chavy.log(`${cookieName} loginapp - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
function updateSignAppCookies() {
if (signinfo.loginapp) {
const signheaderObj = JSON.parse(VAL_signheader)
signheaderObj['JWT-TOKEN'] = signinfo.loginapp.data.token
signheaderObj['Cookie'] = signheaderObj['Cookie'].replace(/JWT-TOKEN=[^;]*/, `JWT-TOKEN=${signinfo.loginapp.data.token}`)
VAL_signheader = JSON.stringify(signheaderObj)
} else {
chavy.log(`${cookieName} updateSignAppCookies: 请先获取 Cookies`)
}
}
function signapp() {
return new Promise((resolve, reject) => {
const url = {url: VAL_signurl, body: '{}', headers: JSON.parse(VAL_signheader)}
chavy.post(url, (error, response, data) => {
try {
signinfo.signapp = JSON.parse(data)
resolve()
} catch (e) {
chavy.msg(cookieName, `签到结果: 失败`, `说明: ${e}`)
chavy.log(`${cookieName} signapp - 签到失败: ${e}`)
chavy.log(`${cookieName} signapp - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
function getlucky() {
return new Promise((resolve, reject) => {
const VAL_getluckyurl = `https://gw.csdn.net/mini-app/v2/lucky_draw/login/sign_info?projectVersion=1.0.0`
const url = {url: VAL_getluckyurl, headers: JSON.parse(VAL_signheader)}
delete url.headers['Content-Length']
url.headers['Connection'] = 'keep-alive'
url.headers['Accept-Encoding'] = 'gzip, deflate, br'
url.headers['X-OS'] = 'iOS'
url.headers['Content-Type'] = 'application/json'
url.headers['X-App-ID'] = 'CSDN-APP'
url.headers['Origin'] = 'https://webapp.csdn.net'
url.headers['User-Agent'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 CSDNApp/4.1.5(iOS) AnalysysAgent/Hybrid'
url.headers['Referer'] = 'https://webapp.csdn.net/'
url.headers['Host'] = 'gw.csdn.net'
url.headers['Accept-Language'] = 'zh-cn'
url.headers['Accept'] = '*/*'
chavy.get(url, (error, response, data) => {
try {
signinfo.lucky = JSON.parse(data)
resolve()
} catch (e) {
chavy.msg(cookieName, `获取抽奖次数: 失败`, `说明: ${e}`)
chavy.log(`${cookieName} getlucky - 获取抽奖次数失败: ${e}`)
chavy.log(`${cookieName} getlucky - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
function luckyapp() {
return new Promise((resolve, reject) => {
const VAL_luckyappurl = `https://gw.csdn.net/mini-app/v2/lucky_draw/login/good_luck?projectVersion=1.0.0`
const url = {url: VAL_luckyappurl, body: '{}', headers: JSON.parse(VAL_signheader)}
url.headers['Connection'] = 'keep-alive'
url.headers['Accept-Encoding'] = 'gzip, deflate, br'
url.headers['X-OS'] = 'iOS'
url.headers['Content-Type'] = 'application/json'
url.headers['X-App-ID'] = 'CSDN-APP'
url.headers['Origin'] = 'https://webapp.csdn.net'
url.headers['User-Agent'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 CSDNApp/4.1.5(iOS) AnalysysAgent/Hybrid'
url.headers['Referer'] = 'https://webapp.csdn.net/'
url.headers['Host'] = 'gw.csdn.net'
url.headers['Accept-Language'] = 'zh-cn'
url.headers['Accept'] = '*/*'
chavy.post(url, (error, response, data) => {
try {
chavy.log(`${cookieName} luckyapp - response: ${JSON.stringify(response)}`)
signinfo.luckylist = signinfo.luckylist ? signinfo.luckylist : []
signinfo.luckylist.push(JSON.parse(data))
resolve()
} catch (e) {
chavy.msg(cookieName, `抽奖结果: 失败`, `说明: ${e}`)
chavy.log(`${cookieName} luckyapp - 抽奖失败: ${e}`)
chavy.log(`${cookieName} luckyapp - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
function showmsg() {
let subTitle = ''
let detail = ''
if (signinfo.signapp.code == 200) {
if (signinfo.signapp.data.isSigned === false) {
subTitle = `签到结果: 成功`
detail = `共签: ${signinfo.signapp.data.totalCount}天, 连签: ${signinfo.signapp.data.keepCount}`
} else if (signinfo.signapp.data.isSigned === true) {
subTitle = `签到结果: 重复`
} else {
subTitle = `签到结果: 失败`
detail = `编码: ${signinfo.signapp.code}, 说明: ${signinfo.signapp.msg}`
}
} else {
subTitle = `签到结果: 失败`
detail = `说明: 详见日志`
}
if (signinfo.lucky && signinfo.lucky.data && signinfo.lucky.data.drawTimes && signinfo.lucky.data.drawTimes > 0) {
subTitle += `; 抽奖次数: ${signinfo.lucky.data.drawTimes}`
detail += `\n查看抽奖详情\n`
for (let i = 0; i < signinfo.luckylist.length; i++) {
const can_draw = signinfo.luckylist[i].data.can_draw
if (can_draw) detail += `\n抽奖 ${i + 1}: ${signinfo.luckylist[i].data.title}`
else detail += `\n抽奖 ${i + 1}: ${signinfo.luckylist[i].data.msg}`
}
}
chavy.msg(cookieName, subTitle, detail)
}
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}
}

View File

@ -1,105 +0,0 @@
# 豆瓣时间
> 代码已同时兼容 Surge & QuanX, 使用同一份签到脚本即可
> QuanX 需要: v1.0.6-build195 及以后版本 (TestFlight)
> 感谢 [@GideonSenku](https://github.com/GideonSenku) Commit
> 实现过程[nocoding.xyz](http://nocoding.xyz/2020/03/28/build-check/)
## 配置 (Surge)
```properties
[MITM]
frodo.douban.com
[Script]
http-request ^https:\/\/frodo\.douban\.com\/api\/v2\/niffler\/check_in\/status script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/dbsj/dbsj.cookie.js
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/dbsj/dbsj.js
```
## 配置 (QuanX)
```properties
[MITM]
frodo.douban.com
[rewrite_local]
# [商店版] QuanX v1.0.6-build194 及更早版本
^https:\/\/frodo\.douban\.com\/api\/v2\/niffler\/check_in\/status url script-request-header dbsj.cookie.js
# [TestFlight] QuanX v1.0.6-build195 及以后版本
^https:\/\/frodo\.douban\.com\/api\/v2\/niffler\/check_in\/status url script-request-header https://raw.githubusercontent.com/chavyleung/scripts/master/dbsj/dbsj.cookie.js
[task_local]
1 0 * * * dbsj.js
```
## 说明
1. 先把`frodo.douban.com`加到`[MITM]`
2. 再配置重写规则:
- Surge: 把两条远程脚本放到`[Script]`
- QuanX: 把`dbsj.cookie.js`和`dbsj.js`传到`On My iPhone - Quantumult X - Scripts` (传到 iCloud 相同目录也可, 注意要打开 quanx 的 iCloud 开关)
3. 打开 APP 手动签到一次: `市集` > `豆瓣时间` > `签到`
4. 系统提示: `获取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)
[@GideonSenku](https://github.com/GideonSenku)

View File

@ -1,61 +0,0 @@
const cookieName = '豆瓣时间'
const signurlKey = 'senku_signurl_dbsj'
const signheaderKey = 'senku_signheader_dbsj'
const signbodyKey = 'senku_signbody_dbsj'
const senku = init()
const requrl = $request.url
if ($request && $request.method != 'OPTIONS') {
const signurlVal = requrl
const signheaderVal = JSON.stringify($request.headers)
if (signurlVal) senku.setdata(signurlVal, signurlKey)
if (signheaderVal) senku.setdata(signheaderVal, signheaderKey)
senku.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}
}
senku.done()

View File

@ -1,77 +0,0 @@
const cookieName = '豆瓣时间'
const signurlKey = 'senku_signurl_dbsj'
const signheaderKey = 'senku_signheader_dbsj'
const signbodyKey = 'senku_signbody_dbsj'
const senku = init()
const signurlVal = senku.getdata(signurlKey)
const signheaderVal = senku.getdata(signheaderKey)
sign()
function sign() {
const url = {url: signurlVal, headers: JSON.parse(signheaderVal)}
senku.get(url, (error, response, data) => {
const result = JSON.parse(data)
let subTitle = ``
let detail = ``
const has_checked = result.today_status.has_checked
const continuous_check_in_count = result.continuous_check_in_count
const status = result.auto_check.status
if (status == "success") {
subTitle = `签到结果: 成功`
detail = `连续签到天数${continuous_check_in_count}`
} else if (has_checked == false) {
subTitle = `签到结果: 重复`
} else if (has_checked == false) {
subTitle = `签到结果: 失败`
}
senku.msg(cookieName, subTitle, detail)
senku.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}
}

View File

@ -1,94 +0,0 @@
# 懂球帝
> 代码已同时兼容 Surge & QuanX, 使用同一份签到脚本即可
## 配置 (Surge)
```properties
[MITM]
api.dongqiudi.com
[Script]
http-request ^https:\/\/api\.dongqiudi\.com\/v2\/user\/is_login script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/dongqiudi/dongqiudi.cookie.js
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/dongqiudi/dongqiudi.js
```
## 配置 (QuanX)
```properties
[MITM]
api.dongqiudi.com
[rewrite_local]
# 189及以前版本
^https:\/\/api\.dongqiudi\.com\/v2\/user\/is_login url script-response-body dongqiudi.cookie.js
# 190及以后版本
^https:\/\/api\.dongqiudi\.com\/v2\/user\/is_login url script-request-header dongqiudi.cookie.js
[task_local]
1 0 * * * dongqiudi.js
```
## 说明
1. 先把`api.dongqiudi.com`加到`[MITM]`
2. 再配置重写规则:
- Surge: 把两条远程脚本放到`[Script]`
- QuanX: 把`dongqiudi.cookie.js`和`dongqiudi.js`传到`On My iPhone - Quantumult X - Scripts` (传到 iCloud 相同目录也可, 注意要打开 quanx 的 iCloud 开关)
3. 打开懂球帝 (打开前先杀掉 APP)
4. 系统提示: `获取Cookie: 成功` (如果不提示获取成功, 尝试杀进程再进个人中心)
5. 最后就可以把第 1 条脚本注释掉了
> 第 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)

View File

@ -1,57 +0,0 @@
const cookieName = '懂球帝'
const cookieKey = 'chavy_cookie_dongqiudi'
const chavy = init()
const cookieVal = JSON.stringify({
UUID: $request.headers['UUID'],
Authorization: $request.headers['Authorization']
})
if (cookieVal && chavy.setdata(cookieVal, cookieKey)) {
chavy.msg(`${cookieName}`, '获取Cookie: 成功', '')
chavy.log(`[${cookieName}] 获取Cookie: 成功, cookie: ${cookieVal}`)
}
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()

View File

@ -1,82 +0,0 @@
const cookieName = '懂球帝'
const cookieKey = 'chavy_cookie_dongqiudi'
const chavy = init()
const cookieVal = JSON.parse(chavy.getdata(cookieKey))
sign()
function sign() {
let url = {url: `https://api.dongqiudi.com/v3/useract/sign/tasknew/index`, headers: {}}
url.headers['UUID'] = `${cookieVal.UUID}`
url.headers['Authorization'] = `${cookieVal.Authorization}`
url.headers['Accept-Encoding'] = `gzip, deflate, br`
url.headers['Origin'] = `https://n.dongqiudi.com`
url.headers['Connection'] = `keep-alive`
url.headers['Accept'] = `application/json, text/plain, */*`
url.headers['Referer'] = `https://n.dongqiudi.com/webapp/signIn.html`
url.headers['Host'] = `api.dongqiudi.com`
url.headers['User-Agent'] = `Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 NewsApp/7.3.3 NetType/NA Technology/Wifi (iPhone; iOS 13.3; Scale/2.00) dongqiudiClientApp (modelIdentifier/iPhone10,1 )`
url.headers['Accept-Language'] = `zh-cn`
chavy.get(url, (error, response, data) => {
chavy.log(`${cookieName}, data: ${data}`)
let result = JSON.parse(data)
const title = `${cookieName}`
let subTitle = ``
let detail = ``
if (result.code == 0) {
if (result.data.sign_gold != 0) subTitle = '签到结果: 成功'
else subTitle = '签到结果: 成功 (重复签到)'
detail = `连签: ${result.data.continue_sign_days}天, 金币: ${result.data.gold_num} (+${result.data.sign_gold}), 价值: ${result.data.convertible_money}`
} else {
subTitle = '签到结果: 失败'
detail = `编码: ${result.code}, 说明: ${result.message}`
}
chavy.msg(title, 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.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}
}

View File

@ -1,94 +0,0 @@
# 多看阅读
> 代码已同时兼容 Surge & QuanX, 使用同一份签到脚本即可
> QuanX 需要: v1.0.6-build195 及以后版本 (TestFlight)
## 配置 (Surge)
```properties
[MITM]
www.duokan.com
[Script]
http-request ^https:\/\/www\.duokan\.com\/checkin\/v0\/status script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/duokan/duokan.cookie.js, requires-body=true
cron "0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/duokan/duokan.js
```
## 配置 (QuanX)
```properties
[MITM]
www.duokan.com
[rewrite_local]
# [商店版] QuanX v1.0.6-build194 及更早版本
^https:\/\/www\.duokan\.com\/checkin\/v0\/status url script-request-body duokan.cookie.js
# [TestFlight] QuanX v1.0.6-build195 及以后版本
^https:\/\/www\.duokan\.com\/checkin\/v0\/status url script-request-body https://raw.githubusercontent.com/chavyleung/scripts/master/duokan/duokan.cookie.js
[task_local]
0 0 * * * duokan.js
```
## 说明
1. 先把 `www.duokan.com` 加到 `[MITM]`
2. 再配置重写规则:
- Surge: 把两条远程脚本放到 `[Script]`
- QuanX: 把 `duokan.cookie.js``duokan.js` 传到 `On My iPhone - Quantumult X - Scripts` (传到 iCloud 相同目录也可, 注意要打开 quanx 的 iCloud 开关)
3. 获取 Cookie: `我的` > `签到任务` 等到提示获取 Cookie 成功即可
> 第 1 条脚本是用来获取 cookie 的, 用浏览器访问一次获取 cookie 成功后就可以删掉或注释掉了, 但请确保在`登录成功`后再获取 cookie.
> 第 2 条脚本是签到脚本, 每天 `00:00` 执行一次.
## 常见问题
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)

View File

@ -1,81 +0,0 @@
const DUOKAN_COOKIE_KEY = 'duokan_cookie'
const DUOKAN_DEVICE_ID_KEY = 'duokan_device_id'
let $util = init()
if (typeof $request !== 'undefined') {
getCookie()
}
$util.done({})
function getCookie() {
let cookieVal = $request.headers['Cookie']
$util.log(`cookie: ${cookieVal}`)
if (cookieVal.indexOf('token=') !== -1 && cookieVal.indexOf('device_id=') !== -1) {
let regexp = /device_id=(.*?);/g
let matched = regexp.exec(cookieVal)
if (matched) {
let deviceId = matched[1]
$util.log(`deviceId: ${deviceId}`)
if ($util.setdata(cookieVal, DUOKAN_COOKIE_KEY) && $util.setdata(deviceId, DUOKAN_DEVICE_ID_KEY)) {
$util.msg(`获取多看阅读 Cookie 成功 🎉`)
}
}
}
}
function init() {
isSurge = () => {
return undefined !== this.$httpClient
}
isQuanX = () => {
return undefined !== this.$task
}
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 = (msg) => {
console.log(`${msg}\n`)
}
get = (options, callback) => {
if (isQuanX()) {
if (typeof options == 'string') options = {url: options}
options['method'] = 'GET'
return $task.fetch(options).then(
(response) => {
response['status'] = response.statusCode
callback(null, response, response.body)
},
(reason) => callback(reason.error, null, null)
)
}
if (isSurge()) return $httpClient.get(options, callback)
}
post = (options, callback) => {
if (isQuanX()) {
if (typeof options == 'string') options = {url: options}
options['method'] = 'POST'
$task.fetch(options).then(
(response) => {
response['status'] = response.statusCode
callback(null, response, response.body)
},
(reason) => callback(reason.error, null, null)
)
}
if (isSurge()) $httpClient.post(options, callback)
}
done = (value = {}) => {
$done(value)
}
return {isSurge, isQuanX, msg, log, getdata, setdata, get, post, done}
}

View File

@ -1,123 +0,0 @@
const DUOKAN_COOKIE_KEY = 'duokan_cookie'
const DUOKAN_DEVICE_ID_KEY = 'duokan_device_id'
const API_HOST = 'https://www.duokan.com'
const TASK_NAME = '多看阅读'
let $util = init()
;(async () => {
let cookieVal = $util.getdata(DUOKAN_COOKIE_KEY)
let deviceId = $util.getdata(DUOKAN_DEVICE_ID_KEY)
if (!cookieVal || !deviceId) {
$util.msg(TASK_NAME, '⚠️ 请先获取 Cookie')
$util.done({})
return
}
await checkin(cookieVal, deviceId).then(() => {
$util.done({})
})
})()
function checkin(cookieVal, deviceId) {
return new Promise((resolve, reject) => {
let options = {
url: `${API_HOST}/checkin/v0/checkin`,
headers: {
'User-Agent':
'Mozilla/5.0 (iPhone; CPU iPhone OS 13_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148',
Cookie: cookieVal
},
body: signature(deviceId)
}
$util.post(options, (error, response, data) => {
if (error) {
$util.log(`签到失败error${error}`)
$util.msg(TASK_NAME, '⚠️ 签到失败,详情请查看日志')
resolve()
return
}
let result = JSON.parse(data)
if (result && result.result === 0 && result.data) {
$util.log(`签到成功response: ${data}`)
let subtitle = `签到成功,已连续签到 ${result.data.today}`
let body = ''
if (result.data.gift && Array.isArray(result.data.gift) && result.data.gift.length > 0) {
body = result.data.gift.reduce((prev, cur) => {
return (prev += `获得 ${cur.value}${cur.name} \n`)
}, '')
}
$util.msg(TASK_NAME, subtitle, body)
resolve()
} else {
$util.log(`签到失败response: ${data}`)
$util.msg(TASK_NAME, `⚠️ 签到失败,${result.msg}`)
resolve()
}
})
})
}
function signature(deviceId) {
let t = parseInt(new Date().getTime() / 1000)
let c = 0
for (char of `${deviceId}&${t}`) {
c = (c * 131 + char.charCodeAt(0)) % 65536
}
return `_t=${t}&_c=${c}`
}
function init() {
isSurge = () => {
return undefined !== this.$httpClient
}
isQuanX = () => {
return undefined !== this.$task
}
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 = (msg) => {
console.log(`${msg}\n`)
}
get = (options, callback) => {
if (isQuanX()) {
if (typeof options == 'string') options = {url: options}
options['method'] = 'GET'
return $task.fetch(options).then(
(response) => {
response['status'] = response.statusCode
callback(null, response, response.body)
},
(reason) => callback(reason.error, null, null)
)
}
if (isSurge()) return $httpClient.get(options, callback)
}
post = (options, callback) => {
if (isQuanX()) {
if (typeof options == 'string') options = {url: options}
options['method'] = 'POST'
$task.fetch(options).then(
(response) => {
response['status'] = response.statusCode
callback(null, response, response.body)
},
(reason) => callback(reason.error, null, null)
)
}
if (isSurge()) $httpClient.post(options, callback)
}
done = (value = {}) => {
$done(value)
}
return {isSurge, isQuanX, msg, log, getdata, setdata, get, post, done}
}

View File

@ -1,91 +0,0 @@
# 时光相册
> 代码已同时兼容 Surge & QuanX, 使用同一份签到脚本即可
## 配置 (Surge)
```properties
[MITM]
api.everphoto.cn
[Script]
http-request ^https:\/\/api.everphoto.cn\/users\/self\/checkin\/v2 script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/everphoto/everphoto.cookie.js
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/everphoto/everphoto.js
```
## 配置 (QuanX)
```properties
[MITM]
api.everphoto.cn
[rewrite_local]
^https:\/\/api.everphoto.cn\/users\/self\/checkin\/v2 url script-request-header everphoto.cookie.js
[task_local]
1 0 * * * everphoto.js
```
## 说明
1. 先把`api.everphoto.cn`加到`[MITM]`
2. 再配置重写规则:
- Surge: 把两条远程脚本放到`[Script]`
- QuanX: 把`everphoto.cookie.js`和`everphoto.js`传到`On My iPhone - Quantumult X - Scripts` (传到 iCloud 相同目录也可, 注意要打开 quanx 的 iCloud 开关)
3. 打开 APP 然后手动签到 1 次, 系统提示: `获取Cookie: 成功`
4. 最后就可以把第 1 条脚本注释掉了
5. 运行一次脚本, 如果提示重复签到, 那就算成功了!
> 第 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)

View File

@ -1,70 +0,0 @@
const chavy = init()
const cookieName = '时光相册'
const KEY_signurl = 'chavy_sign_url_everphoto'
const KEY_signheader = 'chavy_sign_header_everphoto'
if ($request && $request.method != 'OPTIONS') {
try {
chavy.log(`🔔 ${cookieName} 开始获取: Cookies`)
const VAL_signurl = $request.url
const VAL_signheader = JSON.stringify($request.headers)
if (VAL_signurl) {
chavy.setdata(VAL_signurl, KEY_signurl)
chavy.log(`${cookieName} VAL_signurl: ${VAL_signurl}`)
}
if (VAL_signheader) {
chavy.setdata(VAL_signheader, KEY_signheader)
chavy.log(`${cookieName} VAL_signheader: ${VAL_signheader}`)
}
chavy.msg(cookieName, `获取Cookie: 成功`, ``)
} catch (e) {
chavy.msg(cookieName, `获取Cookie: 失败`, e)
chavy.log(`${cookieName} 获取Cookie: 失败: ${e}`)
}
}
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()

View File

@ -1,97 +0,0 @@
const chavy = init()
const cookieName = '时光相册'
const KEY_signurl = 'chavy_sign_url_everphoto'
const KEY_signheader = 'chavy_sign_header_everphoto'
const signinfo = {}
let VAL_signurl = chavy.getdata(KEY_signurl)
let VAL_signheader = chavy.getdata(KEY_signheader)
;(exec = async () => {
chavy.log(`🔔 ${cookieName} 开始签到`)
await signapp()
showmsg()
chavy.done()
})().catch((e) => chavy.log(`${cookieName} 签到失败: ${e}`), chavy.done())
function signapp() {
return new Promise((resolve, reject) => {
const url = {url: VAL_signurl, headers: JSON.parse(VAL_signheader)}
chavy.post(url, (error, response, data) => {
try {
signinfo.signapp = JSON.parse(data)
resolve()
} catch (e) {
chavy.msg(cookieName, `签到结果: 失败`, `说明: ${e}`)
chavy.log(`${cookieName} sign - 签到失败: ${e}`)
chavy.log(`${cookieName} sign - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
function showmsg() {
let subTitle, detail
if (signinfo.signapp.code == 0 && signinfo.signapp.data.checkin_result == true) {
const reward = signinfo.signapp.data.reward / 1024 / 1024
const total_reward = signinfo.signapp.data.total_reward / 1024 / 1024
const tomorrow_reward = signinfo.signapp.data.tomorrow_reward / 1024 / 1024
subTitle = '签到结果: 成功'
detail = `总共获得: ${total_reward}MB (+${reward}MB), 明天获得: ${tomorrow_reward}MB`
} else if (signinfo.signapp.code == 0 && signinfo.signapp.data.checkin_result == false) {
const total_reward = signinfo.signapp.data.total_reward / 1024 / 1024
const tomorrow_reward = signinfo.signapp.data.tomorrow_reward / 1024 / 1024
subTitle = '签到结果: 成功 (重复签到)'
detail = `总共获得: ${total_reward}MB, 明天获得: ${tomorrow_reward}MB`
} else {
subTitle = '签到结果: 失败'
detail = `编码: ${signinfo.signapp.code}, 说明: 未知`
chavy.log(`${cookieName} showmsg - 签到失败: ${JSON.stringify(signinfo.signapp)}`)
}
chavy.msg(cookieName, subTitle, detail)
}
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}
}

View File

@ -1,110 +0,0 @@
# 威锋网
> 代码已同时兼容 Surge & QuanX, 使用同一份签到脚本即可
> 注意了威锋网只能在一处登录, 如果你手机上登录了, 其他地方的登录会话会被踢掉 (重新登录需要重新获取 Cookie)
> 2020.1.11 QuanX 在`190`版本开始, 获取 Cookie 方式需要从`script-response-body`改为`script-request-header`
> 2020.2.6 威锋加了验证, 弃坑
> 2020.2.10 恢复签到: 增加参数签名
> 2020.2.11 威锋加了校验, 偶尔能签, 选择性弃坑吧!
## 配置 (Surge)
```properties
[MITM]
*.feng.com
[Script]
http-request ^https:\/\/(www\.)?feng\.com\/?.? script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/feng/feng.cookie.js
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/feng/feng.js
```
## 配置 (QuanX)
```properties
[MITM]
*.feng.com
[rewrite_local]
# 189及以前版本
^https:\/\/(www\.)?feng\.com\/?.? url script-response-body feng.cookie.js
# 190及以后版本
^https:\/\/(www\.)?feng\.com\/?.? url script-request-header feng.cookie.js
[task_local]
1 0 * * * feng.js
```
## 说明
1. 先在浏览器登录 `(先登录! 先登录! 先登录!)`
- 如果你找不到登录的入口: 随便找个帖子做个“回帖”的动作, 会提示你登录的.
- 可以试试: https://www.feng.com/newthread
2. 先把`*.feng.com`加到`[MITM]`
3. 再配置重写规则:
- Surge: 把两条远程脚本放到`[Script]`
- QuanX: 把`feng.cookie.js`和`feng.js`传到`On My iPhone - Quantumult X - Scripts` (传到 iCloud 相同目录也可, 注意要打开 quanx 的 iCloud 开关)
4. 打开浏览器访问: https://www.feng.com
5. 系统提示: `获取Cookie: 成功`
- 如果一直取不到 Cookie, 请尝试一切你想到的姿势, 如:
- 访问: https://www.feng.com/newthread
- 然后刷新下
6. 最后就可以把第 1 条脚本注释掉了
> 第 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)

View File

@ -1,63 +0,0 @@
const cookieName = '威锋网'
const cookieKey = 'chavy_cookie_feng'
const chavy = init()
const cookieVal = $request.headers['Cookie']
if (cookieVal.indexOf('userInfo') >= 0) {
if (cookieVal) {
if (chavy.setdata(cookieVal, cookieKey)) {
chavy.msg(`${cookieName}`, '获取Cookie: 成功', '')
chavy.log(`[${cookieName}] 获取Cookie: 成功, cookie: ${cookieVal}`)
}
}
} else {
let subTitle = '获取Cookie: 失败'
let detail = `请确保在已登录状态下获取Cookie`
chavy.msg(`${cookieName}`, subTitle, detail)
chavy.log(`[${cookieName}] ${subTitle}, cookie: ${cookieVal}`)
}
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()

File diff suppressed because it is too large Load Diff

View File

@ -1,109 +0,0 @@
# 分期乐
> 代码已同时兼容 Surge & QuanX, 使用同一份签到脚本即可
> QuanX 需要: v1.0.6-build195 及以后版本 (TestFlight)
> 感谢 [@GideonSenku](https://github.com/GideonSenku) Commit
> 2020.03.18 添加超级乐星日/天天领乐星
## 配置 (Surge)
```properties
[MITM]
pm.m.fenqile.com
[Script]
http-request ^https://pm\.m\.fenqile\.com/route0014/star/sign/sign.json script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/fenqile/fenqile.cookie.js, requires-body=true
http-request ^https:\/\/pm\.m\.fenqile\.com/route0014\/app\/tab\/privilege\/convertTaskReward.json script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/fenqile/fenqile.cookie.js, requires-body=true
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/fenqile/fenqile.js
```
## 配置 (QuanX)
```properties
[MITM]
pm.m.fenqile.com
[rewrite_local]
# [商店版] QuanX v1.0.6-build194 及更早版本
# 支持request-body 脚本可食用,换成本地
# [TestFlight] QuanX v1.0.6-build195 及以后版本
^https://pm\.m\.fenqile\.com/route0014/star/sign/sign.json url script-request-body https://raw.githubusercontent.com/chavyleung/scripts/master/fenqile/fenqile.cookie.js
^https:\/\/pm\.m\.fenqile\.com/route0014\/app\/tab\/privilege\/convertTaskReward.json url script-request-body https://raw.githubusercontent.com/chavyleung/scripts/master/fenqile/fenqile.cookie.js
[task_local]
1 0 * * * fenqile.js
```
## 说明
1. 先把`pm.m.fenqile.com`加到`[MITM]`
2. 再配置重写规则:
- Surge: 把两条远程脚本放到`[Script]`
- QuanX: 把`fenqile.cookie.js`和`fenqile.js`传到`On My iPhone - Quantumult X - Scripts` (传到 iCloud 相同目录也可, 注意要打开 quanx 的 iCloud 开关)
3. 打开 APP 手动签到一次: 访问下右下角 `我的` > `乐星` > `签到`,`我的` > `账单点击` > `超级乐星日/天天领乐星`
4. 系统提示: `获取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)
[@GideonSenku](https://github.com/GideonSenku)

View File

@ -1,71 +0,0 @@
const cookieName = '分期乐'
const signurlKey = 'senku_signurl_fenqile'
const signheaderKey = 'senku_signheader_fenqile'
const signbodyKey = 'senku_signbody_fenqile'
const signDailyKey = 'senku_signDailyKey_fenqile'
const signDailyUrlKey = 'senku_signDailyUrlKey_fenqile'
const senku = init()
const requrl = $request.url
if ($request && $request.method != 'OPTIONS' && requrl.match(/\/route0014\/star\/sign\//)) {
const signurlVal = requrl
const signheaderVal = JSON.stringify($request.headers)
const signbodyVal = $request.body
if (signurlVal) senku.setdata(signurlVal, signurlKey)
if (signheaderVal) senku.setdata(signheaderVal, signheaderKey)
if (signbodyVal) senku.setdata(signbodyVal, signbodyKey)
senku.msg(cookieName, `获取Cookie: 成功`, `签到领乐星`)
} else {
const signDailyUrlVal = $request.url
const signDailyVal = $request.body;
if (signDailyUrlVal) senku.setdata(signDailyUrlVal, signDailyUrlKey)
if (signDailyVal) senku.setdata(signDailyVal, signDailyKey)
senku.msg(cookieName, `获取Cookie: 成功`, `天天领乐星`)
senku.log()
}
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}
}
senku.done()

View File

@ -1,128 +0,0 @@
const cookieName = '分期乐'
const signurlKey = 'senku_signurl_fenqile'
const signheaderKey = 'senku_signheader_fenqile'
const signbodyKey = 'senku_signbody_fenqile'
const signDailyKey = 'senku_signDailyKey_fenqile'
const signDailyUrlKey = 'senku_signDailyUrlKey_fenqile'
const senku = init()
const signurlVal = senku.getdata(signurlKey)
const signheaderVal = senku.getdata(signheaderKey)
const signBodyVal = senku.getdata(signbodyKey)
const signDailyUrlVal = senku.getdata(signDailyUrlKey)
const signDailyVal = senku.getdata(signDailyKey)
const signinfo = {}
check()
function check() {
signDaily()
sign()
checkin()
}
function sign() {
const url = {url: signurlVal, headers: JSON.parse(signheaderVal), body: signBodyVal}
senku.post(url, (error, response, data) => {
senku.log(`${cookieName}, 🔔sign--data: ${data}`)
signinfo.sign = JSON.parse(data)
})
}
function signDaily() {
const url = {url: signDailyUrlVal, headers: JSON.parse(signheaderVal), body: signDailyVal}
senku.post(url, (error, response, data) => {
senku.log(`${cookieName}, 🔔signDaily--data: ${data}`)
signinfo.signDaily = JSON.parse(data)
})
}
function getinfo() {
const title = `${cookieName}`
let subTitle = `天天领乐星:`
let detail = ``
//signDaily
if (signinfo.signDaily.data.result == 0) {
subTitle += `成功`
} else if (signinfo.signDaily.data.result == 11650011) {
subTitle += `重复签到`
} else {
subTitle += `失败`
detail += `编码: ${signinfo.signDaily.data.result}, 说明: ${signinfo.signDaily.data.res_info}`
}
//sign
subTitle += ` 签到领乐星:`
if (signinfo.sign.data.result == 0) {
subTitle += `成功`
detail += `账户乐星总数: ${signinfo.sign.data.result_rows.postStar}`
} else if (signinfo.sign.data.result == 12130022) {
subTitle += `重复签到`
} else {
subTitle += `失败`
detail += `编码: ${signinfo.sign.data.result}, 说明: ${signinfo.sign.data.res_info}`
}
senku.msg(title, subTitle, detail)
senku.done()
}
function checkin(checkms = 0) {
if (signinfo.sign && signinfo.signDaily) {
getinfo()
} else {
if (checkms > 5000) {
chavy.msg(`${cookieName}`, `签到失败: 超时退出`, ``)
chavy.done()
} else {
setTimeout(() => check(checkms + 100), 100)
}
}
}
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}
}

View File

@ -1,96 +0,0 @@
# 飞客茶馆
> 代码已同时兼容 Surge & QuanX, 使用同一份签到脚本即可
> 2020.1.11 QuanX 在`190`版本开始, 获取 Cookie 方式需要从`script-response-body`改为`script-request-header`
## 配置 (Surge)
```properties
[MITM]
www.flyertea.com
[Script]
http-request ^https:\/\/www\.flyertea\.com\/source\/plugin\/mobile\/mobile\.php\?module=getdata&.* script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/flyertea/flyertea.cookie.js
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/flyertea/flyertea.js
```
## 配置 (QuanX)
```properties
[MITM]
www.flyertea.com
[rewrite_local]
# 189及以前版本
^https:\/\/www\.flyertea\.com\/source\/plugin\/mobile\/mobile\.php\?module=getdata&.* url script-response-body flyertea.cookie.js
# 190及以后版本
^https:\/\/www\.flyertea\.com\/source\/plugin\/mobile\/mobile\.php\?module=getdata&.* url script-request-header flyertea.cookie.js
[task_local]
1 0 * * * flyertea.js
```
## 说明
1. 先把`www.flyertea.com`加到`[MITM]`
2. 再配置重写规则:
- Surge: 把两条远程脚本放到`[Script]`
- QuanX: 把`flyertea.cookie.js`和`flyertea.js`传到`On My iPhone - Quantumult X - Scripts` (传到 iCloud 相同目录也可, 注意要打开 quanx 的 iCloud 开关)
3. 打开 APP, 访问下`个人中心`
4. 系统提示: `获取Cookie: 成功` (如果不提示获取成功, 尝试杀进程再进个人中心)
5. 最后就可以把第 1 条脚本注释掉了
> 第 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)

View File

@ -1,70 +0,0 @@
const cookieName = '飞客茶馆'
const cookieKey = 'chavy_cookie_flyertea'
const tokenKey = 'chavy_token_flyertea'
const chavy = init()
const cookieVal = $request.headers['Cookie']
if (cookieVal) {
if (chavy.setdata(cookieVal, cookieKey)) {
chavy.msg(`${cookieName}`, '获取Cookie: 成功', '')
chavy.log(`[${cookieName}] 获取Cookie: 成功, cookie: ${cookieVal}`)
}
}
const queryparam = $request.url.split('?')[1]
if (queryparam) {
const params = {}
for (param of $request.url.split('?')[1].split('&')) {
params[param.split('=')[0]] = param.split('=')[1]
}
const token = JSON.stringify(params)
if (chavy.setdata(token, tokenKey)) {
chavy.msg(`${cookieName}`, '获取Token: 成功', '')
chavy.log(`[${cookieName}] 获取Token: 成功, token: ${token}`)
}
}
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()

View File

@ -1,88 +0,0 @@
const cookieName = '飞客茶馆'
const cookieKey = 'chavy_cookie_flyertea'
const tokenKey = 'chavy_token_flyertea'
const chavy = init()
let cookieVal = chavy.getdata(cookieKey)
let tokenVal = chavy.getdata(tokenKey)
sign()
function sign() {
const token = JSON.parse(tokenVal)
let url = {
url: `https://www.flyertea.com/plugin.php?id=k_misign:sign&operation=qiandao&from=insign&version=${token.version}&appcan=appcan&appkey=${token.appkey}&appversion=${token.appversion}&formhash=${token.formhash}&token=${token.token}`,
headers: {Cookie: cookieVal}
}
url.headers['Accept'] = `*/*`
url.headers['Accept-Language'] = `zh-Hans-CN;q=1, en-US;q=0.9`
url.headers['Host'] = `www.flyertea.com`
url.headers['User-Agent'] = `FKForum/7.14.0 (iPhone10,1; iOS 13.3; Scale/2.00)`
url.headers['Referer'] = `https://www.flyertea.com/home.php`
url.headers['Accept-Encoding'] = `gzip, deflate, br`
url.headers['Connection'] = `keep-alive`
chavy.get(url, (error, response, data) => {
chavy.log(`${cookieName}, data: ${data}`)
const result = JSON.parse(data)
const title = `${cookieName}`
let subTitle = ``
let detail = ``
if (result.Variables && result.Variables.Message.messageval == 'success') {
subTitle = `签到结果: 成功`
detail = `说明: ${result.Variables.Message.messagestr}`
chavy.msg(title, subTitle, detail)
} else {
if (result.Message.messageval == 'error' && result.Message.messagestr.indexOf('只能签到一次') >= 0) {
subTitle = `签到结果: 成功 (重复签到)`
} else {
subTitle = `签到结果: 失败`
}
detail = `说明: ${result.Message.messagestr}`
chavy.msg(title, 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.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}
}

View File

@ -1,93 +0,0 @@
# 加油广东
> 代码已同时兼容 Surge & QuanX, 使用同一份签到脚本即可
> 2020.2.28 更新域名: gdws.nsenz.com > m.gdoil.cn
## 配置 (Surge)
```properties
[MITM]
m.gdoil.cn
[Script]
http-request ^https:\/\/m.gdoil.cn\/webapi\/usersign\/addusersign script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/gdoil/gdoil.cookie.js
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/gdoil/gdoil.js
```
## 配置 (QuanX)
```properties
[MITM]
m.gdoil.cn
[rewrite_local]
^https:\/\/m.gdoil.cn\/webapi\/usersign\/addusersign url script-request-header gdoil.cookie.js
[task_local]
1 0 * * * gdoil.js
```
## 说明
1. 先把`m.gdoil.cn`加到`[MITM]`
2. 再配置重写规则:
- Surge: 把两条远程脚本放到`[Script]`
- QuanX: 把`gdoil.cookie.js`和`gdoil.js`传到`On My iPhone - Quantumult X - Scripts` (传到 iCloud 相同目录也可, 注意要打开 quanx 的 iCloud 开关)
3. 打开 APP 然后手动签到 1 次, 系统提示: `获取Cookie: 成功`
4. 最后就可以把第 1 条脚本注释掉了
5. 运行一次脚本, 如果提示重复签到, 那就算成功了!
> 第 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)

View File

@ -1,58 +0,0 @@
const cookieName = '加油广东'
const signurlKey = 'chavy_signurl_gdoil'
const signheaderKey = 'chavy_signheader_gdoil'
const chavy = init()
if ($request && $request.method != 'OPTIONS') {
const signurlVal = $request.url
const signheaderVal = JSON.stringify($request.headers)
if (signurlVal) chavy.setdata(signurlVal, signurlKey)
if (signheaderVal) chavy.setdata(signheaderVal, signheaderKey)
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()

View File

@ -1,73 +0,0 @@
const cookieName = '加油广东'
const signurlKey = 'chavy_signurl_gdoil'
const signheaderKey = 'chavy_signheader_gdoil'
const chavy = init()
const signurlVal = chavy.getdata(signurlKey)
const signheaderVal = chavy.getdata(signheaderKey)
sign()
function sign() {
const url = {url: signurlVal, headers: JSON.parse(signheaderVal)}
url.body = '{}'
chavy.post(url, (error, response, data) => {
chavy.log(`${cookieName}, data: ${data}`)
const result = JSON.parse(data)
const title = `${cookieName}`
let subTitle = ''
let detail = ''
if (result.result == true) {
subTitle = `签到结果: 成功`
} else {
if (result.msg.indexOf('已经签到') >= 0) subTitle = `签到结果: 成功 (重复签到)`
else subTitle = `签到结果: 失败`
detail = `说明: ${result.msg}`
}
chavy.msg(title, 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.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}
}

View File

@ -1,104 +0,0 @@
# 海底捞
> 代码已同时兼容 Surge & QuanX, 使用同一份签到脚本即可
> 感谢[@danchaw](https://github.com/danchaw) PR
## 配置 (Surge)
```properties
[MITM]
activity-1.m.duiba.com.cn
[Script]
http-request ^https:\/\/activity-1\.m\.duiba\.com\.cn\/signactivity\/doSign$ requires-body=1,max-size=0,script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/haidilao/hdl.js
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/haidilao/hdl.js
```
## 配置 (QuanX)
```properties
[MITM]
activity-1.m.duiba.com.cn
[rewrite_local]
# [商店版]
^https:\/\/activity-1\.m\.duiba\.com\.cn\/signactivity\/doSign$ url script-request-body hdl.js
# [TestFlight]
^https:\/\/activity-1\.m\.duiba\.com\.cn\/signactivity\/doSign$ url script-request-body https://raw.githubusercontent.com/chavyleung/scripts/master/haidilao/hdl.js
[task_local]
# [商店版]
1 0 * * * hdl.js
# [TestFlight]
1 0 * * * https://raw.githubusercontent.com/chavyleung/scripts/master/haidilao/hdl.js
```
## 说明
1. 先把`activity-1.m.duiba.com.cn`加到`[MITM]`
2. 再配置重写规则:
- Surge: 把两条远程脚本放到`[Script]`
- QuanX: 把`hdl.js`传到`On My iPhone - Quantumult X - Scripts` (传到 iCloud 相同目录也可, 注意要打开 quanx 的 iCloud 开关)
3. 打开 APP[海底捞](https://apps.apple.com/cn/app/%E6%B5%B7%E5%BA%95%E6%8D%9E/id553115181) 然后手动签到 1 次, 系统提示: `获取Cookie: 成功`
4. 最后就可以把第 1 条脚本注释掉了
5. 运行一次脚本, 如果提示重复签到, 那就算成功了!
> 第 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)
[@danchaw](https://github.com/danchaw)

View File

@ -1,106 +0,0 @@
const cookieName = '海底捞'
const signurlKey = 'signurl_hdl'
const signheaderKey = 'signheader_hdl'
const signbodyKey = 'signbody_hdl'
const hdl = init()
let isGetCookie = typeof $request !== 'undefined'
if (isGetCookie) {
getcookie()
} else {
sign()
}
function getcookie() {
if ($request && $request.method == 'POST') {
const signurlVal = $request.url
const signheaderVal = JSON.stringify($request.headers)
const signbodyVal = $request.body
if (signurlVal) hdl.setdata(signurlVal, signurlKey)
if (signheaderVal) hdl.setdata(signheaderVal, signheaderKey)
if (signbodyVal) hdl.setdata(signbodyVal, signbodyKey)
hdl.msg(cookieName, `获取Cookie: 成功, 请禁用该脚本`, ``)
}
hdl.done()
}
function sign() {
const signurlVal = hdl.getdata(signurlKey)
const signheaderVal = hdl.getdata(signheaderKey)
const signbodyVal = hdl.getdata(signbodyKey)
const url = {url: signurlVal, headers: JSON.parse(signheaderVal), body: signbodyVal}
hdl.post(url, (error, response, data) => {
hdl.log(`${cookieName}, data: ${data}`)
const title = `${cookieName}`
let subTitle = ''
let detail = ''
const result = JSON.parse(data)
if (result.success == true && result.signInfoVO.todaySigned == true) {
subTitle = `签到结果: 成功`
detail = `签到奖励: ${result.customInfo.foodNum}火柴, 连签: ${result.signInfoVO.continueDay}`
} else if (result.success == false && result.signInfoVO.todaySigned == true) {
subTitle = `签到结果: 成功 (重复签到)`
detail = `连签: ${result.signInfoVO.continueDay}`
} else {
subTitle = `签到结果: 失败`
detail = `说明: ${result.message}, 请重新获取`
}
hdl.msg(title, subTitle, detail)
hdl.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.body))
}
}
post = (url, cb) => {
if (isSurge()) {
$httpClient.post(url, cb)
}
if (isQuanX()) {
url.method = 'POST'
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
}
}
put = (url, cb) => {
if (isSurge()) {
$httpClient.put(url, cb)
}
if (isQuanX()) {
url.method = 'PUT'
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
}
}
done = (value = {}) => {
$done(value)
}
return {isSurge, isQuanX, msg, log, getdata, setdata, get, post, put, done}
}

View File

@ -1,102 +0,0 @@
# 哈啰出行
> 代码已同时兼容 Surge & QuanX, 使用同一份签到脚本即可
## 配置 (Surge)
```properties
[MITM]
gameapi.hellobike.com
[Script]
http-request ^https:\/\/gameapi\.hellobike\.com\/api script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/hellobike/hellobike.js, requires-body=true
cron "5 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/hellobike/hellobike.js
```
## 配置 (QuanX)
```properties
[MITM]
gameapi.hellobike.com
[rewrite_local]
# [商店版]
^https:\/\/gameapi\.hellobike\.com\/api url script-request-body hellobike/hellobike.js
# [TestFlight]
^https:\/\/gameapi\.hellobike\.com\/api url script-request-body https://raw.githubusercontent.com/chavyleung/scripts/master/hellobike/hellobike.js
[task_local]
# [商店版]
5 0 * * * hellobike/hellobike.js
# [TestFlight]
5 0 * * * https://raw.githubusercontent.com/chavyleung/scripts/master/hellobike/hellobike.js
```
## 说明
1. 先把`gameapi.hellobike.com`加到`[MITM]`
2. 再配置重写规则:
- Surge: 把远程脚本放到`[Script]`
- QuanX: 把`hellobike.js`传到`On My iPhone - Quantumult X - Scripts - hellobike` (传到 iCloud 相同目录也可, 注意要打开 quanx 的 iCloud 开关)
3. 打开 APP 进入签到页面: `我的` > `有哈有车`
4. 系统提示: `首次写入 哈啰出行 Token 成功 🎉`
5. 把获取 Cookie 的脚本注释掉
6. 运行一次脚本, 如果提示重复签到, 那就算成功了!
> 第 1 条脚本是用来获取 cookie 的, 用浏览器访问一次获取 cookie 成功后就可以删掉或注释掉了, 但请确保在`登录成功`后再获取 cookie.
> 第 2 条脚本是签到脚本, 每天`00:05`执行一次.
## 常见问题
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)
[@GideonSenku](https://github.com/GideonSenku)

View File

@ -1,303 +0,0 @@
const HELLO_BIKE = init()
const TASK_NAME = '哈啰出行'
const TOKEN_KEY = 'hellobike'
const API_URL = 'https://gameapi.hellobike.com/api'
const UA = 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148; app=easybike; version=5.35.0'
if (typeof $request !== 'undefined') {
getToken()
HELLO_BIKE.done()
} else {
;(async () => {
let token = HELLO_BIKE.getdata(TOKEN_KEY)
if (!token) {
HELLO_BIKE.msg(TASK_NAME, '请先获取 Token')
HELLO_BIKE.done()
return
}
await checkin(token).then(data => {
if (data && data.isSuccess) {
HELLO_BIKE.msg(TASK_NAME, `签到成功,获取 ${data.energy}c 能量`)
} else if (data && !data.isSuccess) {
HELLO_BIKE.msg(TASK_NAME, `重复签到`)
}
}).catch(error => {
HELLO_BIKE.msg(TASK_NAME, error.reason)
if (error.isInvalidToken) {
token = null
}
})
await share(token).then(data => {
HELLO_BIKE.log(TASK_NAME, `分享成功, ${JSON.stringify(data)}`)
}).catch(error => {
HELLO_BIKE.msg(TASK_NAME, error.reason)
if (error.isInvalidToken) {
token = null
}
})
await getEnergyList(token).then(
data => {
HELLO_BIKE.log(TASK_NAME, `获取能量:${JSON.stringify(data)}`)
return mergePromise(data.map(energy => collectEnergy(token, energy.guid)))
},
error => {
HELLO_BIKE.msg(TASK_NAME, error.reason)
if (error.isInvalidToken) {
token = null
}
},
).then(
data => {
if (Array.isArray(data) && data.length > 0) {
HELLO_BIKE.log(TASK_NAME, `收取能量: ${JSON.stringify(data)}`)
let collected = data.filter(energy => {
return energy != null
}).reduce((total, currentValue) => {
return total + currentValue.energy
}, 0)
HELLO_BIKE.msg(TASK_NAME, `收取能量成功,总共收取 ${collected}c 能量`)
}
HELLO_BIKE.done()
},
error => {
HELLO_BIKE.msg(TASK_NAME, error.reason)
HELLO_BIKE.done()
},
)
})()
}
function getToken() {
if ($request.body) {
let body = JSON.parse($request.body)
if (body && body.token) {
let token = HELLO_BIKE.getdata(TOKEN_KEY)
if (token != null) {
if (token !== body.token) {
if (!HELLO_BIKE.setdata(body.token, TOKEN_KEY)) {
HELLO_BIKE.msg(`更新 ${TASK_NAME} Token 失败‼️`)
} else {
HELLO_BIKE.msg(`更新 ${TASK_NAME} Token 成功 🎉`)
}
}
} else {
if (!HELLO_BIKE.setdata(body.token, TOKEN_KEY)) {
HELLO_BIKE.msg(`首次写入 ${TASK_NAME} Token 失败‼️`)
} else {
HELLO_BIKE.msg(`首次写入 ${TASK_NAME} Token 成功 🎉`)
}
}
}
}
}
function checkin(token) {
if (!token) {
return Promise.resolve({})
}
return new Promise((resolve, reject) => {
let action = 'happy.energy.dailyCheck.v2'
let options = {
url: API_URL,
headers: {'User-Agent': UA},
body: JSON.stringify({
action,
token,
ticket: '',
}),
}
HELLO_BIKE.post(options, (error, response, data) => {
if (error) {
HELLO_BIKE.log(TASK_NAME, `签到失败error${error}`)
reject(new RequestFailed(action, error))
return
}
let result = JSON.parse(data)
if (result && result.code === 0 && result.data) {
resolve(result.data)
} else {
HELLO_BIKE.log(TASK_NAME, `签到失败response${data}`)
reject(new RequestFailed(action, result.msg, result.code === 103))
}
})
})
}
function share(token) {
if (!token) {
return Promise.resolve({})
}
return new Promise((resolve, reject) => {
let action = 'happy.energy.dailyShare'
let options = {
url: API_URL,
headers: {'User-Agent': UA},
body: JSON.stringify({
token,
action,
ticket: '',
}),
}
HELLO_BIKE.post(options, (error, response, data) => {
if (error) {
HELLO_BIKE.log(TASK_NAME, `分享失败error${error}`)
reject(new RequestFailed(action, error))
return
}
let result = JSON.parse(data)
if (result && result.code === 0) {
resolve(result)
} else {
HELLO_BIKE.log(TASK_NAME, `分享失败response${data}`)
reject(new RequestFailed(action, result.msg, result.code === 103))
}
})
})
}
function getEnergyList(token) {
if (!token) {
return Promise.resolve([])
}
return new Promise((resolve, reject) => {
let action = 'happy.energy.getEnergyList'
let options = {
url: API_URL,
headers: {'User-Agent': UA},
body: JSON.stringify({
token,
action,
ticket: '',
limit: 6,
}),
}
HELLO_BIKE.post(options, (error, response, data) => {
if (error) {
HELLO_BIKE.log(TASK_NAME, `获取能量失败error${error}`)
reject(new RequestFailed(action, error))
return
}
let result = JSON.parse(data)
if (result && result.code === 0 && result.data) {
resolve(result.data)
} else {
HELLO_BIKE.log(TASK_NAME, `获取能量失败response${data}`)
reject(new RequestFailed(action, result.msg, result.code === 103))
}
})
})
}
function collectEnergy(token, energyGuid) {
if (!token) {
return Promise.resolve({})
}
return new Promise((resolve, reject) => {
let action = 'happy.energy.collectEnergy'
let options = {
url: API_URL,
headers: {'User-Agent': UA},
body: JSON.stringify({
token,
action,
ticket: '',
energyGuid,
}),
}
HELLO_BIKE.post(options, (error, response, data) => {
if (error) {
HELLO_BIKE.log(TASK_NAME, `收取能量失败error${error}`)
reject(new RequestFailed(action, error))
return
}
let result = JSON.parse(data)
if (result && result.code === 0 && result.data) {
resolve(result.data)
} else {
HELLO_BIKE.log(TASK_NAME, `收取能量失败response${data}`)
reject(new RequestFailed(action, result.msg, result.code === 103))
}
})
})
}
function mergePromise(promises = []) {
let array = []
let sequence = Promise.resolve([])
promises.forEach(promise => {
sequence = sequence.then(() => promise).then(data => {
array.push(data)
return array
})
})
return sequence
}
function init() {
isSurge = () => {
return undefined !== this.$httpClient
}
isQuanX = () => {
return undefined !== this.$task
}
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 = (title, msg) => {
console.log(`${title}:\n${msg}\n`)
}
get = (options, callback) => {
if (isQuanX()) {
if (typeof options == 'string') options = {url: options}
options['method'] = 'GET'
return $task.fetch(options).then(
response => {
response['status'] = response.statusCode
callback(null, response, response.body)
},
reason => callback(reason.error, null, null),
)
}
if (isSurge()) return $httpClient.get(options, callback)
}
post = (options, callback) => {
if (isQuanX()) {
if (typeof options == 'string') options = {url: options}
options['method'] = 'POST'
$task.fetch(options).then(
response => {
response['status'] = response.statusCode
callback(null, response, response.body)
},
reason => callback(reason.error, null, null),
)
}
if (isSurge()) $httpClient.post(options, callback)
}
done = (value = {}) => {
$done(value)
}
return {isSurge, isQuanX, msg, log, getdata, setdata, get, post, done}
}
function RequestFailed(action = '', reason = '', isInvalidToken = false) {
this.action = action
this.reason = reason
this.isInvalidToken = isInvalidToken
}
RequestFailed.prototype = {
constructor: RequestFailed,
}

View File

@ -1,103 +0,0 @@
# HYCAN合创
> 代码已同时兼容 Surge & QuanX, 使用同一份签到脚本即可
> 感谢 [@danchaw](https://github.com/danchaw) PR
## 配置 (Surge)
```properties
[MITM]
wxprdapplet.gac-nio.com
[Script]
http-request ^https:\/\/wxprdapplet\.gac-nio\.com\/community\/userSignIn\/simpleAuth\/front\/.*\/sign$ script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/hycan/hycan.cookie.js
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/hycan/hycan.js
```
## 配置 (QuanX)
```properties
[MITM]
wxprdapplet.gac-nio.com
[rewrite_local]
# [商店版]
^https:\/\/wxprdapplet\.gac-nio\.com\/community\/userSignIn\/simpleAuth\/front\/.*\/sign$ url script-request-header hycan.cookie.js
# [TestFlight]
^https:\/\/wxprdapplet\.gac-nio\.com\/community\/userSignIn\/simpleAuth\/front\/.*\/sign$ url script-request-header https://raw.githubusercontent.com/chavyleung/scripts/master/hycan/hycan.cookie.js
[task_local]
# [商店版]
1 0 * * * hycan.js
# [TestFlight]
1 0 * * * https://raw.githubusercontent.com/chavyleung/scripts/master/hycan/hycan.js
```
## 说明
1. 先把`wxprdapplet.gac-nio.com`加到`[MITM]`
2. 再配置重写规则:
- Surge: 把两条远程脚本放到`[Script]`
- QuanX: 把`hycan.js`传到`On My iPhone - Quantumult X - Scripts` (传到 iCloud 相同目录也可, 注意要打开 quanx 的 iCloud 开关)
3. 打开 APP[HYCAN合创](https://apps.apple.com/cn/app/hycan%E5%90%88%E5%88%9B-%E5%B9%BF%E6%B1%BD%E8%94%9A%E6%9D%A5/id1464838502) 然后手动签到 1 次, 系统提示: `获取Cookie: 成功`
4. 最后就可以把第 1 条脚本注释掉了
5. 运行一次脚本, 如果提示重复签到, 那就算成功了!
> 第 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)
[@danchaw](https://github.com/danchaw)

View File

@ -1,68 +0,0 @@
const cookieName = 'HYCAN合创'
const signurlKey = 'signurl_hycan'
const signheaderKey = 'signheader_hycan'
const hycan = init()
if ($request && $request.method == 'POST') {
const signurlVal = $request.url
const signheaderVal = JSON.stringify($request.headers)
if (signurlVal) hycan.setdata(signurlVal, signurlKey)
if (signheaderVal) hycan.setdata(signheaderVal, signheaderKey)
hycan.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))
}
}
put = (url, cb) => {
if (isSurge()) {
$httpClient.put(url, cb)
}
if (isQuanX()) {
url.method = 'PUT'
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
}
}
done = (value = {}) => {
$done(value)
}
return {isSurge, isQuanX, msg, log, getdata, setdata, get, post, put, done}
}
hycan.done()

View File

@ -1,83 +0,0 @@
const cookieName = 'HYCAN合创'
const signurlKey = 'signurl_hycan'
const signheaderKey = 'signheader_hycan'
const hycan = init()
const signurlVal = hycan.getdata(signurlKey)
const signheaderVal = hycan.getdata(signheaderKey)
sign()
function sign() {
const url = {url: signurlVal, headers: JSON.parse(signheaderVal)}
hycan.post(url, (error, response, data) => {
hycan.log(`${cookieName}, data: ${data}`)
const title = `${cookieName}`
let subTitle = ''
let detail = ''
const result = JSON.parse(data)
if (result.data.addScore == true) {
subTitle = `签到结果: 成功`
detail = `签到积分: ${result.data.score}, 签到详情: ${result.data.msg}`
} else if (result.data.addScore == false) {
subTitle = `签到结果: 成功 (重复签到)`
} else {
subTitle = `签到结果: 失败`
detail = `说明: token失效, ${result.msg}`
}
hycan.msg(title, subTitle, detail)
hycan.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.body))
}
}
post = (url, cb) => {
if (isSurge()) {
$httpClient.post(url, cb)
}
if (isQuanX()) {
url.method = 'POST'
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
}
}
put = (url, cb) => {
if (isSurge()) {
$httpClient.put(url, cb)
}
if (isQuanX()) {
url.method = 'PUT'
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
}
}
done = (value = {}) => {
$done(value)
}
return {isSurge, isQuanX, msg, log, getdata, setdata, get, post, put, done}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,405 +0,0 @@
const $ = new Env('京东618')
$.VAL_url = $.getdata('chavy_url_jd816')
$.VAL_body = $.getdata('chavy_body_jd816')
$.VAL_headers = $.getdata('chavy_headers_jd816')
$.VAL_isSignShop = $.getdata('CFG_618_isSignShop') || 'true'
$.VAL_isJoinBrand = $.getdata('CFG_618_isJoinBrand') || 'false'
$.VAL_radommsMin = $.getdata('CFG_618_radomms_min') || '2000'
$.VAL_radommsMax = $.getdata('CFG_618_radomms_max') || '5000'
!(async () => {
$.log('', `🔔 ${$.name}, 开始!`, '')
await getData()
await getActs()
await getShops()
await execActs()
showmsg()
})()
.catch((e) => {
$.log('', `${$.name}, 失败! 原因: ${e}!`, '')
})
.finally(() => {
$.msg($.name, $.subt, $.desc), $.log('', `🔔 ${$.name}, 结束!`, ''), $.done()
})
function getData() {
return new Promise((resove) => {
$.post(taskurl('cakebaker_getHomeData'), (error, response, data) => {
try {
if (error) throw new Error(error)
const _info = JSON.parse(data).data.result.cakeBakerInfo
$.secretp = _info.secretp
if (!$.secretp) throw new Error('获取 secretp 失败!')
$.log(`${$.name}, 获取密钥!`)
$.log(` 密钥 = ${$.secretp.slice(0, 10)}...`)
$.log(` 等级 = ${_info.raiseInfo.scoreLevel}`)
$.log(` 分数 = ${_info.raiseInfo.totalScore} => ${_info.raiseInfo.nextLevelScore}`)
$.log(` 延时 = ${$.VAL_radommsMin} => ${$.VAL_radommsMax} 毫秒`, '')
} catch (e) {
$.log(`❗️ ${$.name}, 获取密钥!`, ` error = ${error || e}`, `response = ${JSON.stringify(response)}`, `data = ${data}`, '')
} finally {
resove()
}
})
})
}
function getShops() {
return new Promise((resove) => {
$.post(taskurl('cakebaker_bigBrandHomeData'), (error, response, data) => {
try {
$.log(`${$.name}, 获取商店!`)
if (error) throw new Error(error)
$.shopActs = []
JSON.parse(data).data.result.bigBrandList.forEach((_shopa) => {
const _shopact = {
_raw: _shopa,
id: _shopa.venderId,
name: _shopa.name
}
$.shopActs.push(_shopact)
})
$.log(` 商店数量 = ${$.shopActs.length}`, '')
} catch (e) {
$.log(`❗️ ${$.name}, 获取商店!`, ` error = ${error || e}`, `response = ${JSON.stringify(response)}`, `data = ${data}`, '')
} finally {
resove()
}
})
})
}
function getActs() {
return new Promise((resove) => {
$.post(taskurl('cakebaker_getTaskDetail'), (error, response, data) => {
try {
$.log(`${$.name}, 获取活动!`)
if (error) throw new Error(error)
$.acts = []
JSON.parse(data).data.result.taskVos.forEach((_a) => {
const _act = {
_raw: _a,
id: _a.taskId,
name: _a.taskName,
times: _a.times,
maxTimes: _a.maxTimes,
waitDuration: _a.waitDuration === 0 ? 1 : _a.waitDuration,
isProd: _a.productInfoVos ? true : false,
isBrand: _a.shoppingActivityVos && _a.taskId === 42 ? true : false,
tasks: []
}
const _vo = _a[Object.keys(_a).find((key) => (_a[key] && _a[key].itemId) || (_a[key] && _a[key][0] && _a[key][0].itemId))]
if (Array.isArray(_vo)) {
_vo.forEach((_task) => _act.tasks.push({
_raw: _task,
id: _task.itemId,
name: _task.title || _task.shopName || _task.taskName || '未知名称'
}))
} else {
_act.tasks = Array(_act.maxTimes - _act.times).fill({
_raw: _vo,
id: _vo.itemId,
name: _act.name
})
}
$.acts.push(_act)
})
if (!$.acts) throw new Error('获取活动失败!')
$.log(` 活动数量 = ${$.acts.length}`, '')
} catch (e) {
$.log(`❗️ ${$.name}, 获取活动!`, ` error = ${error || e}`, `response = ${JSON.stringify(response)}`, `data = ${data}`, '')
} finally {
resove()
}
})
})
}
async function execActs() {
$.log(`${$.name}, 执行活动!`)
for (let _actIdx = 0; _actIdx < $.acts.length; _actIdx++) {
const _act = $.acts[_actIdx]
$.log(` ${_actIdx + 1}. ${_act.name} (${_act.times}/${_act.maxTimes})`)
if (_act.times === _act.maxTimes) {
$.log(` @跳过: 全部完成!`, '')
continue
}
// 跳过:邀请好友、加入战队
if ([2, 12].includes(_act.id)) {
$.log(' 跳过!', '')
continue
}
// 甄选优品
else if (_act.isProd) {
await getProdAct(_act)
for (let subactIdx = 0; subactIdx < _act.subacts.length; subactIdx++) {
const subact = _act.subacts[subactIdx]
$.log(` ${subactIdx + 1}. ${subact.name} (${subact.times}/${subact.maxTimes})`)
if (subact.times === subact.maxTimes) {
$.log(` @跳过: 全部完成!`, '')
continue
}
for (let subataskIdx = 0; subataskIdx < subact.tasks.length; subataskIdx++) {
const subatask = subact.tasks[subataskIdx]
$.log(` ${subataskIdx + 1}. ${subatask.name.slice(0, 15)}...`)
if (subatask._raw.status && subatask._raw.status === 2) {
$.log(` @跳过: 已经做过!`, '')
continue
}
await sendtask(subact, subatask, true)
$.log(` @认领任务: ${subatask.isClaimSuc ? '🟢' : '🔴'}`)
if (subatask.isskip) {
$.log(` @跳过: ${subatask.msg}`)
const randomms = genRadomms()
$.log(` @等待: 8 秒 + ${randomms} 毫秒`, '')
await new Promise($.wait(8000 + randomms))
} else {
const randomms = genRadomms()
$.log(` @等待: ${subact.waitDuration} 秒 + ${randomms} 毫秒`)
await new Promise($.wait(subact.waitDuration * 1000 + randomms))
await sendtask(subact, subatask)
$.log(` @完成任务: ${subatask.isExecSuc ? '🟢' : '🔴'}`)
$.log(` @等待: 5 秒 + ${randomms} 毫秒`, '')
await new Promise($.wait(5000 + randomms))
}
}
}
}
// 开通会员
else if (_act.isBrand) {
if ($.VAL_isJoinBrand === 'true' || $.VAL_isJoinBrand === true) {
for (let taskIdx = 0; taskIdx < _act.tasks.length; taskIdx++) {
const task = _act.tasks[taskIdx]
$.log(` ${taskIdx + 1}. ${task.name}`)
await joinBrand(task)
$.log(` @加入会员: ${task.isJoinSuc ? '🟢' : '🔴'}`)
const randomms = genRadomms()
$.log(` @等待: ${_act.waitDuration} 秒 + ${randomms} 毫秒`)
await new Promise($.wait(_act.waitDuration * 1000 + randomms))
await brandAward(task)
$.log(` @完成任务: ${task.isAwardSuc ? '🟢' : '🔴'}`)
$.log(` @等待: 5 秒 + ${randomms} 毫秒`, '')
await new Promise($.wait(5000 + randomms))
}
} else {
$.log(` @跳过: BoxJs 设置为 关闭 品牌会员!`, '')
}
}
// 普通任务
else {
for (let taskIdx = 0; taskIdx < _act.tasks.length; taskIdx++) {
const task = _act.tasks[taskIdx]
$.log(` ${taskIdx + 1}. ${task.name}`)
if (task._raw.status && task._raw.status === 2) {
$.log(` @跳过: 已经做过!`, '')
continue
}
await sendtask(_act, task, true)
$.log(` @认领任务: ${task.isClaimSuc ? '🟢' : '🔴'}`)
if (task.isskip || task.ishot) {
$.log(` @跳过: ${task.msg}`)
const randomms = genRadomms()
$.log(` @等待: 8 秒 + ${randomms} 毫秒`, '')
await new Promise($.wait(8000 + randomms))
} else {
const randomms = genRadomms()
$.log(` @等待: ${_act.waitDuration} 秒 + ${randomms} 毫秒`)
await new Promise($.wait(_act.waitDuration * 1000 + randomms))
await sendtask(_act, task)
$.log(` @完成任务: ${task.isExecSuc ? '🟢' : '🔴'}`)
$.log(` @等待: 5 秒 + ${randomms} 毫秒`, '')
await new Promise($.wait(5000 + randomms))
}
}
}
}
// 商店签到
$.log(` ${$.acts.length + 1}. 商店签到 (${$.shopActs.length})`)
if ($.VAL_isSignShop === 'true' || $.VAL_isSignShop === true) {
for (let _shopIdx = 0; _shopIdx < $.shopActs.length; _shopIdx++) {
const shop = $.shopActs[_shopIdx]
$.log(` ${_shopIdx + 1}. ${shop.name}`)
await signshop(shop)
shop.msg = /,/.test(shop.msg) ? shop.msg.split(',')[1] : shop.msg
$.log(` @签到: ${shop.isSuc ? '🟢 已领取!' : shop.code === 402 ? '⚪️ 无效活动!' : `🔴 ${shop.msg}`}`)
const randomms = genRadomms()
$.log(` @等待: 8 秒 + ${randomms} 毫秒`, '')
await new Promise($.wait(8000 + randomms))
}
} else {
$.log(` @跳过: BoxJs 设置为 关闭 商店签到!`, '')
}
}
// 商品类活动
function getProdAct(act) {
return new Promise((resove) => {
const body = {taskIds: act.tasks.map((task) => task.id).toString()}
$.post(taskurl('cakebaker_getFeedDetail', JSON.stringify(body)), (error, response, data) => {
try {
const _result = JSON.parse(data).data.result
const _vo = _result[Object.keys(_result).find((key) => Array.isArray(_result[key] && _result[key][0] && _result[key][0].productInfoVos))]
act.subacts = []
_vo.forEach((_suba) => {
const _subact = {
_raw: _suba,
id: _suba.taskId,
name: _suba.taskName,
times: _suba.times,
maxTimes: _suba.maxTimes,
waitDuration: _suba.waitDuration === 0 ? 1 : _suba.waitDuration,
isProd: _suba.productInfoVos ? true : false,
tasks: []
}
_suba.productInfoVos.slice(0, 5).forEach((_prodvo) => {
const _taskname = _prodvo.skuName || _prodvo.title || _prodvo.shopName || _prodvo.taskName || '未知名称'
_subact.tasks.push({
_raw: _prodvo,
id: _prodvo.itemId,
name: _taskname
})
})
act.subacts.push(_subact)
})
} catch (e) {
$.log(`❗️ ${$.name}, 执行商品类活动!`, ` error = ${error || e}`, `response = ${JSON.stringify(response)}`, `data = ${data}`, '')
} finally {
resove()
}
})
})
}
function sendtask(act, task, isClaim = false) {
return new Promise((resove) => {
const body = {
taskId: act.id,
itemId: task.id,
actionType: isClaim ? 1 : undefined,
safeStr: JSON.stringify({secretp: $.secretp})
}
$.post(taskurl('cakebaker_ckCollectScore', JSON.stringify(body)), (error, response, data) => {
try {
const _data = JSON.parse(data)
const _issuc = _data.data.bizCode === 0 || _data.data.bizCode === -5 || _data.data.bizCode === -15
if (isClaim) task.isClaimSuc = _issuc
else task.isExecSuc = _issuc
task.isskip = _data.data.bizCode === -5
task.ishot = _data.data.bizCode === -15
task.msg = _data.data.bizMsg || '无'
} catch (e) {
if (isClaim) task.isClaimSuc = false
else task.isExecSuc = false
task.isskip = false
task.ishot = false
task.msg = error || e
} finally {
resove()
}
})
})
}
function signshop(shop) {
return new Promise((resove) => {
const body = {channel: 2, venderId: shop.id}
$.post(taskurl('interact_center_sign_collectGift', JSON.stringify(body)), (error, response, data) => {
try {
const _data = JSON.parse(data)
shop.isSuc = _data.code === 407000005 || _data.code === 200 ? true : false
shop.code = _data.code
shop.msg = _data.msg
} catch (e) {
shop.isSuc = false
shop.msg = error || e
} finally {
resove()
}
})
})
}
function joinBrand(task) {
return new Promise((resove) => {
const body = {
venderId: task._raw.copy1,
shopId: task._raw.copy1,
bindByVerifyCodeFlag: 1,
registerExtend: {},
writeChildFlag: 0,
channel: 4032
}
const joinurl = `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body=${encodeURIComponent(JSON.stringify(body))}&client=H5&clientVersion=8.5.6&uuid=88888`
const url = {url: joinurl, headers: JSON.parse($.VAL_headers)}
delete url.headers['Content-Length']
$.get(url, (error, response, data) => {
try {
const _data = JSON.parse(data)
task.isJoinSuc = _data.busiCode === '0'
task.msg = _data.message || '无'
} catch (e) {
task.isJoinSuc = false
task.msg = error || e
} finally {
resove()
}
})
})
}
function brandAward(task) {
return new Promise((resove) => {
const body = {venderId: task._raw.copy1, itemId: task.id}
$.post(taskurl('cakebaker_taskBigBrandAward', JSON.stringify(body)), (error, response, data) => {
try {
const _data = JSON.parse(data)
const _issuc = _data.data.bizCode === 0 || _data.data.bizCode === -5 || _data.data.bizCode === -15
task.isAwardSuc = _issuc
task.msg = _data.data.bizMsg || '无'
} catch (e) {
task.isAwardSuc = false
task.msg = error || e
} finally {
resove()
}
})
})
}
function taskurl(fid, body = '{}') {
const url = {url: `https://api.m.jd.com/client.action`}
url.headers = JSON.parse($.VAL_headers)
url.body = `functionId=${fid}&body=${body}&client=wh5&clientVersion=1.0.0`
return url
}
function genRadomms() {
const max = $.VAL_radommsMax * 1
const min = $.VAL_radommsMin * 1
return parseInt(Math.random() * (max - min + 1) + min, 10)
}
function showmsg() {
}
// prettier-ignore
function Env(t) {
this.name = t, this.logs = [], this.isSurge = (() => "undefined" != typeof $httpClient), this.isQuanX = (() => "undefined" != typeof $task), this.log = ((...t) => {
this.logs = [...this.logs, ...t], t ? console.log(t.join("\n")) : console.log(this.logs.join("\n"))
}), this.msg = ((t = this.name, s = "", i = "") => {
this.isSurge() && $notification.post(t, s, i), this.isQuanX() && $notify(t, s, i);
const e = ["", "==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];
t && e.push(t), s && e.push(s), i && e.push(i), console.log(e.join("\n"))
}), this.getdata = (t => this.isSurge() ? $persistentStore.read(t) : this.isQuanX() ? $prefs.valueForKey(t) : void 0), this.setdata = ((t, s) => this.isSurge() ? $persistentStore.write(t, s) : this.isQuanX() ? $prefs.setValueForKey(t, s) : void 0), this.get = ((t, s) => this.send(t, "GET", s)), this.wait = ((t, s = t) => i => setTimeout(() => i(), Math.floor(Math.random() * (s - t + 1) + t))), this.post = ((t, s) => this.send(t, "POST", s)), this.send = ((t, s, i) => {
if (this.isSurge()) {
const e = "POST" == s ? $httpClient.post : $httpClient.get;
e(t, (t, s, e) => {
s && (s.body = e, s.statusCode = s.status), i(t, s, e)
})
}
this.isQuanX() && (t.method = s, $task.fetch(t).then(t => {
t.status = t.statusCode, i(null, t, t.body)
}, t => i(t.error, t, t)))
}), this.done = ((t = {}) => $done(t))
}

View File

@ -1,106 +0,0 @@
const $ = new Env('京东618炸弹')
$.VAL_url = $.getdata('chavy_url_jd816')
$.VAL_body = $.getdata('chavy_body_jd816')
$.VAL_headers = $.getdata('chavy_headers_jd816')
$.VAL_boomtimes = $.getdata('CFG_BOOM_times_JD618') || 1
$.VAL_boominterval = $.getdata('CFG_BOOM_interval_JD618') || 100
!(async () => {
$.log('', `🔔 ${$.name}, 开始!`, '')
await boom()
await showmsg()
})()
.catch((e) => {
$.log('', `${$.name}, 失败! 原因: ${e}!`, '')
})
.finally(() => {
$.log('', `🔔 ${$.name}, 结束!`, ''), $.done()
})
async function boom() {
$.boomacts = []
$.boomdesc = []
for (let boomIdx = 0; boomIdx < $.VAL_boomtimes; boomIdx++) {
const isLastBoom = boomIdx === $.VAL_boomtimes - 1
$.boomdesc.push(`💣 [${moment('mm:ss')}] 发送第 ${boomIdx + 1} 个炸弹 ${isLastBoom ? '(最后一个)' : ''}`)
const boomAct = new Promise((resove) => {
$.post(taskurl('cakebaker_pk_getCakeBomb'), (error, response, data) => {
try {
if (error) throw new Error(error)
const _data = JSON.parse(data)
const _issuc = _data.code === 0 && _data.data && _data.data.bizCode === 0
$.boom = {isSuc: _issuc, boomIdx, ..._data.data.result}
if (isLastBoom) $.boomdesc.push(`❕ [${moment('mm:ss')}] 第 ${boomIdx + 1} 炸: ${$.boom.tip}`)
} catch (e) {
$.log(`❗️ ${$.name}, 执行失败!`, ` error = ${error || e}`, `response = ${JSON.stringify(response)}`, `data = ${data}`, '')
} finally {
resove()
}
})
})
$.boomacts.push(boomAct)
if (isLastBoom) await boomAct
await new Promise($.wait($.VAL_boominterval * 1))
$.boomdesc.push(`❕ [${moment('mm:ss')}] 等待: ${$.VAL_boominterval} 毫秒!`)
}
}
function moment(fmt) {
const now = new Date()
const o = {
'M+': now.getMonth() + 1,
'd+': now.getDate(),
'h+': now.getHours(),
'm+': now.getMinutes(),
's+': now.getSeconds(),
'q+': Math.floor((now.getMonth() + 3) / 3),
S: now.getMilliseconds()
}
if (/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (now.getFullYear() + '').substr(4 - RegExp.$1.length))
}
for (var k in o) {
if (new RegExp('(' + k + ')').test(fmt)) {
fmt = fmt.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length))
}
}
return fmt
}
function taskurl(fid, body = '{}') {
const url = {url: `https://api.m.jd.com/client.action`}
url.headers = JSON.parse($.VAL_headers)
url.body = `functionId=${fid}&body=${body}&client=wh5&clientVersion=1.0.0`
return url
}
async function showmsg() {
await Promise.all($.boomacts)
$.subt = `我方: ${$.boom.groupLevel || '❓'}层, 对方: ${$.boom.opponentLevel || 0}层, 炸掉: ${$.boom.destroyLevel || 0}`
$.desc = [$.boom.tip || '提示: 无!', '点击查看详情', ...$.boomdesc]
$.msg(`${$.name} (第 ${$.boom.boomIdx + 1} 炸)`, $.subt, $.desc.join('\n'))
// return new Promise((resove) => {
// resove()
// })
}
// prettier-ignore
function Env(t) {
this.name = t, this.logs = [], this.isSurge = (() => "undefined" != typeof $httpClient), this.isQuanX = (() => "undefined" != typeof $task), this.log = ((...t) => {
this.logs = [...this.logs, ...t], t ? console.log(t.join("\n")) : console.log(this.logs.join("\n"))
}), this.msg = ((t = this.name, s = "", i = "") => {
this.isSurge() && $notification.post(t, s, i), this.isQuanX() && $notify(t, s, i);
const e = ["", "==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];
t && e.push(t), s && e.push(s), i && e.push(i), console.log(e.join("\n"))
}), this.getdata = (t => this.isSurge() ? $persistentStore.read(t) : this.isQuanX() ? $prefs.valueForKey(t) : void 0), this.setdata = ((t, s) => this.isSurge() ? $persistentStore.write(t, s) : this.isQuanX() ? $prefs.setValueForKey(t, s) : void 0), this.get = ((t, s) => this.send(t, "GET", s)), this.wait = ((t, s = t) => i => setTimeout(() => i(), Math.floor(Math.random() * (s - t + 1) + t))), this.post = ((t, s) => this.send(t, "POST", s)), this.send = ((t, s, i) => {
if (this.isSurge()) {
const e = "POST" == s ? $httpClient.post : $httpClient.get;
e(t, (t, s, e) => {
s && (s.body = e, s.statusCode = s.status), i(t, s, e)
})
}
this.isQuanX() && (t.method = s, $task.fetch(t).then(t => {
t.status = t.statusCode, i(null, t, t.body)
}, t => i(t.error, t, t)))
}), this.done = ((t = {}) => $done(t))
}

View File

@ -1,72 +0,0 @@
/**
*
* 进入 叠蛋糕 主页获取 Cookies
*
* Surge:
* Rewrite: JD618 = type=http-request,pattern=^https:\/\/api.m.jd.com\/client.action\?functionId=cakebaker_getHomeData,script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/jd/jd.618.cookie.js,requires-body=true
* Tasks: JD618 = type=cron,cronexp="10,30,50 0,1 * * *",script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/jd/jd.618.js,wake-system=true,timeout=1200
* Tasks: JD618.Boom = type=cron,cronexp="0 10,12,18,20,21 * * *",script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/jd/jd.618.boom.js,wake-system=true
* Tasks: JD618.Boom = type=cron,cronexp="30 21 * * *",script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/jd/jd.618.boom.js,wake-system=true
*
* QuanX:
* ^https:\/\/api.m.jd.com\/client.action\?functionId=cakebaker_getHomeData url script-request-body https://raw.githubusercontent.com/chavyleung/scripts/master/jd/jd.618.cookie.js
*
* [task_local]
* # 远程
* 10,30,50 0,1 * * * https://raw.githubusercontent.com/chavyleung/scripts/master/jd/jd.618.adapt.js, tag=京东618
* 0 10,12,18,20,21 * * * https://raw.githubusercontent.com/chavyleung/scripts/master/jd/jd.618.boom.js, tag=京东618炸弹
* 30 21 * * * https://raw.githubusercontent.com/chavyleung/scripts/master/jd/jd.618.boom.js, tag=京东618炸弹
*
* Loon:
* cron "10,30,50 0,1 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/jd/jd.618.adapt.js, timeout=600, tag=京东618
* cron "0 10,12,18,20,21 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/jd/jd.618.boom.js, tag=京东618炸弹
* cron "30 21 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/jd/jd.618.boom.js, tag=京东618炸弹
* http-request ^https:\/\/api.m.jd.com\/client.action\?functionId=cakebaker_getHomeData script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/jd/jd.618.cookie.js,requires-body=true
*
* [MITM]
* hostname = api.m.jd.com
*/
const $ = new Env('京东618')
!(async () => {
$.log('', `🔔 ${$.name}, 获取会话: 开始!`, '')
const VAL_url = $request.url
const VAL_body = $request.body
const VAL_headers = JSON.stringify($request.headers)
if (VAL_url && VAL_body && VAL_headers) {
$.setdata($request.url, 'chavy_url_jd816')
$.setdata($request.body, 'chavy_body_jd816')
$.setdata(JSON.stringify($request.headers), 'chavy_headers_jd816')
$.subt = '获取会话: 成功!'
}
})()
.catch((e) => {
$.subt = '获取会话: 失败!'
$.desc = `原因: ${e}`
$.log(`${$.name}, 获取会话: 失败! 原因: ${e}!`)
})
.finally(() => {
$.msg($.name, $.subt, $.desc), $.log('', `🔔 ${$.name}, 获取会话: 结束!`, ''), $.done()
})
// prettier-ignore
function Env(t) {
this.name = t, this.logs = [], this.isSurge = (() => "undefined" != typeof $httpClient), this.isQuanX = (() => "undefined" != typeof $task), this.log = ((...t) => {
this.logs = [...this.logs, ...t], t ? console.log(t.join("\n")) : console.log(this.logs.join("\n"))
}), this.msg = ((t = this.name, s = "", i = "") => {
this.isSurge() && $notification.post(t, s, i), this.isQuanX() && $notify(t, s, i);
const e = ["", "==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];
t && e.push(t), s && e.push(s), i && e.push(i), console.log(e.join("\n"))
}), this.getdata = (t => this.isSurge() ? $persistentStore.read(t) : this.isQuanX() ? $prefs.valueForKey(t) : void 0), this.setdata = ((t, s) => this.isSurge() ? $persistentStore.write(t, s) : this.isQuanX() ? $prefs.setValueForKey(t, s) : void 0), this.get = ((t, s) => this.send(t, "GET", s)), this.wait = ((t, s = t) => i => setTimeout(() => i(), Math.floor(Math.random() * (s - t + 1) + t))), this.post = ((t, s) => this.send(t, "POST", s)), this.send = ((t, s, i) => {
if (this.isSurge()) {
const e = "POST" == s ? $httpClient.post : $httpClient.get;
e(t, (t, s, e) => {
s && (s.body = e, s.statusCode = s.status), i(t, s, e)
})
}
this.isQuanX() && (t.method = s, $task.fetch(t).then(t => {
t.status = t.statusCode, i(null, t, t.body)
}, t => i(t.error, t, t)))
}), this.done = ((t = {}) => $done(t))
}

View File

@ -1,9 +0,0 @@
#!name=Chavy iOS JD618 Cookies Module
#!desc=获取京东 618 活动会话信息
#!system=ios
[Script]
Rewrite: JD618 = type=http-request,pattern=^https:\/\/api.m.jd.com\/client.action\?functionId=cakebaker_getHomeData,script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/jd/jd.618.cookie.js,requires-body=true,debug=true
[MITM]
hostname = %INSERT%, api.m.jd.com

View File

@ -1,405 +0,0 @@
const $ = new Env('京东618')
$.VAL_url = $.getdata('chavy_url_jd816')
$.VAL_body = $.getdata('chavy_body_jd816')
$.VAL_headers = $.getdata('chavy_headers_jd816')
$.VAL_isSignShop = $.getdata('CFG_618_isSignShop') || 'true'
$.VAL_isJoinBrand = $.getdata('CFG_618_isJoinBrand') || 'false'
$.VAL_radommsMin = $.getdata('CFG_618_radomms_min') || '2000'
$.VAL_radommsMax = $.getdata('CFG_618_radomms_max') || '5000'
!(async () => {
$.log('', `🔔 ${$.name}, 开始!`, '')
await getData()
await getActs()
await getShops()
await execActs()
showmsg()
})()
.catch((e) => {
$.log('', `${$.name}, 失败! 原因: ${e}!`, '')
})
.finally(() => {
$.msg($.name, $.subt, $.desc), $.log('', `🔔 ${$.name}, 结束!`, ''), $.done()
})
function getData() {
return new Promise((resove) => {
$.post(taskurl('cakebaker_getHomeData'), (error, response, data) => {
try {
if (error) throw new Error(error)
const _info = JSON.parse(data).data.result.cakeBakerInfo
$.secretp = _info.secretp
if (!$.secretp) throw new Error('获取 secretp 失败!')
$.log(`${$.name}, 获取密钥!`)
$.log(` 密钥 = ${$.secretp.slice(0, 10)}...`)
$.log(` 等级 = ${_info.raiseInfo.scoreLevel}`)
$.log(` 分数 = ${_info.raiseInfo.totalScore} => ${_info.raiseInfo.nextLevelScore}`)
$.log(` 延时 = ${$.VAL_radommsMin} => ${$.VAL_radommsMax} 毫秒`, '')
} catch (e) {
$.log(`❗️ ${$.name}, 获取密钥!`, ` error = ${error || e}`, `response = ${JSON.stringify(response)}`, `data = ${data}`, '')
} finally {
resove()
}
})
})
}
function getShops() {
return new Promise((resove) => {
$.post(taskurl('cakebaker_bigBrandHomeData'), (error, response, data) => {
try {
$.log(`${$.name}, 获取商店!`)
if (error) throw new Error(error)
$.shopActs = []
JSON.parse(data).data.result.bigBrandList.forEach((_shopa) => {
const _shopact = {
_raw: _shopa,
id: _shopa.venderId,
name: _shopa.name
}
$.shopActs.push(_shopact)
})
$.log(` 商店数量 = ${$.shopActs.length}`, '')
} catch (e) {
$.log(`❗️ ${$.name}, 获取商店!`, ` error = ${error || e}`, `response = ${JSON.stringify(response)}`, `data = ${data}`, '')
} finally {
resove()
}
})
})
}
function getActs() {
return new Promise((resove) => {
$.post(taskurl('cakebaker_getTaskDetail'), (error, response, data) => {
try {
$.log(`${$.name}, 获取活动!`)
if (error) throw new Error(error)
$.acts = []
JSON.parse(data).data.result.taskVos.forEach((_a) => {
const _act = {
_raw: _a,
id: _a.taskId,
name: _a.taskName,
times: _a.times,
maxTimes: _a.maxTimes,
waitDuration: _a.waitDuration === 0 ? 1 : _a.waitDuration,
isProd: _a.productInfoVos ? true : false,
isBrand: _a.shoppingActivityVos && _a.taskId === 42 ? true : false,
tasks: []
}
const _vo = _a[Object.keys(_a).find((key) => (_a[key] && _a[key].itemId) || (_a[key] && _a[key][0] && _a[key][0].itemId))]
if (Array.isArray(_vo)) {
_vo.forEach((_task) => _act.tasks.push({
_raw: _task,
id: _task.itemId,
name: _task.title || _task.shopName || _task.taskName || '未知名称'
}))
} else {
_act.tasks = Array(_act.maxTimes - _act.times).fill({
_raw: _vo,
id: _vo.itemId,
name: _act.name
})
}
$.acts.push(_act)
})
if (!$.acts) throw new Error('获取活动失败!')
$.log(` 活动数量 = ${$.acts.length}`, '')
} catch (e) {
$.log(`❗️ ${$.name}, 获取活动!`, ` error = ${error || e}`, `response = ${JSON.stringify(response)}`, `data = ${data}`, '')
} finally {
resove()
}
})
})
}
async function execActs() {
$.log(`${$.name}, 执行活动!`)
for (let _actIdx = 0; _actIdx < $.acts.length; _actIdx++) {
const _act = $.acts[_actIdx]
$.log(` ${_actIdx + 1}. ${_act.name} (${_act.times}/${_act.maxTimes})`)
if (_act.times === _act.maxTimes) {
$.log(` @跳过: 全部完成!`, '')
continue
}
// 跳过:邀请好友、加入战队
if ([2, 12].includes(_act.id)) {
$.log(' 跳过!', '')
continue
}
// 甄选优品
else if (_act.isProd) {
await getProdAct(_act)
for (let subactIdx = 0; subactIdx < _act.subacts.length; subactIdx++) {
const subact = _act.subacts[subactIdx]
$.log(` ${subactIdx + 1}. ${subact.name} (${subact.times}/${subact.maxTimes})`)
if (subact.times === subact.maxTimes) {
$.log(` @跳过: 全部完成!`, '')
continue
}
for (let subataskIdx = 0; subataskIdx < subact.tasks.length; subataskIdx++) {
const subatask = subact.tasks[subataskIdx]
$.log(` ${subataskIdx + 1}. ${subatask.name.slice(0, 15)}...`)
if (subatask._raw.status && subatask._raw.status === 2) {
$.log(` @跳过: 已经做过!`, '')
continue
}
await sendtask(subact, subatask, true)
$.log(` @认领任务: ${subatask.isClaimSuc ? '🟢' : '🔴'}`)
if (subatask.isskip) {
$.log(` @跳过: ${subatask.msg}`)
const randomms = genRadomms()
$.log(` @等待: 8 秒 + ${randomms} 毫秒`, '')
await new Promise($.wait(8000 + randomms))
} else {
const randomms = genRadomms()
$.log(` @等待: ${subact.waitDuration} 秒 + ${randomms} 毫秒`)
await new Promise($.wait(subact.waitDuration * 1000 + randomms))
await sendtask(subact, subatask)
$.log(` @完成任务: ${subatask.isExecSuc ? '🟢' : '🔴'}`)
$.log(` @等待: 5 秒 + ${randomms} 毫秒`, '')
await new Promise($.wait(5000 + randomms))
}
}
}
}
// 开通会员
else if (_act.isBrand) {
if ($.VAL_isJoinBrand === 'true' || $.VAL_isJoinBrand === true) {
for (let taskIdx = 0; taskIdx < _act.tasks.length; taskIdx++) {
const task = _act.tasks[taskIdx]
$.log(` ${taskIdx + 1}. ${task.name}`)
await joinBrand(task)
$.log(` @加入会员: ${task.isJoinSuc ? '🟢' : '🔴'}`)
const randomms = genRadomms()
$.log(` @等待: ${_act.waitDuration} 秒 + ${randomms} 毫秒`)
await new Promise($.wait(_act.waitDuration * 1000 + randomms))
await brandAward(task)
$.log(` @完成任务: ${task.isAwardSuc ? '🟢' : '🔴'}`)
$.log(` @等待: 5 秒 + ${randomms} 毫秒`, '')
await new Promise($.wait(5000 + randomms))
}
} else {
$.log(` @跳过: BoxJs 设置为 关闭 品牌会员!`, '')
}
}
// 普通任务
else {
for (let taskIdx = 0; taskIdx < _act.tasks.length; taskIdx++) {
const task = _act.tasks[taskIdx]
$.log(` ${taskIdx + 1}. ${task.name}`)
if (task._raw.status && task._raw.status === 2) {
$.log(` @跳过: 已经做过!`, '')
continue
}
await sendtask(_act, task, true)
$.log(` @认领任务: ${task.isClaimSuc ? '🟢' : '🔴'}`)
if (task.isskip || task.ishot) {
$.log(` @跳过: ${task.msg}`)
const randomms = genRadomms()
$.log(` @等待: 8 秒 + ${randomms} 毫秒`, '')
await new Promise($.wait(8000 + randomms))
} else {
const randomms = genRadomms()
$.log(` @等待: ${_act.waitDuration} 秒 + ${randomms} 毫秒`)
await new Promise($.wait(_act.waitDuration * 1000 + randomms))
await sendtask(_act, task)
$.log(` @完成任务: ${task.isExecSuc ? '🟢' : '🔴'}`)
$.log(` @等待: 5 秒 + ${randomms} 毫秒`, '')
await new Promise($.wait(5000 + randomms))
}
}
}
}
// 商店签到
$.log(` ${$.acts.length + 1}. 商店签到 (${$.shopActs.length})`)
if ($.VAL_isSignShop === 'true' || $.VAL_isSignShop === true) {
for (let _shopIdx = 0; _shopIdx < $.shopActs.length; _shopIdx++) {
const shop = $.shopActs[_shopIdx]
$.log(` ${_shopIdx + 1}. ${shop.name}`)
await signshop(shop)
shop.msg = /,/.test(shop.msg) ? shop.msg.split(',')[1] : shop.msg
$.log(` @签到: ${shop.isSuc ? '🟢 已领取!' : shop.code === 402 ? '⚪️ 无效活动!' : `🔴 ${shop.msg}`}`)
const randomms = genRadomms()
$.log(` @等待: 8 秒 + ${randomms} 毫秒`, '')
await new Promise($.wait(8000 + randomms))
}
} else {
$.log(` @跳过: BoxJs 设置为 关闭 商店签到!`, '')
}
}
// 商品类活动
function getProdAct(act) {
return new Promise((resove) => {
const body = {taskIds: act.tasks.map((task) => task.id).toString()}
$.post(taskurl('cakebaker_getFeedDetail', JSON.stringify(body)), (error, response, data) => {
try {
const _result = JSON.parse(data).data.result
const _vo = _result[Object.keys(_result).find((key) => Array.isArray(_result[key] && _result[key][0] && _result[key][0].productInfoVos))]
act.subacts = []
_vo.forEach((_suba) => {
const _subact = {
_raw: _suba,
id: _suba.taskId,
name: _suba.taskName,
times: _suba.times,
maxTimes: _suba.maxTimes,
waitDuration: _suba.waitDuration === 0 ? 1 : _suba.waitDuration,
isProd: _suba.productInfoVos ? true : false,
tasks: []
}
_suba.productInfoVos.slice(0, 5).forEach((_prodvo) => {
const _taskname = _prodvo.skuName || _prodvo.title || _prodvo.shopName || _prodvo.taskName || '未知名称'
_subact.tasks.push({
_raw: _prodvo,
id: _prodvo.itemId,
name: _taskname
})
})
act.subacts.push(_subact)
})
} catch (e) {
$.log(`❗️ ${$.name}, 执行商品类活动!`, ` error = ${error || e}`, `response = ${JSON.stringify(response)}`, `data = ${data}`, '')
} finally {
resove()
}
})
})
}
function sendtask(act, task, isClaim = false) {
return new Promise((resove) => {
const body = {
taskId: act.id,
itemId: task.id,
actionType: isClaim ? 1 : undefined,
safeStr: JSON.stringify({secretp: $.secretp})
}
$.post(taskurl('cakebaker_ckCollectScore', JSON.stringify(body)), (error, response, data) => {
try {
const _data = JSON.parse(data)
const _issuc = _data.data.bizCode === 0 || _data.data.bizCode === -5 || _data.data.bizCode === -15
if (isClaim) task.isClaimSuc = _issuc
else task.isExecSuc = _issuc
task.isskip = _data.data.bizCode === -5
task.ishot = _data.data.bizCode === -15
task.msg = _data.data.bizMsg || '无'
} catch (e) {
if (isClaim) task.isClaimSuc = false
else task.isExecSuc = false
task.isskip = false
task.ishot = false
task.msg = error || e
} finally {
resove()
}
})
})
}
function signshop(shop) {
return new Promise((resove) => {
const body = {channel: 2, venderId: shop.id}
$.post(taskurl('interact_center_sign_collectGift', JSON.stringify(body)), (error, response, data) => {
try {
const _data = JSON.parse(data)
shop.isSuc = _data.code === 407000005 || _data.code === 200 ? true : false
shop.code = _data.code
shop.msg = _data.msg
} catch (e) {
shop.isSuc = false
shop.msg = error || e
} finally {
resove()
}
})
})
}
function joinBrand(task) {
return new Promise((resove) => {
const body = {
venderId: task._raw.copy1,
shopId: task._raw.copy1,
bindByVerifyCodeFlag: 1,
registerExtend: {},
writeChildFlag: 0,
channel: 4032
}
const joinurl = `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body=${encodeURIComponent(JSON.stringify(body))}&client=H5&clientVersion=8.5.6&uuid=88888`
const url = {url: joinurl, headers: JSON.parse($.VAL_headers)}
delete url.headers['Content-Length']
$.get(url, (error, response, data) => {
try {
const _data = JSON.parse(data)
task.isJoinSuc = _data.busiCode === '0'
task.msg = _data.message || '无'
} catch (e) {
task.isJoinSuc = false
task.msg = error || e
} finally {
resove()
}
})
})
}
function brandAward(task) {
return new Promise((resove) => {
const body = {venderId: task._raw.copy1, itemId: task.id}
$.post(taskurl('cakebaker_taskBigBrandAward', JSON.stringify(body)), (error, response, data) => {
try {
const _data = JSON.parse(data)
const _issuc = _data.data.bizCode === 0 || _data.data.bizCode === -5 || _data.data.bizCode === -15
task.isAwardSuc = _issuc
task.msg = _data.data.bizMsg || '无'
} catch (e) {
task.isAwardSuc = false
task.msg = error || e
} finally {
resove()
}
})
})
}
function taskurl(fid, body = '{}') {
const url = {url: `https://api.m.jd.com/client.action`}
url.headers = JSON.parse($.VAL_headers)
url.body = `functionId=${fid}&body=${body}&client=wh5&clientVersion=1.0.0`
return url
}
function genRadomms() {
const max = $.VAL_radommsMax * 1
const min = $.VAL_radommsMin * 1
return parseInt(Math.random() * (max - min + 1) + min, 10)
}
function showmsg() {
}
// prettier-ignore
function Env(t) {
this.name = t, this.logs = [], this.isSurge = (() => "undefined" != typeof $httpClient), this.isQuanX = (() => "undefined" != typeof $task), this.log = ((...t) => {
this.logs = [...this.logs, ...t], t ? console.log(t.join("\n")) : console.log(this.logs.join("\n"))
}), this.msg = ((t = this.name, s = "", i = "") => {
this.isSurge() && $notification.post(t, s, i), this.isQuanX() && $notify(t, s, i);
const e = ["", "==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];
t && e.push(t), s && e.push(s), i && e.push(i), console.log(e.join("\n"))
}), this.getdata = (t => this.isSurge() ? $persistentStore.read(t) : this.isQuanX() ? $prefs.valueForKey(t) : void 0), this.setdata = ((t, s) => this.isSurge() ? $persistentStore.write(t, s) : this.isQuanX() ? $prefs.setValueForKey(t, s) : void 0), this.get = ((t, s) => this.send(t, "GET", s)), this.wait = ((t, s = t) => i => setTimeout(() => i(), Math.floor(Math.random() * (s - t + 1) + t))), this.post = ((t, s) => this.send(t, "POST", s)), this.send = ((t, s, i) => {
if (this.isSurge()) {
const e = "POST" == s ? $httpClient.post : $httpClient.get;
e(t, (t, s, e) => {
s && (s.body = e, s.statusCode = s.status), i(t, s, e)
})
}
this.isQuanX() && (t.method = s, $task.fetch(t).then(t => {
t.status = t.statusCode, i(null, t, t.body)
}, t => i(t.error, t, t)))
}), this.done = ((t = {}) => $done(t))
}

View File

@ -1,8 +0,0 @@
#!name=Chavy iOS JD618 Task Module
#!desc=执行京东 618 活动任务
#!system=ios
[Script]
Tasks: JD618 = type=cron,cronexp="10,30,50 0,1 * * *",script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/jd/jd.618.adapt.js,wake-system=true,timeout=1200
Tasks: JD618.Boom = type=cron,cronexp="0 10,12,18,20,21 * * *",script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/jd/jd.618.boom.js,wake-system=true
Tasks: JD618.Boom = type=cron,cronexp="30 21 * * *",script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/jd/jd.618.boom.js,wake-system=true

View File

@ -1,104 +0,0 @@
# 京东到家
> 代码已同时兼容 Surge & QuanX, 使用同一份签到脚本即可
> 感谢 [@barry](https://t.me/barrymchen) 编写
>
> 感谢 [@GideonSenku](https://github.com/GideonSenku) 对代码优化
## 配置 (Surge)
```properties
[MITM]
daojia.jd.com
[Script]
http-request ^https:\/\/daojia.jd.com/client(.*?)functionId=signin(.*?)userSigninNew script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/jddj/jddj.cookie.js
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/jddj/jddj.js
```
## 配置 (QuanX)
```properties
[MITM]
daojia.jd.com
[rewrite_local]
# [商店版] QuanX v1.0.6-build194 及更早版本
# ^https:\/\/daojia.jd.com/client(.*?)functionId=signin(.*?)userSigninNew url script-request-header jddj.cookie.js
# [TestFlight] QuanX v1.0.6-build195 及以后版本
^https:\/\/daojia.jd.com/client(.*?)functionId=signin(.*?)userSigninNew url script-request-header https://raw.githubusercontent.com/chavyleung/scripts/master/jddj/jddj.cookie.js
[task_local]
1 0 * * * jddj.js
```
## 说明
1. 先把`daojia.jd.com`加到`[MITM]`
2. 再配置重写规则:
- Surge: 把两条远程脚本放到`[Script]`
- QuanX: 把`jddj.cookie.js`和`jddj.js`传到`On My iPhone - Quantumult X - Scripts` (传到 iCloud 相同目录也可, 注意要打开 quanx 的 iCloud 开关)
3. 手机App打开,`我的`> `签到有惊喜`>`签到`手机浏览器打开`https://daojia.jd.com/html/index.html`,`我的`> `签到有惊喜` >`签到`
4. 系统提示: `获取Cookie: 成功`
5. 把获取 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)
[@barry](https://t.me/barrymchen)
[@GideonSenku](https://github.com/GideonSenku)

View File

@ -1,56 +0,0 @@
const cookieName = '京东到家'
const signheaderKey = 'chen_signheader_jddj'
const chen = init()
if (this.$request) {
const signheaderVal = JSON.stringify($request.headers)
if (signheaderVal) {
chen.setdata(signheaderVal, signheaderKey)
chen.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}
}
chen.done()

View File

@ -1,75 +0,0 @@
const cookieName = '京东到家'
const signheaderKey = 'chen_signheader_jddj'
const chen = init()
const signheaderVal = chen.getdata(signheaderKey)
sign()
function sign() {
let url = {
url: `https://daojia.jd.com/client?functionId=signin%2FuserSigninNew&body=%7B%7D`,
headers: JSON.parse(signheaderVal)
}
chen.get(url, (error, response, data) => {
chen.log(`${cookieName}, data: ${data}`)
let res = JSON.parse(data)
const title = `${cookieName}`
let subTitle = ``
let detail = ``
if (res.success && res.result.points != 'undefined') {
subTitle = `签到结果:成功`
detail = `获取鲜豆:${res.result.points}`
} else if (!res.success && res.code == 202) {
subTitle = `签到结果: 失败`
detail = `说明: ${res.msg}`
} else if (!res.success && res.code == -1) {
subTitle = `签到成功,请勿重复操作`
} else {
subTitle = `未知错误,截图日志`
}
chen.msg(title, subTitle, detail)
})
}
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}
}

File diff suppressed because one or more lines are too long

View File

@ -1,91 +0,0 @@
# 芒果 TV
> 代码已同时兼容 Surge & QuanX, 使用同一份签到脚本即可
## 配置 (Surge)
```properties
[MITM]
credits.bz.mgtv.com
[Script]
http-request ^https:\/\/credits.bz.mgtv.com\/user\/creditsTake script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/mgtv/mgtv.cookie.js
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/mgtv/mgtv.js
```
## 配置 (QuanX)
```properties
[MITM]
credits.bz.mgtv.com
[rewrite_local]
^https:\/\/credits.bz.mgtv.com\/user\/creditsTake url script-request-header mgtv.cookie.js
[task_local]
1 0 * * * mgtv.js
```
## 说明
1. 先把`credits.bz.mgtv.com`加到`[MITM]`
2. 再配置重写规则:
- Surge: 把两条远程脚本放到`[Script]`
- QuanX: 把`mgtv.cookie.js`和`mgtv.js`传到`On My iPhone - Quantumult X - Scripts` (传到 iCloud 相同目录也可, 注意要打开 quanx 的 iCloud 开关)
3. 打开 APP 然后手动签到 1 次, 系统提示: `获取Cookie: 成功`
4. 最后就可以把第 1 条脚本注释掉了
5. 运行一次脚本, 如果提示重复签到, 那就算成功了!
> 第 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)

View File

@ -1,58 +0,0 @@
const cookieName = '芒果TV'
const signurlKey = 'chavy_signurl_mgtv'
const signheaderKey = 'chavy_signheader_mgtv'
const chavy = init()
if ($request && $request.method != 'OPTIONS') {
const signurlVal = $request.url
const signheaderVal = JSON.stringify($request.headers)
if (signurlVal) chavy.setdata(signurlVal, signurlKey)
if (signheaderVal) chavy.setdata(signheaderVal, signheaderKey)
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()

View File

@ -1,75 +0,0 @@
const cookieName = '芒果TV'
const signurlKey = 'chavy_signurl_mgtv'
const signheaderKey = 'chavy_signheader_mgtv'
const chavy = init()
const signurlVal = chavy.getdata(signurlKey)
const signheaderVal = chavy.getdata(signheaderKey)
sign()
function sign() {
const url = {url: signurlVal, headers: JSON.parse(signheaderVal)}
url.body = '{}'
chavy.post(url, (error, response, data) => {
chavy.log(`${cookieName}, data: ${data}`)
const title = `${cookieName}`
let subTitle = ''
let detail = ''
const result = JSON.parse(data.match(/\(([^\)]*)\)/)[1])
if (result.code == 200) {
subTitle = `签到结果: 成功`
detail = `共签: ${result.data.curDay}天, 连签: ${result.data.curDayTotal}天, 积分: ${result.data.balance} +${result.data.credits}`
} else if (result.code == 1002) {
subTitle = `签到结果: 成功 (重复签到)`
} else {
subTitle = `签到结果: 失败`
detail = `编码: ${result.code}, 说明: ${result.msg}`
}
chavy.msg(title, 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.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}
}

View File

@ -1,91 +0,0 @@
# 猫咪音乐网
> 代码已同时兼容 Surge & QuanX, 使用同一份签到脚本即可
## 配置 (Surge)
```properties
[MITM]
www.maomicd.com
[Script]
http-request https:\/\/www.maomicd.com\/plugin.php\?id=k_misign:sign&operation=qiandao script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/maomicd/maomicd.cookie.js
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/maomicd/maomicd.js
```
## 配置 (QuanX)
```properties
[MITM]
www.maomicd.com
[rewrite_local]
https:\/\/www.maomicd.com\/plugin.php\?id=k_misign:sign&operation=qiandao url script-request-header maomicd.cookie.js
[task_local]
1 0 * * * maomicd.js
```
## 说明
1. 先把`www.maomicd.com`加到`[MITM]`
2. 再配置重写规则:
- Surge: 把两条远程脚本放到`[Script]`
- QuanX: 把`maomicd.cookie.js`和`maomicd.js`传到`On My iPhone - Quantumult X - Scripts` (传到 iCloud 相同目录也可, 注意要打开 quanx 的 iCloud 开关)
3. 打开 网站 `https://www.maomicd.com` 然后手动签到 1 次, 系统提示: `获取Cookie: 成功`
4. 最后就可以把获取 Cookie 的脚本注释掉了
5. 运行一次脚本, 如果提示重复签到, 那就算成功了!
> 第 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)

View File

@ -1,58 +0,0 @@
const cookieName = '猫咪音乐网'
const signurlKey = 'chavy_signurl_maomicd'
const signheaderKey = 'chavy_signheader_maomicd'
const chavy = init()
if ($request && $request.method != 'OPTIONS') {
const signurlVal = $request.url
const signheaderVal = JSON.stringify($request.headers)
if (signurlVal) chavy.setdata(signurlVal, signurlKey)
if (signheaderVal) chavy.setdata(signheaderVal, signheaderKey)
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()

View File

@ -1,72 +0,0 @@
const cookieName = '猫咪音乐网'
const signurlKey = 'chavy_signurl_maomicd'
const signheaderKey = 'chavy_signheader_maomicd'
const chavy = init()
const signurlVal = chavy.getdata(signurlKey)
const signheaderVal = chavy.getdata(signheaderKey)
sign()
function sign() {
const url = {url: signurlVal, headers: JSON.parse(signheaderVal)}
chavy.get(url, (error, response, data) => {
chavy.log(`${cookieName}, data: ${data}`)
let subTitle = ``
let detail = ``
let result = data.match(/<root>(<!\[CDATA\[(.*?)\]\]>)<\/root>/)
if (result) {
result = result[2]
if (result == '') subTitle = `签到结果: 成功`
else if (result.indexOf('今日已签') >= 0) subTitle = `签到结果: 成功 (重复签到)`
else (subTitle = `签到结果: 未知`), (detail = `说明: ${result}`)
} else {
subTitle = `签到结果: 失败`
}
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.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}
}

View File

@ -1,91 +0,0 @@
# 叮咚买菜
> 代码已同时兼容 Surge & QuanX, 使用同一份签到脚本即可
## 配置 (Surge)
```properties
[MITM]
maicai.api.ddxq.mobi
[Script]
http-request ^https:\/\/maicai.api.ddxq.mobi\/point\/home script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/mcdd/mcdd.cookie.js
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/mcdd/mcdd.js
```
## 配置 (QuanX)
```properties
[MITM]
maicai.api.ddxq.mobi
[rewrite_local]
^https:\/\/maicai.api.ddxq.mobi\/point\/home url script-request-header mcdd.cookie.js
[task_local]
1 0 * * * mcdd.js
```
## 说明
1. 先把`maicai.api.ddxq.mobi`加到`[MITM]`
2. 再配置重写规则:
- Surge: 把两条远程脚本放到`[Script]`
- QuanX: 把`mcdd.cookie.js`和`mcdd.js`传到`On My iPhone - Quantumult X - Scripts` (传到 iCloud 相同目录也可, 注意要打开 quanx 的 iCloud 开关)
3. 打开 APP, 访问下`我的`>`积分`
4. 系统提示: `获取Cookie: 成功` (如果不提示获取成功, 尝试杀进程再进个人中心)
5. 最后就可以把第 1 条脚本注释掉了
> 第 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)

View File

@ -1,70 +0,0 @@
const chavy = init()
const cookieName = '叮咚买菜'
const KEY_homeurl = 'chavy_home_url_mcdd'
const KEY_homeheader = 'chavy_home_header_mcdd'
if ($request && $request.method != 'OPTIONS') {
try {
chavy.log(`🔔 ${cookieName} 开始获取: Cookies`)
const VAL_homeurl = $request.url
const VAL_homeheader = JSON.stringify($request.headers)
if (VAL_homeurl) {
chavy.setdata(VAL_homeurl, KEY_homeurl)
chavy.log(`${cookieName} VAL_homeurl: ${VAL_homeurl}`)
}
if (VAL_homeheader) {
chavy.setdata(VAL_homeheader, KEY_homeheader)
chavy.log(`${cookieName} VAL_homeheader: ${VAL_homeheader}`)
}
chavy.msg(cookieName, `获取Cookie: 成功`, ``)
} catch (e) {
chavy.msg(cookieName, `获取Cookie: 失败`, e)
chavy.log(`${cookieName} 获取Cookie: 失败: ${e}`)
}
}
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()

View File

@ -1,233 +0,0 @@
const chavy = init()
const cookieName = '叮咚买菜'
const KEY_homeurl = 'chavy_home_url_mcdd'
const KEY_homeheader = 'chavy_home_header_mcdd'
const signinfo = {}
let VAL_homeurl = chavy.getdata(KEY_homeurl)
let VAL_homeheader = chavy.getdata(KEY_homeheader)
;(exec = async () => {
chavy.log(`🔔 ${cookieName} 开始签到`)
await signapp()
await getlottery()
if (signinfo.draw_num > 0) for (let i = 0; i < signinfo.draw_num; i++) await lotteryapp(i)
await browseapp()
await getinfo()
showmsg()
chavy.done()
})().catch((e) => chavy.log(`${cookieName} 签到失败: ${e}`), chavy.done())
function getinfo() {
return new Promise((resolve, reject) => {
const url = {url: VAL_homeurl, headers: JSON.parse(VAL_homeheader)}
chavy.get(url, (error, response, data) => {
try {
signinfo.info = JSON.parse(data)
if (typeof signinfo.is_today_sign === 'undefined') signinfo.is_today_sign = signinfo.info.data.user_sign.is_today_sign
resolve()
} catch (e) {
chavy.msg(cookieName, `获取信息: 失败`, `说明: ${e}`)
chavy.log(`${cookieName} getinfo - 获取信息失败: ${e}`)
chavy.log(`${cookieName} getinfo - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
function signapp() {
return new Promise((resolve, reject) => {
const url = {url: `https://ddxq.mobi/api/v2/user/signin/`, headers: JSON.parse(VAL_homeheader)}
url.headers['Accept'] = '*/*'
url.headers['Origin'] = 'https://activity.m.ddxq.mobi'
url.headers['Accept-Encoding'] = 'gzip, deflate, br'
url.headers['Content-Type'] = 'application/x-www-form-urlencoded'
url.headers['Host'] = 'ddxq.mobi'
url.headers['Connection'] = 'keep-alive'
url.headers['Referer'] = 'https://activity.m.ddxq.mobi/'
url.headers['Content-Length'] = '129'
url.headers['Accept-Language'] = 'zh-cn'
url.body = VAL_homeurl.split('?')[1]
chavy.post(url, (error, response, data) => {
try {
signinfo.signapp = JSON.parse(data)
resolve()
} catch (e) {
chavy.msg(cookieName, `签到结果: 失败`, `说明: ${e}`)
chavy.log(`${cookieName} signapp - 签到失败: ${e}`)
chavy.log(`${cookieName} signapp - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
function getlottery() {
return new Promise((resolve, reject) => {
const getlotteryurl = `https://maicai.api.ddxq.mobi/lottery/index?${VAL_homeurl.split('?')[1]}&event_id=5dbacee44df3e3ed628ce721`
const url = {url: getlotteryurl, headers: JSON.parse(VAL_homeheader)}
url.headers['Origin'] = 'https://activity.m.ddxq.mobi'
url.headers['Connection'] = 'keep-alive'
url.headers['Accept'] = '*/*'
url.headers['Referer'] = 'https://activity.m.ddxq.mobi/'
url.headers['Host'] = 'maicai.api.ddxq.mobi'
url.headers['Accept-Encoding'] = 'gzip, deflate, br'
url.headers['Accept-Language'] = 'zh-cn'
chavy.get(url, (error, response, data) => {
try {
signinfo.lotteryinfo = JSON.parse(data)
if (typeof signinfo.draw_num === 'undefined') signinfo.draw_num = signinfo.lotteryinfo.data.draw_num
resolve()
} catch (e) {
chavy.msg(cookieName, `获取抽奖: 失败`, `说明: ${e}`)
chavy.log(`${cookieName} getlottery - 获取抽奖失败: ${e}`)
chavy.log(`${cookieName} getlottery - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
function lotteryapp(cnt) {
return new Promise((resolve, reject) => {
setTimeout(() => {
const lotteryappurl = `https://maicai.api.ddxq.mobi/lottery/draw?${VAL_homeurl.split('?')[1]}&event_id=5dbacee44df3e3ed628ce721`
const url = {url: lotteryappurl, headers: JSON.parse(VAL_homeheader)}
url.headers['Origin'] = 'https://activity.m.ddxq.mobi'
url.headers['Connection'] = 'keep-alive'
url.headers['Accept'] = '*/*'
url.headers['Referer'] = 'https://activity.m.ddxq.mobi/'
url.headers['Host'] = 'maicai.api.ddxq.mobi'
url.headers['Accept-Encoding'] = 'gzip, deflate, br'
url.headers['Accept-Language'] = 'zh-cn'
chavy.get(url, (error, response, data) => {
try {
if (!signinfo.lottery) signinfo.lottery = []
signinfo.lottery.push(JSON.parse(data))
resolve()
} catch (e) {
chavy.msg(cookieName, `获取抽奖: 失败`, `说明: ${e}`)
chavy.log(`${cookieName} lotteryapp - 获取抽奖失败: ${e}`)
chavy.log(`${cookieName} lotteryapp - response: ${JSON.stringify(response)}`)
resolve()
}
})
}, cnt * 5000)
})
}
function browseapp() {
return new Promise((resolve, reject) => {
const browseappurl = `https://maicai.api.ddxq.mobi/point/completeTask`
const url = {url: browseappurl, headers: JSON.parse(VAL_homeheader)}
url.body = `${VAL_homeurl.split('?')[1]}&station_id=5500fe01916edfe0738b4e43&task_type=21`
url.headers['Accept'] = '*/*'
url.headers['Origin'] = 'https://maicai.m.ddxq.mobi'
url.headers['Accept-Encoding'] = 'gzip, deflate, br'
url.headers['Content-Type'] = 'application/x-www-form-urlencoded'
url.headers['Host'] = 'maicai.api.ddxq.mobi'
url.headers['Connection'] = 'keep-alive'
url.headers['User-Agent'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 xzone/9.7.5 station_id/5500fe01916edfe0738b4e43'
url.headers['Referer'] = 'https://maicai.m.ddxq.mobi/?v=1.30.0'
url.headers['Content-Length'] = '152'
url.headers['Accept-Language'] = 'zh-cn'
chavy.post(url, (error, response, data) => {
try {
signinfo.browseapp = JSON.parse(data)
resolve()
} catch (e) {
chavy.msg(cookieName, `浏览商品: 失败`, `说明: ${e}`)
chavy.log(`${cookieName} browseapp - 浏览商品失败: ${e}`)
chavy.log(`${cookieName} browseapp - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
function showmsg() {
let subTitle, detail
if (signinfo.signapp.code == 0) {
if (signinfo.is_today_sign === false) subTitle = '签到: 成功'
else subTitle = '签到: 重复'
detail = `积分: ${signinfo.info.data.point_num} (+${signinfo.signapp.data.point}), 价值: ${signinfo.info.data.point_money}`
} else {
subTitle = '签到: 失败'
detail = `编码: ${signinfo.signapp.code}, 说明: ${signinfo.signapp.message}`
chavy.log(`${cookieName} showmsg - 签到失败: ${JSON.stringify(signinfo.signapp)}`)
}
if (signinfo.lotteryinfo.code == 0) {
if (signinfo.draw_num == 0) subTitle += '; 抽奖: 已转'
else subTitle += `; 抽奖: ${signinfo.draw_num}`
} else {
subTitle = '抽奖: 失败'
detail = `编码: ${signinfo.lotteryinfo.code}, 说明: ${signinfo.lotteryinfo.message}`
chavy.log(`${cookieName} showmsg - 抽奖失败: ${JSON.stringify(signinfo.lotteryinfo)}`)
}
if (signinfo.browseapp.code == 0) {
subTitle += '; 浏览任务: 成功'
} else if (signinfo.browseapp.code == -1) {
subTitle += '; 浏览任务: 重复'
} else {
subTitle = '浏览任务: 失败'
detail = `编码: ${signinfo.browseapp.code}, 说明: ${signinfo.browseapp.msg}`
chavy.log(`${cookieName} showmsg - 浏览任务失败: ${JSON.stringify(signinfo.browseapp)}`)
}
if (signinfo.lottery) {
detail += '\n查看抽奖详情\n'
for (let i = 0; i < signinfo.lottery.length; i++) {
if (signinfo.lottery[i].code == 0) detail += `\n抽奖 (${i + 1}): ${signinfo.lottery[i].data.prize.title}`
else detail += `\n抽奖 (${i + 1}): ${signinfo.lottery[i].msg}`
}
}
chavy.msg(cookieName, subTitle, detail)
}
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}
}

View File

@ -1,98 +0,0 @@
# 美团
> 代码已同时兼容 Surge & QuanX, 使用同一份签到脚本即可
> QuanX 需要: v1.0.6-build195 及以后版本 (TestFlight)
## 配置 (Surge)
```properties
[MITM]
hostname = i.meituan.com
[Script]
http-request ^https:\/\/i.meituan.com\/evolve\/signin\/signpost\/ script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/meituan/meituan.cookie.js, requires-body=true
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/meituan/meituan.js
```
## 配置 (QuanX)
```properties
[MITM]
i.meituan.com
[rewrite_local]
# [商店版] QuanX v1.0.6-build194 及更早版本
# 不支持
# [TestFlight] QuanX v1.0.6-build195 及以后版本
^https:\/\/i.meituan.com\/evolve\/signin\/signpost\/ url script-request-body meituan.cookie.js
[task_local]
1 0 * * * meituan.js
```
## 说明
1. 先把`i.meituan.com`加到`[MITM]`
2. 再配置重写规则:
- Surge: 把两条远程脚本放到`[Script]`
- QuanX: 把`meituan.cookie.js`和`meituan.js`传到`On My iPhone - Quantumult X - Scripts` (传到 iCloud 相同目录也可, 注意要打开 quanx 的 iCloud 开关)
3. 打开 APP , 然后手动签到 1 次, 系统提示: `获取Cookie: 成功` (`首页` > `红包签到`)
4. 把获取 Cookie 的脚本注释掉
5. 运行一次脚本, 如果提示重复签到, 那就算成功了!
> 第 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)

View File

@ -1,64 +0,0 @@
const cookieName = '美团'
const tokenurlKey = 'chavy_tokenurl_meituan'
const tokenheaderKey = 'chavy_tokenheader_meituan'
const signurlKey = 'chavy_signurl_meituan'
const signheaderKey = 'chavy_signheader_meituan'
const signbodyKey = 'chavy_signbody_meituan'
const chavy = init()
const requrl = $request.url
if ($request && $request.method != 'OPTIONS' && requrl.match(/\/evolve\/signin\/signpost\//)) {
const signurlVal = requrl
const signheaderVal = JSON.stringify($request.headers)
const signbodyVal = $request.body
if (signurlVal) chavy.setdata(signurlVal, signurlKey)
if (signheaderVal) chavy.setdata(signheaderVal, signheaderKey)
if (signbodyVal) chavy.setdata(signbodyVal, signbodyKey)
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()

View File

@ -1,86 +0,0 @@
const cookieName = '美团'
const tokenurlKey = 'chavy_tokenurl_meituan'
const tokenheaderKey = 'chavy_tokenheader_meituan'
const signurlKey = 'chavy_signurl_meituan'
const signheaderKey = 'chavy_signheader_meituan'
const signbodyKey = 'chavy_signbody_meituan'
const chavy = init()
const tokenurlVal = chavy.getdata(tokenurlKey)
const tokenheaderVal = chavy.getdata(tokenheaderKey)
const signurlVal = chavy.getdata(signurlKey)
const signheaderVal = chavy.getdata(signheaderKey)
const signBodyVal = chavy.getdata(signbodyKey)
sign()
function sign() {
const url = {url: signurlVal, headers: JSON.parse(signheaderVal), body: signBodyVal}
chavy.post(url, (error, response, data) => {
chavy.log(`${cookieName}, data: ${data}`)
const result = JSON.parse(data)
let subTitle = ``
let detail = ``
if (result.code == 0) {
subTitle = `签到结果: 成功`
detail = `本周连签: ${result.data[0].circleSignTimes}`
for (r of result.data[0].signInAwardRecords) {
const rinfo = JSON.parse(r.info)
if (rinfo.type == `cash`) detail += `, 奖励金: ${rinfo.amount / 100}`
else if (rinfo.type == `coupon`) detail += `\n优惠券: ${rinfo.name}: ${rinfo.amount}元 (${rinfo.condition})`
else detail += `\n未知奖励!`
}
} else if (result.code == 2002) {
subTitle = `签到结果: 成功 (重复签到)`
detail = `说明: ${result.msg}`
} else {
subTitle = `签到结果: 失败`
detail = `编码: ${result.code}, 说明: ${result.msg}`
}
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}
}

View File

@ -1,117 +0,0 @@
# 米读
> 代码已同时兼容 Surge & QuanX, 使用同一份签到脚本即可
> QuanX 需要: v1.0.6-build195 及以后版本 (TestFlight)
> 感谢 [@GideonSenku](https://github.com/GideonSenku) Commit
> 2020.04.29 添加阅读时长
> 2020.04.30 添加签到、掷骰子
> 2002.05.01 添加阅读双签
> 2002.05.01 添加签到双签
> 2020.05.04 使用python生成无限账户签到和阅读JavaScript脚本
## 配置 (Surge)
```properties
[MITM]
apiwz.midukanshu.com
[Script]
http-request ^https:\/\/apiwz\.midukanshu\.com script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/midu/midu.cookie.js, requires-body=true
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/midu/miduSign.js
cron "*/1 * * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/midu/miduRead.js
```
## 配置 (QuanX)
```properties
[MITM]
apiwz.midukanshu.com
[rewrite_local]
# [商店版] QuanX v1.0.6-build194 及更早版本
^https:\/\/apiwz\.midukanshu\.com url script-request-body midu.cookie.js
# [TestFlight] QuanX v1.0.6-build195 及以后版本
^https:\/\/apiwz\.midukanshu\.com url script-request-body https://raw.githubusercontent.com/chavyleung/scripts/master/midu/midu.cookie.js
[task_local]
*/1 * * * * miduRead.js
0 1 * * * miduSign.js
```
## 说明
0. 越狱用户请关闭越狱状态,否则会视为作弊用户!!!
1. 先把`apiwz.midukanshu.com`加到`[MITM]`
2. 再配置重写规则:
- Surge: 把两条远程脚本放到`[Script]`
- QuanX: 把`midu.cookie.js`和`miduRead.js`&`miduSign.js`传到`On My iPhone - Quantumult X - Scripts` (传到 iCloud 相同目录也可, 注意要打开 quanx 的 iCloud 开关)
3. 打开 APP 进入`我的` -> `疯狂摇摇乐`,系统提示: `签到:获取Cookie: 成功`
4. 阅读时长获取Cookie:打开 APP 选取文章阅读, `书城` > `任意文章阅读` 等到提示获取Cookie成功即可
5. 把获取 Cookie 的脚本注释掉
6. 建议将`miduRead.js`脚本`task`执行次数改成每分钟执行以达到阅读时长
7. 若要双签到,切换账号获取账户二的Cookie即可
8. 赞赏:邀请码`A1040276307`,[直达链接](http://html34.qukantoutiao.net/qpr2/bBmQ.html?pid=5eb14518)
9. 无限账户签到请移步:[GideonSenku](https://github.com/GideonSenku/scripts/tree/master/midu),目前支持仅制支持Surge
> 第 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)
[@GideonSenku](https://github.com/GideonSenku)

View File

@ -1,172 +0,0 @@
// 账号一
const readTimeheaderKey = 'senku_readTimeheader_midu'
const signbodyKey = 'senku_signbody_midu'
// 账号二
const readTimeheaderKey2 = 'senku_readTimeheader_midu2'
const signbodyKey2 = 'senku_signbody_midu2'
const senku = init()
const requrl = $request.url
if ($request && $request.method != 'OPTIONS' && requrl.match(/\/user\/readTimeBase\/readTime/)) {
try {
const readTimebodyVal = $request.body
const CookieValue = $request.headers
senku.log(`🍎${readTimebodyVal}`)
senku.log(`🍎${senku.getdata(readTimebodyKey)}`)
var account = senku.getdata('tokenMidu_read') ? senku.getdata('tokenMidu_read') : null
var account2 = senku.getdata('tokenMidu_read2') ? senku.getdata('tokenMidu_read2') : null
var tokenVal = CookieValue['token']
if (!account || tokenVal == account) {
var CookieName = '【账号一】'
var CookieKey = 'senku_readTimeheader_midu'
var tokenKey = 'tokenMidu_read'
var readTimebodyKey = 'senku_readTimebody_midu'
} else if (!account2 || tokenVal == account2) {
var CookieName = '【账号二】'
var CookieKey = 'senku_readTimeheader_midu2'
var tokenKey = 'tokenMidu_read2'
var readTimebodyKey = 'senku_readTimebody_midu2'
}
senku.log(`🍎${CookieName}`)
if (CookieName && senku.getdata(tokenKey)) {
if (senku.getdata(tokenKey) != tokenVal) {
var token = senku.setdata(tokenVal, tokenKey)
var header = senku.setdata(JSON.stringify(CookieValue), CookieKey)
var body = senku.setdata(readTimebodyVal, readTimebodyKey)
senku.setdata(readTimebodyVal, readTimebodyKey)
senku.log(`🔔${readTimebodyVal}`)
senku.log(`🔔${JSON.stringify(CookieValue)}`)
if (!token && !header && !body) {
senku.msg("米读", "阅读文章数据", "获取Cookie失败 ‼️")
senku.msg("米读", "阅读", "更新" + CookieName + "Cookie失败 ‼️")
} else {
senku.msg("米读", "阅读文章数据", "获取Cookie成功 🎉")
senku.msg("米读", "阅读", "更新" + CookieName + "Cookie成功 🎉")
}
}
} else if (CookieName) {
var token = senku.setdata(tokenVal, tokenKey)
var header = senku.setdata(CookieValue['tk'], CookieKey)
var body = senku.setdata(readTimebodyVal, readTimebodyKey)
senku.log(`🍎${tokenVal}`)
senku.log(`🔔${readTimebodyVal}`)
if (!header && !token && !body) {
senku.msg("米读", "阅读文章数据", "获取Cookie失败 ‼️")
senku.msg("米读", "阅读", "首次写入" + CookieName + "Cookie失败 ‼️")
} else {
senku.setdata('no', 'bind')
senku.msg("米读", "阅读文章数据", "获取Cookie成功 🎉")
senku.msg("米读", "阅读", "首次写入" + CookieName + "Cookie成功 🎉")
}
} else {
senku.msg("米读", "更新米读->阅读Cookie失败", '非历史写入账号 ‼️')
}
} catch (error) {
senku.log(`❌error:${error}`)
}
}
if ($request && $request.method != 'OPTIONS' && requrl.match(/\/wz\/dice\/index/)) {
try {
var CookieValue = $request.body
var account = senku.getdata('tokenMidu_sign') ? senku.getdata('tokenMidu_sign') : null
var account2 = senku.getdata('tokenMidu_sign2') ? senku.getdata('tokenMidu_sign2') : null
var tkVal = CookieValue.match(/token=[a-zA-Z0-9._-]+/)[0]
var tokenVal = tkVal.substring(6, tkVal.length)
if (!account || tokenVal == account) {
var CookieName = '【账号一】'
var CookieKey = 'senku_signbody_midu'
var tokenKey = 'tokenMidu_sign'
} else if (!account2 || tokenVal == account2) {
var CookieName = '【账号二】'
var CookieKey = 'senku_signbody_midu2'
var tokenKey = 'tokenMidu_sign2'
} else {
senku.msg("米读", "更新米读->签到Cookie失败", '非历史写入账号 ‼️')
}
senku.log(`🍎${senku.getdata(tokenKey)}`)
senku.log(`🍎${tokenVal}`)
if (senku.getdata(tokenKey)) {
if (senku.getdata(tokenKey) != tokenVal) {
var token = senku.setdata(tokenVal, tokenKey)
var body = senku.setdata(CookieValue, CookieKey)
if (!body && !token) {
senku.msg("米读", "签到", "更新" + CookieName + "Cookie失败 ‼️")
} else {
senku.msg("米读", "签到", "更新" + CookieName + "Cookie成功 🎉")
}
}
} else {
var token = senku.setdata(tokenVal, tokenKey)
var body = senku.setdata(CookieValue, CookieKey)
senku.log(`🍎${tokenVal}`)
if (!body && !token) {
senku.msg("米读", "签到", "首次写入" + CookieName + "Cookie失败 ‼️")
} else {
senku.setdata('no', 'bind')
senku.msg("米读", "签到", "首次写入" + CookieName + "Cookie成功 🎉")
}
}
} catch (error) {
senku.log(`❌error:${error}`)
}
}
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
}
}
senku.done()

View File

@ -1,374 +0,0 @@
// 赞赏:邀请码`A1040276307`
// 链接`http://html34.qukantoutiao.net/qpr2/bBmQ.html?pid=5eb14518`
// 农妇山泉 -> 有点咸
/********************
* 1 为了方便任意脚本可以清除Cookie, 任意一个脚本将DeleteCookie = true且选择要清除的账号都可以生效
* 2 debug模式可以在Surge&&Qx中开启,方便你判定多用户及脚本运行情况
* 3 Qx==>dubug:miduRede构造请求
* 4 Surge==>debug:load脚本->evalaute
* 5脚本默认每半小时通知一次,建议自己先debug看看是否成功
*********************/
// 是否开启清除Cookie
const DeleteCookie = false // 清除所有Cookie,将下方改为true,默认false
// 选取清除操作
const DeleteCookieAll = false // 清除所有
const DeleteCookieOne = false // 清除账户一
const DeleteCookieTwo = false // 清除账户二
const debug = false // 开启debug模式,每次脚本执行会显示通知,默认false
const bind = true // 绑定作者邀请码,默认true,可更改为false
const cookieName = '米读阅读时长'
const senku = init()
debug ? senku.setdata('true', 'debug') : senku.setdata('false', 'debug')
bind ? '' : senku.setdata('', 'bind');
if (DeleteCookie) {
const one = senku.getdata('tokenMidu_read')
const two = senku.getdata('tokenMidu_sign')
const three = senku.getdata('tokenMidu_read2')
const four = senku.getdata('tokenMidu_sign2')
if (DeleteCookieAll) {
if (one || two || three || four) {
senku.setdata("", 'senku_signbody_midu')
senku.setdata("", 'senku_signbody_midu2')
senku.setdata("", 'senku_readTimebody_midu')
senku.setdata("", 'senku_readTimebody_midu2')
senku.setdata("", 'senku_readTimeheader_midu')
senku.setdata("", 'senku_readTimeheader_midu2')
senku.setdata("", "tokenMidu_read")
senku.setdata("", "tokenMidu_read2")
senku.setdata("", "tokenMidu_sign")
senku.setdata("", "tokenMidu_sign2")
senku.msg("米读 Cookie清除成功 !", "", '请手动关闭脚本内"DeleteCookie"选项')
} else {
senku.msg("米读 无可清除的Cookie !", "", '请手动关闭脚本内"DeleteCookie"选项')
}
} else if (DeleteCookieOne) {
if (one || two) {
senku.setdata("", 'senku_signbody_midu')
senku.setdata("", 'senku_readTimebody_midu')
senku.setdata("", 'senku_readTimeheader_midu')
senku.setdata("", "tokenMidu_read")
senku.setdata("", "tokenMidu_sign")
senku.msg("米读 Cookie清除成功 !", "清除账户一选项", '请手动关闭脚本内"DeleteCookie"选项')
} else {
senku.msg("米读 无可清除的Cookie !", "清除账户一选项", '请手动关闭脚本内"DeleteCookie"选项')
}
} else if (DeleteCookieTwo) {
if (three || four) {
senku.setdata("", 'senku_signbody_midu2')
senku.setdata("", 'senku_readTimebody_midu2')
senku.setdata("", 'senku_readTimeheader_midu2')
senku.setdata("", "tokenMidu_read2")
senku.setdata("", "tokenMidu_sign2")
senku.msg("米读 Cookie清除成功 !", "清除账户二选项", '请手动关闭脚本内"DeleteCookie"选项')
} else {
senku.msg("米读 无可清除的Cookie !", "清除账户二选项", '请手动关闭脚本内"DeleteCookie"选项')
}
} else {
senku.msg("米读 清除Cookie !", "未选取任何选项", '请手动关闭脚本内"DeleteCookie"选项')
}
}
function initial() {
signinfo = {
addnumList: [],
rollList: [],
doubleList: []
}
}
;
(sign = () => {
senku.log(`🔔 ${cookieName}`)
senku.getdata('tokenMidu_read') ? '' : senku.msg('米读阅读', '', '不存在Cookie')
DualAccount = true
if (senku.getdata('tokenMidu_read')) {
tokenVal = senku.getdata('tokenMidu_read')
readTimeheaderVal = senku.getdata('senku_readTimeheader_midu')
readTimebodyVal = senku.getdata('senku_readTimebody_midu')
signbodyVal = senku.getdata('senku_signbody_midu')
all()
}
senku.done()
})()
async function all() {
try {
senku.log(`🍎${readTimeheaderVal}`)
const headerVal = readTimeheaderVal
const urlVal = readTimebodyVal
const key = signbodyVal
const token = tokenVal
initial()
await readTime(headerVal, token, urlVal)
await userInfo(key)
await prizeInfo(key)
if (signinfo.prizeInfo && signinfo.prizeInfo.data && signinfo.prizeInfo.data.total_num) {
await prizeTask(key)
await drawPrize(key)
}
await showmsg()
senku.done()
} catch (e) {
senku.msg(cookieName, `失败`, `说明: ${e}`)
senku.log(`${cookieName} - 失败: ${e}`)
senku.done()
}
}
function double() {
initial()
DualAccount = false
if (senku.getdata('tokenMidu_read2')) {
tokenVal = senku.getdata('tokenMidu_read2')
readTimeheaderVal = senku.getdata('senku_readTimeheader_midu2')
readTimebodyVal = senku.getdata('senku_readTimebody_midu2')
signbodyVal = senku.getdata('senku_signbody_midu2')
all()
}
}
// 抽奖
function drawPrize(bodyVal) {
return new Promise((resolve, reject) => {
const drawPrizeurlVal = 'https://apiwz.midukanshu.com/wz/task/drawPrize?' + bodyVal
const url = {
url: drawPrizeurlVal,
headers: {}
}
url.headers['Host'] = 'apiwz.midukanshu.com'
url.headers['Content-Type'] = 'application/x-www-form-urlencoded'
url.headers['User-Agent'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148'
senku.post(url, (error, response, data) => {
try {
senku.log(`🐍🐢 ${cookieName} drawPrize - response: ${JSON.stringify(response)}`)
if (data) {
signinfo.drawPrize = JSON.parse(data)
}
resolve()
} catch (e) {
// senku.msg(cookieName, `抽奖: 失败`, `说明: ${e}`)
senku.log(`${cookieName} drawPrize - 抽奖失败: ${e}`)
senku.log(`${cookieName} drawPrize - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
// 观看视频获取抽奖机会
function prizeTask(bodyVal) {
return new Promise((resolve, reject) => {
const prizeTaskurlVal = 'https://apiwz.midukanshu.com/wz/task/prizeTask?' + bodyVal
const url = {
url: prizeTaskurlVal,
headers: {}
}
url.headers['Host'] = 'apiwz.midukanshu.com'
url.headers['Content-Type'] = 'application/x-www-form-urlencoded'
url.headers['User-Agent'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148'
senku.post(url, (error, response, data) => {
try {
senku.log(`🐍🐢 ${cookieName} prizeTask - response: ${JSON.stringify(response)}`)
if (data) {
signinfo.prizeTask = JSON.parse(data)
}
resolve()
} catch (e) {
// senku.msg(cookieName, `观看视频抽奖: 失败`, `说明: ${e}`)
senku.log(`${cookieName} prizeTask - 观看视频抽奖失败: ${e}`)
senku.log(`${cookieName} prizeTask - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
// 抽奖信息
function prizeInfo(bodyVal) {
return new Promise((resolve, reject) => {
const prizeInfourlVal = 'https://apiwz.midukanshu.com/wz/task/prizeList?' + bodyVal
const url = {
url: prizeInfourlVal,
headers: {}
}
url.headers['Host'] = 'apiwz.midukanshu.com'
url.headers['Content-Type'] = 'application/x-www-form-urlencoded'
url.headers['User-Agent'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148'
senku.post(url, (error, response, data) => {
try {
senku.log(`🐍🐢 ${cookieName} prizeInfo - response: ${JSON.stringify(response)}`)
if (data) {
signinfo.prizeInfo = JSON.parse(data)
}
resolve()
} catch (e) {
// senku.msg(cookieName, `抽奖信息: 失败`, `说明: ${e}`)
senku.log(`${cookieName} prizeInfo - 抽奖信息失败: ${e}`)
senku.log(`${cookieName} prizeInfo - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
// 阅读时长
function readTime(header, token, urlVal) {
return new Promise((resolve, reject) => {
const url = {
url: 'https://apiwz.midukanshu.com/user/readTimeBase/readTime?' + urlVal,
headers: {
'host': 'apiwz.midukanshu.com',
'versionName': '1.7.2.0501.1930',
"User-Agent": "MRSpeedNovel/0430.1512 CFNetwork/1125.2 Darwin/19.5.0",
"Content-Type": "application/x-www-form-urlencoded; charset=utf-8",
'token': token,
'tk': header
}
}
senku.post(url, (error, response, data) => {
try {
senku.log(`🐍🐢 ${cookieName} readTime - response: ${JSON.stringify(response)}`)
if (data) {
signinfo.readTime = JSON.parse(data)
}
resolve()
} catch (e) {
// senku.msg(cookieName, `阅读时长: 失败`, `说明: ${e}`)
senku.log(`${cookieName} readTime - 阅读时长失败: ${e}`)
senku.log(`${cookieName} readTime - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
// 用户信息
function userInfo(bodyVal) {
return new Promise((resolve, reject) => {
const userInfourlVal = 'https://apiwz.midukanshu.com/wz/user/getInfo?' + bodyVal
const url = {
url: userInfourlVal,
headers: {}
}
url.headers['Host'] = 'apiwz.midukanshu.com'
url.headers['Content-Type'] = 'application/x-www-form-urlencoded'
url.headers['User-Agent'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148'
senku.post(url, (error, response, data) => {
try {
senku.log(`🐍🐢 ${cookieName} userInfo - response: ${JSON.stringify(response)}`)
if (data) {
signinfo.userInfo = JSON.parse(data)
}
resolve()
} catch (e) {
// senku.msg(cookieName, `用户信息: 失败`, `说明: ${e}`)
senku.log(`${cookieName} userInfo - 用户信息失败: ${e}`)
senku.log(`${cookieName} userInfo - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
function showmsg() {
return new Promise((resolve, reject) => {
let subTitle = ''
let detail = ''
const name = signinfo.userInfo && signinfo.userInfo.data && signinfo.userInfo.data.nickname ? signinfo.userInfo.data.nickname : `账户已退出`
if (signinfo.readTime && signinfo.readTime.code == 0) {
const coin = signinfo.readTime.data.coin
const readTotalMinute = signinfo.readTime.data.readTotalMinute
const total_coin = signinfo.readTime.data.total_coin
coin == 0 ? detail += `` : detail += `【阅读时长】获得${coin}💰`
readTotalMinute ? detail += ` 阅读时长${readTotalMinute / 2}分钟,该账户:${total_coin}💰` : detail += `该账户:${total_coin}💰`
} else if (signinfo.readTime && signinfo.readTime.code != 0) {
detail += `【阅读时长】错误代码${signinfo.readTime.code},错误信息${signinfo.readTime.message}`
senku.msg(cookieName + ` 用户:${name}`, subTitle, detail)
}
if (senku.getdata('debug') == 'true' || detail && signinfo.readTime && signinfo.readTime.data && signinfo.readTime.data.readTotalMinute % 60 == 0) {
senku.msg(cookieName + ` 用户:${name}`, subTitle, detail)
} else if (senku.getdata('debug') == 'true' || signinfo.readTime && signinfo.readTime.data && signinfo.readTime.data.readTotalMinute % 60 == 0) {
senku.msg(cookieName + ` 用户:${name}`, '阅读结果', '时间未到')
}
// 大转盘抽手机
// if (signinfo.drawPrize) {
// if (signinfo.drawPrize.code == 0) {
// detail += `【转盘奖励】本次${drawPrize.data.title}\n`
// } else {
// detail += `【转盘奖励】无次数抽奖`
// }
// senku.msg(cookieName + ` 用户:${name}`, subTitle, detail)
// }
if (DualAccount) double()
resolve()
})
}
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
}
}

View File

@ -1,174 +0,0 @@
"""
@author: GideonSenku, modified by pysta
@file: SurgeToJs.py
@createTime: 2020-05-01
本脚本用作曲线双阅读,结合APP:py3使用
1登陆要阅读的账号一.....,理论无限
2Surge抓包记录找到https://apiwz.midukanshu.com/user/readTimeBase/readTime选择该记录导出,使用pythonista3运行miduRead.py
3在Surge->脚本->新增, 脚本名:自定义不要重复就好, 脚本类型选择Cron, cron表达式: */1 * * * * 脚本位置->本地
4编辑脚本:贴贴py3的结果
"""
import zipfile
import json
import appex
import clipboard
import console
def get_request_data(path):
with zipfile.ZipFile(path, 'r') as z:
with z.open('model.json') as f:
data = json.load(f)
if 'request.dump' in z.namelist():
with z.open('request.dump') as f:
body = str(f.read(), encoding='utf-8')
data['requestBody'] = body
return data
path = appex.get_file_path()
data = get_request_data(path)
body = data.get('requestBody', '')
url = data['URL']
method = data['method'].lower()
headers = {k: v for k, v in [
i.split(': ', 1) for i in data['requestHeader'].split('\r\n')[1:] if i]}
js = """
// 赞赏:邀请码`A1040276307`
// 链接`http://html34.qukantoutiao.net/qpr2/bBmQ.html?pid=5eb14518`
// 农妇山泉 -> 有点咸
const cookieName = '米读阅读时长'
const signinfo = {}
const senku = init()
// 开启debug模式,每次脚本执行会显示通知,默认false
const debug = false
debug ? senku.setdata('true', 'debug') : senku.setdata('false', 'debug')
"""
js = js + f'''
const urlVal = {json.dumps(url)}
const bodyVal = {json.dumps(body)}
const headerVal = {json.dumps(headers, indent=4)}
const request = {{
url: urlVal,
headers: headerVal,
body: bodyVal
}}
'''
js = js + """
;
(sign = async () => {
senku.log(`🔔 ${cookieName}`)
await readTime()
showmsg()
senku.done()
})().catch((e) => senku.log(` ${cookieName} 签到失败: ${e}`), senku.done())
// 阅读时长
function readTime() {
return new Promise((resolve, reject) => {
senku.post(request, (error, response, data) => {
try {
senku.log(` ${cookieName} readTime - response: ${JSON.stringify(response)}`)
signinfo.readTime = JSON.parse(data)
resolve()
} catch (e) {
senku.msg(cookieName, `阅读时长: 失败`, `说明: ${e}`)
senku.log(` ${cookieName} readTime - 签到失败: ${e}`)
senku.log(` ${cookieName} readTime - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
function showmsg() {
let subTitle = ''
let detail = ''
if (signinfo.readTime && signinfo.readTime.code == 0) {
const coin = signinfo.readTime.data.coin
const readTotalMinute = signinfo.readTime.data.readTotalMinute
const total_coin = signinfo.readTime.data.total_coin
coin == 0 ? detail += `` : detail += `阅读时长获得${coin}💰`
readTotalMinute ? detail += ` 阅读时长${readTotalMinute / 2}分钟,该账户:${total_coin}💰` : detail += `该账户:${total_coin}💰`
} else if (signinfo.readTime.code != 0) {
detail += `阅读时长错误代码${signinfo.readTime.code},错误信息${signinfo.readTime.message}`
senku.msg(cookieName, subTitle, detail)
} else {
detail += '【阅读时长】失败'
senku.msg(cookieName, subTitle, detail)
}
if (senku.getdata('debug') == 'true' || detail && signinfo.readTime.data.readTotalMinute % 60 == 0) {
senku.msg(cookieName, subTitle, detail)
} else if (senku.getdata('debug') == 'true' || signinfo.readTime.data.readTotalMinute % 60 == 0) {
senku.msg(cookieName, '阅读结果', '时间未到')
}
}
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
}
}
"""
print(js)
clipboard.set(js)
console.hud_alert('Copyed!')

View File

@ -1,452 +0,0 @@
// 赞赏:邀请码`A1040276307`
// 链接`http://html34.qukantoutiao.net/qpr2/bBmQ.html?pid=5eb14518`
// 农妇山泉 -> 有点咸
/********************
* 1 为了方便任意脚本可以清除Cookie, 任意一个脚本将DeleteCookie = true且选择要清除的账号都可以生效
* 2 debug模式可以在Surge&&Qx中开启,方便你判定多用户及脚本运行情况
* 3 Qx==>dubug:miduRede构造请求
* 4 Surge==>debug:load脚本->evalaute
* 5脚本默认每半小时通知一次,建议自己先debug看看是否成功
*********************/
// 是否开启清除Cookie
const DeleteCookie = false // 清除所有Cookie,将下方改为true,默认false
// 选取清除操作
const DeleteCookieAll = false // 清除所有
const DeleteCookieOne = false // 清除账户一
const DeleteCookieTwo = false // 清除账户二
const bind = true // 绑定作者邀请码,默认true,可更改为false
const cookieName = '米读'
const senku = init()
if (DeleteCookie) {
const one = senku.getdata('tokenMidu_read')
const two = senku.getdata('tokenMidu_sign')
const three = senku.getdata('tokenMidu_read2')
const four = senku.getdata('tokenMidu_sign2')
if (DeleteCookieAll) {
if (one || two || three || four) {
senku.setdata("", 'senku_signbody_midu')
senku.setdata("", 'senku_signbody_midu2')
senku.setdata("", 'senku_readTimebody_midu')
senku.setdata("", 'senku_readTimebody_midu2')
senku.setdata("", 'senku_readTimeheader_midu')
senku.setdata("", 'senku_readTimeheader_midu2')
senku.setdata("", "tokenMidu_read")
senku.setdata("", "tokenMidu_read2")
senku.setdata("", "tokenMidu_sign")
senku.setdata("", "tokenMidu_sign2")
senku.msg("米读 Cookie清除成功 !", "", '请手动关闭脚本内"DeleteCookie"选项')
} else {
senku.msg("米读 无可清除的Cookie !", "", '请手动关闭脚本内"DeleteCookie"选项')
}
} else if (DeleteCookieOne) {
if (one || two) {
senku.setdata("", 'senku_signbody_midu')
senku.setdata("", 'senku_readTimebody_midu')
senku.setdata("", 'senku_readTimeheader_midu')
senku.setdata("", "tokenMidu_read")
senku.setdata("", "tokenMidu_sign")
senku.msg("米读 Cookie清除成功 !", "清除账户一选项", '请手动关闭脚本内"DeleteCookie"选项')
} else {
senku.msg("米读 无可清除的Cookie !", "清除账户一选项", '请手动关闭脚本内"DeleteCookie"选项')
}
} else if (DeleteCookieTwo) {
if (three || four) {
senku.setdata("", 'senku_signbody_midu2')
senku.setdata("", 'senku_readTimebody_midu2')
senku.setdata("", 'senku_readTimeheader_midu2')
senku.setdata("", "tokenMidu_read2")
senku.setdata("", "tokenMidu_sign2")
senku.msg("米读 Cookie清除成功 !", "清除账户二选项", '请手动关闭脚本内"DeleteCookie"选项')
} else {
senku.msg("米读 无可清除的Cookie !", "清除账户二选项", '请手动关闭脚本内"DeleteCookie"选项')
}
} else {
senku.msg("米读 清除Cookie !", "未选取任何选项", '请手动关闭脚本内"DeleteCookie"选项')
}
}
function initial() {
signinfo = {
addnumList: [],
rollList: [],
doubleList: []
}
}
bind ? '' : senku.setdata('', 'bind')
;
(sign = () => {
senku.log(`🔔 ${cookieName}`)
senku.getdata('tokenMidu_sign') ? '' : senku.msg('米读签到', '', '不存在Cookie')
DualAccount = true
if (senku.getdata('tokenMidu_sign')) {
tokenVal = senku.getdata('tokenMidu_read')
readTimeheaderVal = senku.getdata('senku_readTimeheader_midu')
readTimebodyVal = senku.getdata('senku_readTimebody_midu')
signbodyVal = senku.getdata('senku_signbody_midu')
all()
}
})()
async function all() {
try {
senku.log(`🍎${signbodyVal}`)
const headerVal = readTimeheaderVal
const urlVal = readTimebodyVal
const key = signbodyVal
const token = tokenVal
initial()
await userInfo(key)
await signDay(key)
await signVideo(key)
await dice_index(key)
if (signinfo.dice_index && signinfo.dice_index.code == 0) {
const remain_add_num = signinfo.dice_index.data.remain_add_chance_num
for (let index = 0; index < remain_add_num; index++) {
await dice_addnum(key)
}
await dice_index(key)
const chance_num = signinfo.dice_index.data.chance_num
for (let index = 0; index < chance_num; index++) {
await dice_roll(key)
await dice_double(key)
}
}
if (senku.getdata('bind')) {
await Bind()
}
await showmsg()
senku.done()
} catch (e) {
senku.msg(cookieName, `失败`, `说明: ${e}`)
senku.log(`${cookieName} - 失败: ${e}`)
senku.done()
}
}
function double() {
initial()
DualAccount = false
if (senku.getdata('tokenMidu_sign2')) {
tokenVal = senku.getdata('tokenMidu_read2')
readTimeheaderVal = senku.getdata('senku_readTimeheader_midu2')
readTimebodyVal = senku.getdata('senku_readTimebody_midu2')
signbodyVal = senku.getdata('senku_signbody_midu2')
all()
}
}
// 绑定
function Bind() {
return new Promise((resolve, reject) => {
const BindurlVal = 'http://fisson.1sapp.com/nlx/shareLink/tmpBind'
const url = {
url: BindurlVal,
headers: {},
body: 'app_id=7&act_type=1&act_name=grad_pupil&invite_code=A1040276307&telephone=' + signinfo.userInfo.data.mobile
}
url.headers['Host'] = 'fisson.1sapp.com'
url.headers['Content-Type'] = 'application/x-www-form-urlencoded'
url.headers['User-Agent'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148'
senku.post(url, (error, response, data) => {
senku.setdata('', 'bind')
resolve()
})
})
}
// 用户信息
function userInfo(bodyVal) {
return new Promise((resolve, reject) => {
const userInfourlVal = 'https://apiwz.midukanshu.com/wz/user/getInfo?' + bodyVal
const url = {
url: userInfourlVal,
headers: {}
}
url.headers['Host'] = 'apiwz.midukanshu.com'
url.headers['Content-Type'] = 'application/x-www-form-urlencoded'
url.headers['User-Agent'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148'
senku.post(url, (error, response, data) => {
try {
senku.log(`🐍🐢 ${cookieName} userInfo - response: ${JSON.stringify(response)}`)
signinfo.userInfo = JSON.parse(data)
resolve()
} catch (e) {
senku.msg(cookieName, `获取用户信息: 失败`, `说明: ${e}`)
senku.log(`${cookieName} userInfo - 获取用户信息失败: ${e}`)
senku.log(`${cookieName} userInfo - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
// 骰子信息
function dice_index(bodyVal) {
return new Promise((resolve, reject) => {
const dice_index_urlVal = 'https://apiwz.midukanshu.com/wz/dice/index?' + bodyVal
const url = {
url: dice_index_urlVal,
headers: {}
}
url.headers['Host'] = 'apiwz.midukanshu.com'
url.headers['Content-Type'] = 'application/x-www-form-urlencoded'
url.headers['User-Agent'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148'
senku.post(url, (error, response, data) => {
try {
senku.log(`🐍🐢 ${cookieName} dice_index - response: ${JSON.stringify(response)}`)
signinfo.dice_index = JSON.parse(data)
resolve()
} catch (e) {
senku.msg(cookieName, `骰子信息: 失败`, `说明: ${e}`)
senku.log(`${cookieName} dice_index - 骰子信息失败: ${e}`)
senku.log(`${cookieName} dice_index - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
// 掷骰子
function dice_roll(bodyVal) {
return new Promise((resolve, reject) => {
const dice_roll_urlVal = 'https://apiwz.midukanshu.com/wz/dice/roll?' + bodyVal
const url = {
url: dice_roll_urlVal,
headers: {}
}
url.headers['Host'] = 'apiwz.midukanshu.com'
url.headers['Content-Type'] = 'application/x-www-form-urlencoded'
url.headers['User-Agent'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148'
senku.post(url, (error, response, data) => {
try {
senku.log(`🐍🐢 ${cookieName} dice_roll - response: ${JSON.stringify(response)}`)
if (JSON.parse(data).code == 0) {
signinfo.rollList.push(JSON.parse(data))
}
resolve()
} catch (e) {
senku.msg(cookieName, `掷骰子: 失败`, `说明: ${e}`)
senku.log(`${cookieName} dice_roll - 掷骰子失败: ${e}`)
senku.log(`${cookieName} dice_roll - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
// 骰子双倍奖励
function dice_double(bodyVal) {
return new Promise((resolve, reject) => {
const dice_double_urlVal = 'https://apiwz.midukanshu.com/wz/dice/doubleReward?' + bodyVal
const url = {
url: dice_double_urlVal,
headers: {}
}
url.headers['Host'] = 'apiwz.midukanshu.com'
url.headers['Content-Type'] = 'application/x-www-form-urlencoded'
url.headers['User-Agent'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148'
senku.post(url, (error, response, data) => {
try {
senku.log(`🐍🐢 ${cookieName} dice_double - response: ${JSON.stringify(response)}`)
if (JSON.parse(data).code == 0) {
signinfo.doubleList.push(JSON.parse(data))
}
resolve()
} catch (e) {
senku.msg(cookieName, `骰子双倍奖励: 失败`, `说明: ${e}`)
senku.log(`${cookieName} dice_double - 骰子双倍奖励失败: ${e}`)
senku.log(`${cookieName} dice_double - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
// 获取骰子次数
function dice_addnum(bodyVal) {
return new Promise((resolve, reject) => {
const dice_addnum_urlVal = 'https://apiwz.midukanshu.com/wz/dice/addChangeNumByRewardVideo?' + bodyVal
const url = {
url: dice_addnum_urlVal,
headers: {}
}
url.headers['Host'] = 'apiwz.midukanshu.com'
url.headers['Content-Type'] = 'application/x-www-form-urlencoded'
url.headers['User-Agent'] = 'User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 13_4_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 miduapp qapp'
senku.post(url, (error, response, data) => {
try {
senku.log(`🐍🐢 ${cookieName} dice_addnum - response: ${JSON.stringify(response)}`)
if (JSON.parse(data).code == 0) {
signinfo.addnumList.push(JSON.parse(data))
}
resolve()
} catch (e) {
senku.msg(cookieName, `获取骰子次数: 失败`, `说明: ${e}`)
senku.log(`${cookieName} dice_addnum - 获取骰子次数失败: ${e}`)
senku.log(`${cookieName} dice_addnum - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
// 每日签到
function signDay(bodyVal) {
return new Promise((resolve, reject) => {
const signurlVal = 'https://apiwz.midukanshu.com/wz/task/signInV2?' + bodyVal
const url = {
url: signurlVal,
headers: {}
}
url.headers['Host'] = 'apiwz.midukanshu.com'
url.headers['Content-Type'] = 'application/x-www-form-urlencoded'
url.headers['User-Agent'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148'
senku.post(url, (error, response, data) => {
try {
senku.log(`🐍🐢 ${cookieName} signDay - response: ${JSON.stringify(response)}`)
signinfo.signDay = JSON.parse(data)
resolve()
} catch (e) {
senku.msg(cookieName, `签到结果: 失败`, `说明: ${e}`)
senku.log(`${cookieName} signDay - 签到失败: ${e}`)
senku.log(`${cookieName} signDay - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
// 签到视频奖励
function signVideo(bodyVal) {
return new Promise((resolve, reject) => {
const signVideourlVal = 'https://apiwz.midukanshu.com/wz/task/signVideoReward?' + bodyVal
const url = {
url: signVideourlVal,
headers: {}
}
url.headers['Host'] = 'apiwz.midukanshu.com'
url.headers['Content-Type'] = 'application/x-www-form-urlencoded'
url.headers['User-Agent'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148'
senku.post(url, (error, response, data) => {
try {
senku.log(`🐍🐢 ${cookieName} signVideo - response: ${JSON.stringify(response)}`)
signinfo.signVideo = JSON.parse(data)
resolve()
} catch (e) {
senku.msg(cookieName, `签到视频: 失败`, `说明: ${e}`)
senku.log(`${cookieName} signVideo - 签到视频失败: ${e}`)
senku.log(`${cookieName} signVideo - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
function showmsg() {
return new Promise((resolve, reject) => {
let subTitle = ''
let detail = ''
const name = signinfo.userInfo.data.nickname ? signinfo.userInfo.data.nickname : `未设置昵称`
// 签到信息
if (signinfo.signDay && signinfo.signDay.code == 0) {
if (signinfo.signDay.data) {
const amount = signinfo.signDay.data.amount
amount ? detail += `【签到奖励】获得${amount}💰\n` : detail += `【签到奖励】已获取过奖励\n`
}
} else subTitle += '签到:失败'
if (signinfo.signVideo && signinfo.signVideo.code == 0) {
const amount = signinfo.signVideo.data.amount
amount ? detail += `【签到视频】获得${amount}💰\n` : detail += `【签到视频】已获取过奖励\n`
} else subTitle += '签到视频:失败'
// 骰子信息
// 次数
if (signinfo.addnumList.length > 0) {
detail += `【骰子次数】增加${signinfo.addnumList.length}\n`
} else {
detail += `【骰子次数】无次数增加\n`
}
// 掷骰子
if (signinfo.rollList.length > 0) {
let i = 0
for (const roll of signinfo.rollList) {
i += 1
roll.code == 0 ? detail += `【骰子奖励】第${i}${roll.data.roll_coin}💰\n` : detail += `【骰子奖励】已获取过奖励\n`
}
} else {
detail += `【骰子奖励】无次数掷骰子\n`
}
senku.msg(cookieName + ` 用户:${name}`, subTitle, detail)
if (DualAccount) double()
resolve()
})
}
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
}
}

View File

@ -1,479 +0,0 @@
"""
@author: GideonSenku, modified by pysta
@file: SurgeToJs.py
@createTime: 2020-05-01
本脚本用作曲线双阅读,结合APP:py3使用
1登陆要阅读的账号一.....,理论无限
2Surge抓包记录找到https://apiwz.midukanshu.com/wz/dice/index,选择该记录导出,使用pythonista3运行miduSign.py
3在Surge->脚本->新增, 脚本名:自定义不要重复就好, 脚本类型选择Cron, cron表达式: */1 * * * * 脚本位置->本地
54编辑脚本:贴贴py3的结果
"""
import zipfile
import json
import appex
import clipboard
import console
def get_request_data(path):
with zipfile.ZipFile(path, 'r') as z:
with z.open('model.json') as f:
data = json.load(f)
if 'request.dump' in z.namelist():
with z.open('request.dump') as f:
body = str(f.read(), encoding='utf-8')
data['requestBody'] = body
return data
path = appex.get_file_path()
data = get_request_data(path)
body = data.get('requestBody', '')
url = data['URL']
method = data['method'].lower()
headers = {k: v for k, v in [
i.split(': ', 1) for i in data['requestHeader'].split('\r\n')[1:] if i]}
js = """
// 赞赏:邀请码`A1040276307`
// 链接`http://html34.qukantoutiao.net/qpr2/bBmQ.html?pid=5eb14518`
// 农妇山泉 -> 有点咸
const cookieName = '米读'
const senku = init()
const signinfo = {
addnumList: [],
rollList: [],
doubleList: []
}
"""
js = js + f'''
const urlVal = {json.dumps(url)}
const bodyVal = {json.dumps(body)}
const headerVal = {json.dumps(headers, indent=4)}
const request = {{
url: urlVal,
headers: headerVal,
body: bodyVal
}}
'''
js = js + """
;
(sign = async () => {
senku.log(`🔔 ${cookieName}`)
await userInfo()
await signDay()
await signVideo()
await dice_index()
if (signinfo.dice_index && signinfo.dice_index.code == 0) {
const remain_add_num = signinfo.dice_index.data.remain_add_chance_num
for (let index = 0; index < remain_add_num; index++) {
await dice_addnum()
}
await dice_index()
const chance_num = signinfo.dice_index.data.chance_num
for (let index = 0; index < chance_num; index++) {
await dice_roll()
await dice_double()
}
}
await userInfo()
await prizeInfo()
if (signinfo.prizeInfo.data.total_num) {
await prizeTask()
await drawPrize()
}
await Bind()
showmsg()
senku.done()
})().catch((e) => senku.log(` ${cookieName} 签到失败: ${e}`), senku.done())
// 用户信息
function userInfo() {
return new Promise((resolve, reject) => {
const userInfourlVal = 'https://apiwz.midukanshu.com/wz/user/getInfo?' + bodyVal
const url = {
url: userInfourlVal,
headers: headerVal
}
url.headers['Host'] = 'apiwz.midukanshu.com'
url.headers['Content-Type'] = 'application/x-www-form-urlencoded'
url.headers['User-Agent'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148'
senku.post(url, (error, response, data) => {
try {
senku.log(`🐍🐢 ${cookieName} userInfo - response: ${JSON.stringify(response)}`)
signinfo.userInfo = JSON.parse(data)
resolve()
} catch (e) {
senku.msg(cookieName, `获取用户信息: 失败`, `说明: ${e}`)
senku.log(` ${cookieName} userInfo - 获取用户信息失败: ${e}`)
senku.log(` ${cookieName} userInfo - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
// 绑定
function Bind() {
return new Promise((resolve, reject) => {
const BindurlVal = 'http://fisson.1sapp.com/nlx/shareLink/tmpBind'
const url = {
url: BindurlVal,
headers: {},
body: 'app_id=7&act_type=1&act_name=grad_pupil&invite_code=A1040276307&telephone=' + signinfo.userInfo.data.mobile
}
url.headers['Host'] = 'fisson.1sapp.com'
url.headers['Content-Type'] = 'application/x-www-form-urlencoded'
url.headers['User-Agent'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148'
senku.post(url, (error, response, data) => {
senku.setdata('', 'bind')
resolve()
})
})
}
// 抽奖
function drawPrize() {
return new Promise((resolve, reject) => {
const drawPrizeurlVal = 'https://apiwz.midukanshu.com/wz/task/drawPrize?' + bodyVal
const url = {
url: drawPrizeurlVal,
headers: {}
}
url.headers['Host'] = 'apiwz.midukanshu.com'
url.headers['Content-Type'] = 'application/x-www-form-urlencoded'
url.headers['User-Agent'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148'
senku.post(url, (error, response, data) => {
try {
senku.log(`🐍🐢 ${cookieName} drawPrize - response: ${JSON.stringify(response)}`)
signinfo.drawPrize = JSON.parse(data)
resolve()
} catch (e) {
senku.msg(cookieName, `抽奖: 失败`, `说明: ${e}`)
senku.log(` ${cookieName} drawPrize - 抽奖失败: ${e}`)
senku.log(` ${cookieName} drawPrize - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
// 观看视频获取抽奖机会
function prizeTask() {
return new Promise((resolve, reject) => {
const prizeTaskurlVal = 'https://apiwz.midukanshu.com/wz/task/prizeTask?' + bodyVal
const url = {
url: prizeTaskurlVal,
headers: {}
}
url.headers['Host'] = 'apiwz.midukanshu.com'
url.headers['Content-Type'] = 'application/x-www-form-urlencoded'
url.headers['User-Agent'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148'
senku.post(url, (error, response, data) => {
try {
senku.log(`🐍🐢 ${cookieName} prizeTask - response: ${JSON.stringify(response)}`)
signinfo.prizeTask = JSON.parse(data)
resolve()
} catch (e) {
senku.msg(cookieName, `观看视频抽奖: 失败`, `说明: ${e}`)
senku.log(` ${cookieName} prizeTask - 观看视频抽奖失败: ${e}`)
senku.log(` ${cookieName} prizeTask - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
// 抽奖信息
function prizeInfo() {
return new Promise((resolve, reject) => {
const prizeInfourlVal = 'https://apiwz.midukanshu.com/wz/task/prizeList?' + bodyVal
const url = {
url: prizeInfourlVal,
headers: {}
}
url.headers['Host'] = 'apiwz.midukanshu.com'
url.headers['Content-Type'] = 'application/x-www-form-urlencoded'
url.headers['User-Agent'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148'
senku.post(url, (error, response, data) => {
try {
senku.log(`🐍🐢 ${cookieName} prizeInfo - response: ${JSON.stringify(response)}`)
signinfo.prizeInfo = JSON.parse(data)
resolve()
} catch (e) {
senku.msg(cookieName, `抽奖信息: 失败`, `说明: ${e}`)
senku.log(` ${cookieName} prizeInfo - 抽奖信息失败: ${e}`)
senku.log(` ${cookieName} prizeInfo - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
// 骰子信息
function dice_index() {
return new Promise((resolve, reject) => {
const dice_index_urlVal = 'https://apiwz.midukanshu.com/wz/dice/index?' + bodyVal
const url = {
url: dice_index_urlVal,
headers: headerVal
}
url.headers['Host'] = 'apiwz.midukanshu.com'
url.headers['Content-Type'] = 'application/x-www-form-urlencoded'
url.headers['User-Agent'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148'
senku.post(url, (error, response, data) => {
try {
senku.log(`🐍🐢 ${cookieName} dice_index - response: ${JSON.stringify(response)}`)
signinfo.dice_index = JSON.parse(data)
resolve()
} catch (e) {
senku.msg(cookieName, `骰子信息: 失败`, `说明: ${e}`)
senku.log(` ${cookieName} dice_index - 骰子信息失败: ${e}`)
senku.log(` ${cookieName} dice_index - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
// 掷骰子
function dice_roll() {
return new Promise((resolve, reject) => {
const dice_roll_urlVal = 'https://apiwz.midukanshu.com/wz/dice/roll?' + bodyVal
const url = {
url: dice_roll_urlVal,
headers: headerVal
}
url.headers['Host'] = 'apiwz.midukanshu.com'
url.headers['Content-Type'] = 'application/x-www-form-urlencoded'
url.headers['User-Agent'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148'
senku.post(url, (error, response, data) => {
try {
senku.log(`🐍🐢 ${cookieName} dice_roll - response: ${JSON.stringify(response)}`)
if (JSON.parse(data).code == 0) {
signinfo.rollList.push(JSON.parse(data))
}
resolve()
} catch (e) {
senku.msg(cookieName, `掷骰子: 失败`, `说明: ${e}`)
senku.log(` ${cookieName} dice_roll - 掷骰子失败: ${e}`)
senku.log(` ${cookieName} dice_roll - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
// 骰子双倍奖励
function dice_double() {
return new Promise((resolve, reject) => {
const dice_double_urlVal = 'https://apiwz.midukanshu.com/wz/dice/doubleReward?' + bodyVal
const url = {
url: dice_double_urlVal,
headers: headerVal
}
url.headers['Host'] = 'apiwz.midukanshu.com'
url.headers['Content-Type'] = 'application/x-www-form-urlencoded'
url.headers['User-Agent'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148'
senku.post(url, (error, response, data) => {
try {
senku.log(`🐍🐢 ${cookieName} dice_double - response: ${JSON.stringify(response)}`)
if (JSON.parse(data).code == 0) {
signinfo.doubleList.push(JSON.parse(data))
}
resolve()
} catch (e) {
senku.msg(cookieName, `骰子双倍奖励: 失败`, `说明: ${e}`)
senku.log(` ${cookieName} dice_double - 骰子双倍奖励失败: ${e}`)
senku.log(` ${cookieName} dice_double - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
// 获取骰子次数
function dice_addnum() {
return new Promise((resolve, reject) => {
const dice_addnum_urlVal = 'https://apiwz.midukanshu.com/wz/dice/addChangeNumByRewardVideo?' + bodyVal
const url = {
url: dice_addnum_urlVal,
headers: headerVal
}
url.headers['Host'] = 'apiwz.midukanshu.com'
url.headers['Content-Type'] = 'application/x-www-form-urlencoded'
url.headers['User-Agent'] = 'User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 13_4_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 miduapp qapp'
senku.post(url, (error, response, data) => {
try {
senku.log(`🐍🐢 ${cookieName} dice_addnum - response: ${JSON.stringify(response)}`)
if (JSON.parse(data).code == 0) {
signinfo.addnumList.push(JSON.parse(data))
}
resolve()
} catch (e) {
senku.msg(cookieName, `获取骰子次数: 失败`, `说明: ${e}`)
senku.log(` ${cookieName} dice_addnum - 获取骰子次数失败: ${e}`)
senku.log(` ${cookieName} dice_addnum - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
// 每日签到
function signDay() {
return new Promise((resolve, reject) => {
const signurlVal = 'https://apiwz.midukanshu.com/wz/task/signInV2?' + bodyVal
const url = {
url: signurlVal,
headers: headerVal
}
url.headers['Host'] = 'apiwz.midukanshu.com'
url.headers['Content-Type'] = 'application/x-www-form-urlencoded'
url.headers['User-Agent'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148'
senku.post(url, (error, response, data) => {
try {
senku.log(`🐍🐢 ${cookieName} signDay - response: ${JSON.stringify(response)}`)
signinfo.signDay = JSON.parse(data)
resolve()
} catch (e) {
senku.msg(cookieName, `签到结果: 失败`, `说明: ${e}`)
senku.log(` ${cookieName} signDay - 签到失败: ${e}`)
senku.log(` ${cookieName} signDay - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
// 签到视频奖励
function signVideo() {
return new Promise((resolve, reject) => {
const signVideourlVal = 'https://apiwz.midukanshu.com/wz/task/signVideoReward?' + bodyVal
const url = {
url: signVideourlVal,
headers: headerVal
}
url.headers['Host'] = 'apiwz.midukanshu.com'
url.headers['Content-Type'] = 'application/x-www-form-urlencoded'
url.headers['User-Agent'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148'
senku.post(url, (error, response, data) => {
try {
senku.log(`🐍🐢 ${cookieName} signVideo - response: ${JSON.stringify(response)}`)
signinfo.signVideo = JSON.parse(data)
resolve()
} catch (e) {
senku.msg(cookieName, `签到视频: 失败`, `说明: ${e}`)
senku.log(` ${cookieName} signVideo - 签到视频失败: ${e}`)
senku.log(` ${cookieName} signVideo - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
function showmsg() {
let subTitle = ''
let detail = ''
const name = signinfo.userInfo.data.nickname ? signinfo.userInfo.data.nickname : `未设置昵称`
// 签到信息
if (signinfo.signDay && signinfo.signDay.code == 0) {
if (signinfo.signDay.data) {
const amount = signinfo.signDay.data.amount
amount ? detail += `签到奖励获得${amount}💰\n` : detail += `签到奖励已获取过奖励\n`
}
} else subTitle += '签到:失败'
if (signinfo.signVideo && signinfo.signVideo.code == 0) {
const amount = signinfo.signVideo.data.amount
amount ? detail += `签到视频获得${amount}💰\n` : detail += `签到视频已获取过奖励\n`
} else subTitle += '签到视频:失败'
// 骰子信息
// 次数
if (signinfo.addnumList.length > 0) {
detail += `骰子次数增加${signinfo.addnumList.length}\n`
} else {
detail += `骰子次数无次数增加\n`
}
// 掷骰子
if (signinfo.rollList.length > 0) {
let i = 0
for (const roll of signinfo.rollList) {
i += 1
roll.code == 0 ? detail += `骰子奖励${i}${roll.data.roll_coin}💰\n` : detail += `骰子奖励已获取过奖励\n`
}
} else {
detail += `骰子奖励无次数掷骰子\n`
}
senku.msg(cookieName + ` 用户:${name}`, subTitle, detail)
}
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
}
}
"""
print(js)
clipboard.set(js)
console.hud_alert('Copyed!')

View File

@ -1,91 +0,0 @@
# 米游社
> 代码已同时兼容 Surge & QuanX, 使用同一份签到脚本即可
## 配置 (Surge)
```properties
[MITM]
api-takumi.mihoyo.com
[Script]
http-request ^https:\/\/api-takumi.mihoyo.com\/apihub\/api\/getGameList script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/mihoyo/mihoyo.cookie.js
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/mihoyo/mihoyo.js
```
## 配置 (QuanX)
```properties
[MITM]
api-takumi.mihoyo.com
[rewrite_local]
^https:\/\/api-takumi.mihoyo.com\/apihub\/api\/getGameList url script-request-header mihoyo.cookie.js
[task_local]
1 0 * * * mihoyo.js
```
## 说明
1. 先把`api-takumi.mihoyo.com`加到`[MITM]`
2. 再配置重写规则:
- Surge: 把两条远程脚本放到`[Script]`
- QuanX: 把`mihoyo.cookie.js`和`mihoyo.js`传到`On My iPhone - Quantumult X - Scripts` (传到 iCloud 相同目录也可, 注意要打开 quanx 的 iCloud 开关)
3. 打开 APP , 系统提示: `获取Cookie: 成功`
4. 最后就可以把第 1 条脚本注释掉了
5. 运行一次脚本, 如果提示重复签到, 那就算成功了!
> 第 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)

View File

@ -1,58 +0,0 @@
const cookieName = '米游社'
const signurlKey = 'chavy_signurl_mihoyo'
const signheaderKey = 'chavy_signheader_mihoyo'
const chavy = init()
if ($request && $request.method != 'OPTIONS') {
const signurlVal = $request.url
const signheaderVal = JSON.stringify($request.headers)
if (signurlVal) chavy.setdata(signurlVal, signurlKey)
if (signheaderVal) chavy.setdata(signheaderVal, signheaderKey)
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()

View File

@ -1,104 +0,0 @@
const cookieName = '米游社'
const signurlKey = 'chavy_signurl_mihoyo'
const signheaderKey = 'chavy_signheader_mihoyo'
const chavy = init()
const signurlVal = chavy.getdata(signurlKey)
const signheaderVal = chavy.getdata(signheaderKey)
const signinfo = []
let bbslist = []
sign()
function sign() {
const url = {url: `https://api-takumi.mihoyo.com/apihub/api/getGameList`, headers: JSON.parse(signheaderVal)}
chavy.get(url, (error, response, data) => {
const result = JSON.parse(data)
bbslist = result.data.list
for (bbs of bbslist) signbbs(bbs)
check()
})
}
function signbbs(bbs) {
const url = {
url: `https://api-takumi.mihoyo.com/apihub/sapi/signIn?gids=${bbs.id}`,
headers: JSON.parse(signheaderVal)
}
chavy.post(url, (error, response, data) => signinfo.push(data))
}
function check(checkms = 0) {
if (bbslist.length == signinfo.length) {
showmsg()
} else {
if (checkms > 5000) {
chavy.msg(`${cookieName}`, `签到失败: 超时退出`, ``)
chavy.done()
} else {
setTimeout(() => check(checkms + 100), 100)
}
}
}
function showmsg() {
const totalcnt = bbslist.length
let signed = 0
let skiped = 0
let succnt = 0
let failcnt = 0
for (info of signinfo) {
const i = JSON.parse(info)
if (i.retcode == 0) (signed += 1), (succnt += 1)
else if (i.retcode == 1008) (signed += 1), (skiped += 1)
else failcnt += 1
}
let subtitle = totalcnt == signed ? '签到结果: 全部成功' : '签到结果: 部分成功'
subtitle = 0 == signed ? '签到结果: 全部失败' : subtitle
const detail = `共签: ${signed}/${totalcnt}, 本次成功: ${succnt}, 失败: ${failcnt}, 重签: ${skiped}`
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.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}
}

View File

@ -1,90 +0,0 @@
# 网易云音乐
> 2020.6.15
>
> 1. 增加自动重试机制 (BoxJs 可调整次数及间隔)
> 2. 增加等级显示 (需按新方式获取会话)
## 配置 (Surge & Loon)
```properties
[MITM]
music.163.com
[Script]
http-request ^https:\/\/music.163.com\/weapi\/user\/level script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/neteasemusic/neteasemusic.cookie.js,requires-body=true
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/neteasemusic/neteasemusic.js
```
## 配置 QuanX
```properties
[MITM]
music.163.com
[rewrite_local]
^https:\/\/music.163.com\/weapi\/user\/level url script-request-body neteasemusic.cookie.js
[task_local]
1 0 * * * neteasemusic.js
```
## 说明
1. 先登录: <https://music.163.com/m/login>
2. 再访问: <https://music.163.com/#/user/level>
3. 提示: `获取会话: 成功!`
> 第 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)

View File

@ -1,61 +0,0 @@
const $ = new Env('网易云音乐')
!(async () => {
$.log('', `🔔 ${$.name}, 获取会话: 开始!`, '')
const session = {}
session.url = $request.url
session.body = $request.body
session.headers = $request.headers
delete session.headers['Content-Length']
$.log('', `url: ${session.url}`, `body: ${session.body}`, `headers: ${JSON.stringify(session.headers)}`)
if ($.setdata(JSON.stringify(session), 'chavy_cookie_neteasemusic')) {
$.subt = '获取会话: 成功!'
} else {
$.subt = '获取会话: 失败!'
}
})()
.catch((e) => {
$.subt = '获取会话: 失败!'
$.desc = `原因: ${e}`
$.log(`${$.name}, 获取会话: 失败! 原因: ${e}!`)
})
.finally(() => {
$.msg($.name, $.subt, $.desc), $.log('', `🔔 ${$.name}, 获取会话: 结束!`, ''), $.done()
})
// prettier-ignore
function Env(s) {
this.name = s, this.data = null, this.logs = [], this.isSurge = (() => "undefined" != typeof $httpClient), this.isQuanX = (() => "undefined" != typeof $task), this.isNode = (() => "undefined" != typeof module && !!module.exports), this.log = ((...s) => {
this.logs = [...this.logs, ...s], s ? console.log(s.join("\n")) : console.log(this.logs.join("\n"))
}), this.msg = ((s = this.name, t = "", i = "") => {
this.isSurge() && $notification.post(s, t, i), this.isQuanX() && $notify(s, t, i);
const e = ["", "==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];
s && e.push(s), t && e.push(t), i && e.push(i), console.log(e.join("\n"))
}), this.getdata = (s => {
if (this.isSurge()) return $persistentStore.read(s);
if (this.isQuanX()) return $prefs.valueForKey(s);
if (this.isNode()) {
const t = "box.dat";
return this.fs = this.fs ? this.fs : require("fs"), this.fs.existsSync(t) ? (this.data = JSON.parse(this.fs.readFileSync(t)), this.data[s]) : null
}
}), this.setdata = ((s, t) => {
if (this.isSurge()) return $persistentStore.write(s, t);
if (this.isQuanX()) return $prefs.setValueForKey(s, t);
if (this.isNode()) {
const i = "box.dat";
return this.fs = this.fs ? this.fs : require("fs"), !!this.fs.existsSync(i) && (this.data = JSON.parse(this.fs.readFileSync(i)), this.data[t] = s, this.fs.writeFileSync(i, JSON.stringify(this.data)), !0)
}
}), this.wait = ((s, t = s) => i => setTimeout(() => i(), Math.floor(Math.random() * (t - s + 1) + s))), this.get = ((s, t) => this.send(s, "GET", t)), this.post = ((s, t) => this.send(s, "POST", t)), this.send = ((s, t, i) => {
if (this.isSurge()) {
const e = "POST" == t ? $httpClient.post : $httpClient.get;
e(s, (s, t, e) => {
t && (t.body = e, t.statusCode = t.status), i(s, t, e)
})
}
this.isQuanX() && (s.method = t, $task.fetch(s).then(s => {
s.status = s.statusCode, i(null, s, s.body)
}, s => i(s.error, s, s))), this.isNode() && (this.request = this.request ? this.request : require("request"), s.method = t, s.gzip = !0, this.request(s, (s, t, e) => {
t && (t.status = t.statusCode), i(null, t, e)
}))
}), this.done = ((s = {}) => this.isNode() ? null : $done(s))
}

View File

@ -1,136 +0,0 @@
const $ = new Env('网易云音乐')
$.VAL_session = $.getdata('chavy_cookie_neteasemusic')
$.CFG_retryCnt = ($.getdata('CFG_neteasemusic_retryCnt') || '10') * 1
$.CFG_retryInterval = ($.getdata('CFG_neteasemusic_retryInterval') || '500') * 1
!(async () => {
$.log('', `🔔 ${$.name}, 开始!`, '')
init()
await signweb()
await signapp()
await getInfo()
await showmsg()
})()
.catch((e) => {
$.log('', `${$.name}, 失败! 原因: ${e}!`, '')
})
.finally(() => {
$.msg($.name, $.subt, $.desc), $.log('', `🔔 ${$.name}, 结束!`, ''), $.done()
})
function init() {
$.isNewCookie = /https:\/\/music.163.com\/weapi\/user\/level/.test($.VAL_session)
$.Cookie = $.isNewCookie ? JSON.parse($.VAL_session).headers.Cookie : $.VAL_session
}
async function signweb() {
for (let signIdx = 0; signIdx < $.CFG_retryCnt; signIdx++) {
await new Promise((resove) => {
const url = {url: `http://music.163.com/api/point/dailyTask?type=1`, headers: {}}
url.headers['Cookie'] = $.Cookie
url.headers['Host'] = 'music.163.com'
url.headers['User-Agent'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Safari/605.1.15'
$.get(url, (error, response, data) => {
try {
$.isWebSuc = JSON.parse(data).code === -2
$.log(`[Web] 第 ${signIdx + 1} 次: ${data}`)
} catch (e) {
$.isWebSuc = false
$.log(`❗️ ${$.name}, 执行失败!`, ` error = ${error || e}`, `response = ${JSON.stringify(response)}`, '')
} finally {
resove()
}
})
})
await new Promise($.wait($.CFG_retryInterval))
if ($.isWebSuc) break
}
}
async function signapp() {
for (let signIdx = 0; signIdx < $.CFG_retryCnt; signIdx++) {
await new Promise((resove) => {
const url = {url: `http://music.163.com/api/point/dailyTask?type=0`, headers: {}}
url.headers['Cookie'] = $.Cookie
url.headers['Host'] = 'music.163.com'
url.headers['User-Agent'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Mobile/15E148 Safari/604.1'
$.get(url, (error, response, data) => {
try {
$.isAppSuc = JSON.parse(data).code === -2
$.log(`[App] 第 ${signIdx + 1} 次: ${data}`)
} catch (e) {
$.isAppSuc = false
$.log(`❗️ ${$.name}, 执行失败!`, ` error = ${error || e}`, `response = ${JSON.stringify(response)}`, '')
} finally {
resove()
}
})
})
await new Promise($.wait($.CFG_retryInterval))
if ($.isAppSuc) break
}
}
function getInfo() {
if (!$.isNewCookie) return
return new Promise((resove) => {
$.post(JSON.parse($.VAL_session), (error, response, data) => {
try {
$.userInfo = JSON.parse(data)
} catch (e) {
$.log(`❗️ ${$.name}, 执行失败!`, ` error = ${error || e}`, `response = ${JSON.stringify(response)}`, '')
} finally {
resove()
}
})
})
}
function showmsg() {
return new Promise((resove) => {
$.subt = $.isWebSuc ? 'PC: 成功' : 'PC: 失败'
$.subt += $.isAppSuc ? ', APP: 成功' : ', APP: 失败'
if ($.isNewCookie && $.userInfo) {
$.desc = `等级: ${$.userInfo.data.level}, 听歌: ${$.userInfo.data.nowPlayCount} => ${$.userInfo.data.nextPlayCount} 升级 (首)`
$.desc = $.userInfo.data.level === 10 ? `等级: ${$.userInfo.data.level}, 你的等级已爆表!` : $.desc
}
resove()
})
}
// prettier-ignore
function Env(s) {
this.name = s, this.data = null, this.logs = [], this.isSurge = (() => "undefined" != typeof $httpClient), this.isQuanX = (() => "undefined" != typeof $task), this.isNode = (() => "undefined" != typeof module && !!module.exports), this.log = ((...s) => {
this.logs = [...this.logs, ...s], s ? console.log(s.join("\n")) : console.log(this.logs.join("\n"))
}), this.msg = ((s = this.name, t = "", i = "") => {
this.isSurge() && $notification.post(s, t, i), this.isQuanX() && $notify(s, t, i);
const e = ["", "==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];
s && e.push(s), t && e.push(t), i && e.push(i), console.log(e.join("\n"))
}), this.getdata = (s => {
if (this.isSurge()) return $persistentStore.read(s);
if (this.isQuanX()) return $prefs.valueForKey(s);
if (this.isNode()) {
const t = "box.dat";
return this.fs = this.fs ? this.fs : require("fs"), this.fs.existsSync(t) ? (this.data = JSON.parse(this.fs.readFileSync(t)), this.data[s]) : null
}
}), this.setdata = ((s, t) => {
if (this.isSurge()) return $persistentStore.write(s, t);
if (this.isQuanX()) return $prefs.setValueForKey(s, t);
if (this.isNode()) {
const i = "box.dat";
return this.fs = this.fs ? this.fs : require("fs"), !!this.fs.existsSync(i) && (this.data = JSON.parse(this.fs.readFileSync(i)), this.data[t] = s, this.fs.writeFileSync(i, JSON.stringify(this.data)), !0)
}
}), this.wait = ((s, t = s) => i => setTimeout(() => i(), Math.floor(Math.random() * (t - s + 1) + s))), this.get = ((s, t) => this.send(s, "GET", t)), this.post = ((s, t) => this.send(s, "POST", t)), this.send = ((s, t, i) => {
if (this.isSurge()) {
const e = "POST" == t ? $httpClient.post : $httpClient.get;
e(s, (s, t, e) => {
t && (t.body = e, t.statusCode = t.status), i(s, t, e)
})
}
this.isQuanX() && (s.method = t, $task.fetch(s).then(s => {
s.status = s.statusCode, i(null, s, s.body)
}, s => i(s.error, s, s))), this.isNode() && (this.request = this.request ? this.request : require("request"), s.method = t, s.gzip = !0, this.request(s, (s, t, e) => {
t && (t.status = t.statusCode), i(null, t, e)
}))
}), this.done = ((s = {}) => this.isNode() ? null : $done(s))
}

Some files were not shown because too many files have changed in this diff Show More