Skip to content

Commit 9d70f60

Browse files
authored
Merge pull request chavyleung#53 from AGentleWind/work
添加[百词斩]领取铜板
2 parents 143bd2a + 604eabd commit 9d70f60

3 files changed

Lines changed: 251 additions & 0 deletions

File tree

‎bcz/README.md‎

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

‎bcz/bcz.cookie.js‎

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
const cookieName = '百词斩领取铜板'
2+
const cookieKey = 'cookie_tb'
3+
const shareKey = `share_key`
4+
const senku = init()
5+
6+
if (this.$request && this.$request.headers) {
7+
const cookieVal = $request.headers['Cookie']
8+
const url = $request.url
9+
const index1 = url.indexOf('=')
10+
const index2 = url.indexOf('&')
11+
const shareVal = url.substring(index1+1,index2)
12+
if (cookieVal&&shareVal) {
13+
if (senku.setdata(cookieVal,cookieKey)&&senku.setdata(shareVal,shareKey)) {
14+
senku.msg(`${cookieName}`, '获取Cookie: 成功', '')
15+
senku.log(`[${cookieName}] 获取Cookie: 成功, cookie: ${cookieVal}`)
16+
}
17+
}
18+
}
19+
function init() {
20+
isSurge = () => {
21+
return undefined === this.$httpClient ? false : true
22+
}
23+
isQuanX = () => {
24+
return undefined === this.$task ? false : true
25+
}
26+
getdata = (key) => {
27+
if (isSurge()) return $persistentStore.read(key)
28+
if (isQuanX()) return $prefs.valueForKey(key)
29+
}
30+
setdata = (key, val) => {
31+
if (isSurge()) return $persistentStore.write(key, val)
32+
if (isQuanX()) return $prefs.setValueForKey(key, val)
33+
}
34+
msg = (title, subtitle, body) => {
35+
if (isSurge()) $notification.post(title, subtitle, body)
36+
if (isQuanX()) $notify(title, subtitle, body)
37+
}
38+
log = (message) => console.log(message)
39+
get = (url, cb) => {
40+
if (isSurge()) {
41+
$httpClient.get(url, cb)
42+
}
43+
if (isQuanX()) {
44+
url.method = 'GET'
45+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
46+
}
47+
}
48+
post = (url, cb) => {
49+
if (isSurge()) {
50+
$httpClient.post(url, cb)
51+
}
52+
if (isQuanX()) {
53+
url.method = 'POST'
54+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
55+
}
56+
}
57+
done = (value = {}) => {
58+
$done(value)
59+
}
60+
return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done }
61+
}
62+
senku.done()

‎bcz/bcz.js‎

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
const cookieName = '百词斩领取铜板'
2+
const cookieKey = 'cookie_tb'
3+
const shareKey = `share_key`
4+
const senku = init()
5+
const cookieVal = senku.getdata(cookieKey)
6+
const shareVal = senku.getdata(shareKey)
7+
8+
let signinfo = {} //signinfo 对象初始化
9+
senku.log()
10+
check()
11+
// ^https?://app\.xiaoyuan\.ccb\.com/channelManage/outbreak/addOutbreak Cookie: cookieVal
12+
function check(cb) {
13+
const url = { url: `https://group.baicizhan.com/group/apply_reward`, headers: { Cookie: cookieVal } }
14+
url.headers['Content-Type'] = `text/plain;charset=utf-8`
15+
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`
16+
const key = {share_key:shareVal}
17+
url.body = JSON.stringify(key)
18+
senku.log(url.body)
19+
senku.post(url, (error, response, data) => {
20+
signinfo = JSON.parse(data)
21+
22+
senku.log(JSON.stringify(signinfo))
23+
24+
const title = `${cookieName}`
25+
let subTitle = ``
26+
let detail = ''
27+
if (signinfo.code == 1) {
28+
if (signinfo.data.is_new) {
29+
subTitle += `成功`
30+
detail = `获取铜板数${signinfo.data.reward[2]}`
31+
}
32+
else {
33+
subTitle += `失败(重复签到)`
34+
}
35+
}
36+
else {
37+
detail = `状态: ${signinfo.message}`
38+
subTitle += '失败'
39+
}
40+
senku.msg(title, subTitle, detail)
41+
senku.done()
42+
})
43+
}
44+
45+
46+
function init() {
47+
isSurge = () => {
48+
return undefined === this.$httpClient ? false : true
49+
}
50+
isQuanX = () => {
51+
return undefined === this.$task ? false : true
52+
}
53+
getdata = (key) => {
54+
if (isSurge()) return $persistentStore.read(key)
55+
if (isQuanX()) return $prefs.valueForKey(key)
56+
}
57+
setdata = (key, val) => {
58+
if (isSurge()) return $persistentStore.write(key, val)
59+
if (isQuanX()) return $prefs.setValueForKey(key, val)
60+
}
61+
msg = (title, subtitle, body) => {
62+
if (isSurge()) $notification.post(title, subtitle, body)
63+
if (isQuanX()) $notify(title, subtitle, body)
64+
}
65+
log = (message) => console.log(message)
66+
get = (url, cb) => {
67+
if (isSurge()) {
68+
$httpClient.get(url, cb)
69+
}
70+
if (isQuanX()) {
71+
url.method = 'GET'
72+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
73+
}
74+
}
75+
post = (url, cb) => {
76+
if (isSurge()) {
77+
$httpClient.post(url, cb)
78+
}
79+
if (isQuanX()) {
80+
url.method = 'POST'
81+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
82+
}
83+
}
84+
done = (value = {}) => {
85+
$done(value)
86+
}
87+
return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done }
88+
}

0 commit comments

Comments
 (0)