Skip to content

Commit 922d335

Browse files
committed
添加[不背单词]签到以及修正一些小问题
1 parent 20c864d commit 922d335

File tree

3 files changed

+260
-14
lines changed

3 files changed

+260
-14
lines changed

bubei/README.md

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

bubei/bubei.js

+142
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
var appName = '不背单词'
2+
var bubei = init()
3+
var URL = bubei.getdata("UrlBB")
4+
var KEY = bubei.getdata("CookieBB")
5+
6+
let isGetCookie = typeof $request !== 'undefined'
7+
8+
if (isGetCookie) {
9+
getcookie()
10+
} else {
11+
sign()
12+
}
13+
14+
function getcookie() {
15+
var url = $request.url;
16+
if (url) {
17+
var UrlKeyBB = "UrlBB";
18+
var UrlValueBB = url;
19+
if (bubei.getdata(UrlKeyBB) != (undefined || null)) {
20+
if (bubei.getdata(UrlKeyBB) != UrlValueBB) {
21+
var url = bubei.setdata(UrlValueBB, UrlKeyBB);
22+
if (!url) {
23+
bubei.msg("更新" + appName + "Url失败‼️", "", "");
24+
} else {
25+
bubei.msg("更新" + appName + "Url成功🎉", "", "");
26+
}
27+
} else {
28+
bubei.msg(appName + "Url未变化❗️", "", "");
29+
}
30+
} else {
31+
var url = bubei.setdata(UrlValueBB, UrlKeyBB);
32+
if (!url) {
33+
bubei.msg("首次写入" + appName + "Url失败‼️", "", "");
34+
} else {
35+
bubei.msg("首次写入" + appName + "Url成功🎉", "", "");
36+
}
37+
}
38+
} else {
39+
bubei.msg("写入" + appName + "Url失败‼️", "", "配置错误, 无法读取URL, ");
40+
}
41+
if ($request.headers) {
42+
var CookieKeyBB = "CookieBB";
43+
var CookieValueBB = JSON.stringify($request.headers);
44+
if (bubei.getdata(CookieKeyBB) != (undefined || null)) {
45+
if (bubei.getdata(CookieKeyBB) != CookieValueBB) {
46+
var cookie = bubei.setdata(CookieValueBB, CookieKeyBB);
47+
if (!cookie) {
48+
bubei.msg("更新" + appName + "Cookie失败‼️", "", "");
49+
} else {
50+
bubei.msg("更新" + appName + "Cookie成功🎉", "", "");
51+
}
52+
} else {
53+
bubei.msg(appName + "Cookie未变化❗️", "", "");
54+
}
55+
} else {
56+
var cookie = bubei.setdata(CookieValueBB, CookieKeyBB);
57+
if (!cookie) {
58+
bubei.msg("首次写入" + appName + "Cookie失败‼️", "", "");
59+
} else {
60+
bubei.msg("首次写入" + appName + "Cookie成功🎉", "", "");
61+
}
62+
}
63+
} else {
64+
bubei.msg("写入" + appName + "Cookie失败‼️", "", "配置错误, 无法读取请求头, ");
65+
}
66+
bubei.done()
67+
}
68+
69+
function sign() {
70+
var t1 = new Date().getTime()
71+
var t2 = t1 + 1
72+
URL = URL.replace(/by-sign-in\/\d*/g,"by-sign-in/" + t1).replace(/timestamp=\d*/g,"timestamp=" + t2)
73+
const url = { url: URL, headers: JSON.parse(KEY) }
74+
bubei.get(url, (error, response, data) => {
75+
bubei.log(`${appName}, data: ${data}`)
76+
const title = `${appName}`
77+
let subTitle = ''
78+
let detail = ''
79+
const result = JSON.parse(data)
80+
if (result.result_code == 200) {
81+
subTitle = `签到结果: 成功`
82+
} else {
83+
subTitle = `签到结果: 未知`
84+
detail = `说明: ${result.error_body.user_msg}`
85+
}
86+
bubei.msg(title, subTitle, detail)
87+
bubei.done()
88+
})
89+
}
90+
91+
function init() {
92+
isSurge = () => {
93+
return undefined === this.$httpClient ? false : true
94+
}
95+
isQuanX = () => {
96+
return undefined === this.$task ? false : true
97+
}
98+
getdata = (key) => {
99+
if (isSurge()) return $persistentStore.read(key)
100+
if (isQuanX()) return $prefs.valueForKey(key)
101+
}
102+
setdata = (key, val) => {
103+
if (isSurge()) return $persistentStore.write(key, val)
104+
if (isQuanX()) return $prefs.setValueForKey(key, val)
105+
}
106+
msg = (title, subtitle, body) => {
107+
if (isSurge()) $notification.post(title, subtitle, body)
108+
if (isQuanX()) $notify(title, subtitle, body)
109+
}
110+
log = (message) => console.log(message)
111+
get = (url, cb) => {
112+
if (isSurge()) {
113+
$httpClient.get(url, cb)
114+
}
115+
if (isQuanX()) {
116+
url.method = 'GET'
117+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
118+
}
119+
}
120+
post = (url, cb) => {
121+
if (isSurge()) {
122+
$httpClient.post(url, cb)
123+
}
124+
if (isQuanX()) {
125+
url.method = 'POST'
126+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
127+
}
128+
}
129+
put = (url, cb) => {
130+
if (isSurge()) {
131+
$httpClient.put(url, cb)
132+
}
133+
if (isQuanX()) {
134+
url.method = 'PUT'
135+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
136+
}
137+
}
138+
done = (value = {}) => {
139+
$done(value)
140+
}
141+
return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, put, done }
142+
}

zaker/zaker.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var appName = 'ZAKER新闻'
22
var zaker = init()
3-
var URL = zaker.getdata("Url")
4-
var KEY = zaker.getdata("Cookie")
3+
var URL = zaker.getdata("UrlZK")
4+
var KEY = zaker.getdata("CookieZK")
55

66
let isGetCookie = typeof $request !== 'undefined'
77

@@ -14,11 +14,11 @@ if (isGetCookie) {
1414
function getcookie() {
1515
var url = $request.url;
1616
if (url) {
17-
var UrlKey = "Url";
18-
var UrlValue = url;
19-
if (zaker.getdata(UrlKey) != (undefined || null)) {
20-
if (zaker.getdata(UrlKey) != UrlValue) {
21-
var url = zaker.setdata(UrlValue, UrlKey);
17+
var UrlKeyZK = "UrlZK";
18+
var UrlValueZK = url;
19+
if (zaker.getdata(UrlKeyZK) != (undefined || null)) {
20+
if (zaker.getdata(UrlKeyZK) != UrlValueZK) {
21+
var url = zaker.setdata(UrlValueZK, UrlKeyZK);
2222
if (!url) {
2323
zaker.msg("更新" + appName + "Url失败‼️", "", "");
2424
} else {
@@ -28,7 +28,7 @@ function getcookie() {
2828
zaker.msg(appName + "Url未变化❗️", "", "");
2929
}
3030
} else {
31-
var url = zaker.setdata(UrlValue, UrlKey);
31+
var url = zaker.setdata(UrlValueZK, UrlKeyZK);
3232
if (!url) {
3333
zaker.msg("首次写入" + appName + "Url失败‼️", "", "");
3434
} else {
@@ -39,11 +39,11 @@ function getcookie() {
3939
zaker.msg("写入" + appName + "Url失败‼️", "", "配置错误, 无法读取URL, ");
4040
}
4141
if ($request.headers) {
42-
var CookieKey = "Cookie";
43-
var CookieValue = JSON.stringify($request.headers);
44-
if (zaker.getdata(CookieKey) != (undefined || null)) {
45-
if (zaker.getdata(CookieKey) != CookieValue) {
46-
var cookie = zaker.setdata(CookieValue, CookieKey);
42+
var CookieKeyZK = "CookieZK";
43+
var CookieValueZK = JSON.stringify($request.headers);
44+
if (zaker.getdata(CookieKeyZK) != (undefined || null)) {
45+
if (zaker.getdata(CookieKeyZK) != CookieValueZK) {
46+
var cookie = zaker.setdata(CookieValueZK, CookieKeyZK);
4747
if (!cookie) {
4848
zaker.msg("更新" + appName + "Cookie失败‼️", "", "");
4949
} else {
@@ -53,7 +53,7 @@ function getcookie() {
5353
zaker.msg(appName + "Cookie未变化❗️", "", "");
5454
}
5555
} else {
56-
var cookie = zaker.setdata(CookieValue, CookieKey);
56+
var cookie = zaker.setdata(CookieValueZK, CookieKeyZK);
5757
if (!cookie) {
5858
zaker.msg("首次写入" + appName + "Cookie失败‼️", "", "");
5959
} else {

0 commit comments

Comments
 (0)