Skip to content

Commit c73bf77

Browse files
committed
Revert "更新[百度]签到脚本: 屏蔽文库签到(接口返回成功但实际签不上)"
This reverts commit 343e3a5.
1 parent d26e6ff commit c73bf77

4 files changed

Lines changed: 218 additions & 1 deletion

File tree

feng/README.md

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

feng/feng.cookie.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
const cookieName = '威锋网'
2+
const cookieKey = 'chavy_cookie_feng'
3+
const chavy = init()
4+
const cookieVal = $request.headers['Cookie']
5+
if (cookieVal.indexOf('userInfo') > 0) {
6+
if (cookieVal) {
7+
if (chavy.setdata(cookieVal, cookieKey)) {
8+
chavy.msg(`${cookieName}`, '获取Cookie: 成功', '')
9+
chavy.log(`[${cookieName}] 获取Cookie: 成功, cookie: ${cookieVal}`)
10+
}
11+
}
12+
} else {
13+
let subTitle = '获取Cookie: 失败'
14+
let detail = `请确保在已登录状态下获取Cookie`
15+
chavy.msg(`${cookieName}`, subTitle, detail)
16+
chavy.log(`[${cookieName}] ${subTitle}, cookie: ${cookieVal}`)
17+
}
18+
function init() {
19+
isSurge = () => {
20+
return undefined === this.$httpClient ? false : true
21+
}
22+
isQuanX = () => {
23+
return undefined === this.$task ? false : true
24+
}
25+
getdata = (key) => {
26+
if (isSurge()) return $persistentStore.read(key)
27+
if (isQuanX()) return $prefs.valueForKey(key)
28+
}
29+
setdata = (key, val) => {
30+
if (isSurge()) return $persistentStore.write(key, val)
31+
if (isQuanX()) return $prefs.setValueForKey(key, val)
32+
}
33+
msg = (title, subtitle, body) => {
34+
if (isSurge()) $notification.post(title, subtitle, body)
35+
if (isQuanX()) $notify(title, subtitle, body)
36+
}
37+
log = (message) => console.log(message)
38+
get = (url, cb) => {
39+
if (isSurge()) {
40+
$httpClient.get(url, cb)
41+
}
42+
if (isQuanX()) {
43+
url.method = 'GET'
44+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
45+
}
46+
}
47+
post = (url, cb) => {
48+
if (isSurge()) {
49+
$httpClient.post(url, cb)
50+
}
51+
if (isQuanX()) {
52+
url.method = 'POST'
53+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
54+
}
55+
}
56+
done = (value = {}) => {
57+
$done(value)
58+
}
59+
return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done }
60+
}
61+
chavy.done()

feng/feng.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 = 'chavy_cookie_feng'
3+
const chavy = init()
4+
const cookieVal = chavy.getdata(cookieKey)
5+
6+
sign()
7+
8+
function sign() {
9+
const token = decodeURIComponent(decodeURIComponent([...cookieVal.matchAll(/userInfo=(\{[^;]*)/g)][0][1]))
10+
let url = { url: `https://beta-api.feng.com/v1/attendance/userSignIn`, headers: {}, body: {} }
11+
url.headers['Host'] = 'www.xiami.com'
12+
url.headers['Accept'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
13+
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'
14+
chavy.post(url, (error, response, data) => {
15+
chavy.log(data)
16+
})
17+
chavy.done()
18+
}
19+
20+
function init() {
21+
isSurge = () => {
22+
return undefined === this.$httpClient ? false : true
23+
}
24+
isQuanX = () => {
25+
return undefined === this.$task ? false : true
26+
}
27+
getdata = (key) => {
28+
if (isSurge()) return $persistentStore.read(key)
29+
if (isQuanX()) return $prefs.valueForKey(key)
30+
}
31+
setdata = (key, val) => {
32+
if (isSurge()) return $persistentStore.write(key, val)
33+
if (isQuanX()) return $prefs.setValueForKey(key, val)
34+
}
35+
msg = (title, subtitle, body) => {
36+
if (isSurge()) $notification.post(title, subtitle, body)
37+
if (isQuanX()) $notify(title, subtitle, body)
38+
}
39+
log = (message) => console.log(message)
40+
get = (url, cb) => {
41+
if (isSurge()) {
42+
$httpClient.get(url, cb)
43+
}
44+
if (isQuanX()) {
45+
url.method = 'GET'
46+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
47+
}
48+
}
49+
post = (url, cb) => {
50+
if (isSurge()) {
51+
$httpClient.post(url, cb)
52+
}
53+
if (isQuanX()) {
54+
url.method = 'POST'
55+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
56+
}
57+
}
58+
done = (value = {}) => {
59+
$done(value)
60+
}
61+
return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done }
62+
}

tieba/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
> 代码已同时兼容 Surge & QuanX, 使用同一份签到脚本即可
44
5-
> 目前支持签到: 贴吧、文库、知道 (3 合 1)
5+
> 目前支持签到: 贴吧、知道 (2 合 1)
66
77
> 之前已经获取过贴吧 cookie 的话,不需要再次获取 (通用)
88
9+
> 2020.1.3: 屏蔽文库签到, 原因: 实际签不上
10+
911
## 配置 (Surge)
1012

1113
```properties

0 commit comments

Comments
 (0)