Skip to content

Commit ab8fb17

Browse files
committed
添加[趣头条]测试版,暂没有对时间戳更改
1 parent 8e0341f commit ab8fb17

3 files changed

Lines changed: 247 additions & 0 deletions

File tree

‎qtt/README.md‎

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# 趣头条
2+
3+
> 代码已同时兼容 Surge & QuanX, 使用同一份签到脚本即可
4+
5+
> QuanX 需要: v1.0.6-build195 及以后版本 (TestFlight)
6+
7+
> 感谢 [@GideonSenku](https://github.com/GideonSenku) Commit
8+
9+
## 配置 (Surge)
10+
11+
```properties
12+
[MITM]
13+
api.1sapp.com
14+
15+
[Script]
16+
http-request ^https:\/\/api\.1sapp\.com\/sign\/sign? script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/qtt/qtt.cookie.js
17+
18+
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/qtt/qtt.js
19+
```
20+
21+
## 配置 (QuanX)
22+
23+
```properties
24+
[MITM]
25+
api.1sapp.com
26+
27+
[rewrite_local]
28+
29+
# [商店版] QuanX v1.0.6-build194 及更早版本
30+
^https:\/\/api\.1sapp\.com\/sign\/sign? url script-request-header qtt.cookie.js
31+
32+
# [TestFlight] QuanX v1.0.6-build195 及以后版本
33+
^https:\/\/api\.1sapp\.com\/sign\/sign? url script-request-header https://raw.githubusercontent.com/chavyleung/scripts/master/qtt/qtt.cookie.js
34+
35+
[task_local]
36+
1 0 * * * qtt.js
37+
```
38+
39+
## 说明
40+
41+
1. 先把`api.1sapp.com`加到`[MITM]`
42+
2. 再配置重写规则:
43+
- Surge: 把两条远程脚本放到`[Script]`
44+
- QuanX: 把`qtt.cookie.js`和`qtt.js`传到`On My iPhone - Quantumult X - Scripts` (传到 iCloud 相同目录也可, 注意要打开 quanx 的 iCloud 开关)
45+
3. 打开 APP 手动签到一次: `市集` > `豆瓣时间` > `签到`
46+
4. 系统提示: `获取Cookie: 成功`
47+
5. 把获取 Cookie 的脚本注释掉
48+
6. 运行一次脚本, 如果提示重复签到, 那就算成功了!
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+
[@GideonSenku](https://github.com/GideonSenku)

‎qtt/dbsj.cookie.js‎

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
const cookieName = '趣头条'
2+
const signurlKey = 'senku_signurl_qtt'
3+
const signheaderKey = 'senku_signheader_qtt'
4+
const signbodyKey = 'senku_signbody_qtt'
5+
const senku = init()
6+
7+
const requrl = $request.url
8+
if ($request && $request.method != 'OPTIONS') {
9+
try {
10+
const signurlVal = requrl
11+
const signheaderVal = JSON.stringify($request.headers)
12+
13+
if (signurlVal) senku.setdata(signurlVal, signurlKey)
14+
if (signheaderVal) senku.setdata(signheaderVal, signheaderKey)
15+
senku.msg(cookieName, `获取Cookie: 成功`, ``)
16+
} catch (error) {
17+
senku.log(`❌error:${error}`)
18+
}
19+
}
20+
21+
function init() {
22+
isSurge = () => {
23+
return undefined === this.$httpClient ? false : true
24+
}
25+
isQuanX = () => {
26+
return undefined === this.$task ? false : true
27+
}
28+
getdata = (key) => {
29+
if (isSurge()) return $persistentStore.read(key)
30+
if (isQuanX()) return $prefs.valueForKey(key)
31+
}
32+
setdata = (key, val) => {
33+
if (isSurge()) return $persistentStore.write(key, val)
34+
if (isQuanX()) return $prefs.setValueForKey(key, val)
35+
}
36+
msg = (title, subtitle, body) => {
37+
if (isSurge()) $notification.post(title, subtitle, body)
38+
if (isQuanX()) $notify(title, subtitle, body)
39+
}
40+
log = (message) => console.log(message)
41+
get = (url, cb) => {
42+
if (isSurge()) {
43+
$httpClient.get(url, cb)
44+
}
45+
if (isQuanX()) {
46+
url.method = 'GET'
47+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
48+
}
49+
}
50+
post = (url, cb) => {
51+
if (isSurge()) {
52+
$httpClient.post(url, cb)
53+
}
54+
if (isQuanX()) {
55+
url.method = 'POST'
56+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
57+
}
58+
}
59+
done = (value = {}) => {
60+
$done(value)
61+
}
62+
return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done }
63+
}
64+
senku.done()

‎qtt/dbsj.js‎

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
const cookieName = '趣头条'
2+
const signurlKey = 'senku_signurl_qtt'
3+
const signheaderKey = 'senku_signheader_qtt'
4+
const signbodyKey = 'senku_signbody_qtt'
5+
const senku = init()
6+
const signurlVal = senku.getdata(signurlKey)
7+
const signheaderVal = senku.getdata(signheaderKey)
8+
9+
sign()
10+
11+
function sign() {
12+
13+
const url = { url: signurlVal, headers: JSON.parse(signheaderVal) }
14+
senku.get(url, (error, response, data) => {
15+
const result = JSON.parse(data)
16+
let subTitle = ``
17+
let detail = ``
18+
const code = result.code
19+
const message = result.message
20+
if (code == 0) {
21+
const amount = result.data.amount
22+
const continuouSignIn = result.data.continuouSignIn
23+
subTitle = `签到结果: 成功`
24+
detail = `获得${amount}💰连续签到天数:${continuouSignIn}天`
25+
} else if (code == -132) {
26+
subTitle = `${message}`
27+
}
28+
else {
29+
subTitle = `签到结果: 失败`
30+
}
31+
senku.msg(cookieName, subTitle, detail)
32+
senku.done()
33+
})
34+
}
35+
36+
37+
function init() {
38+
isSurge = () => {
39+
return undefined === this.$httpClient ? false : true
40+
}
41+
isQuanX = () => {
42+
return undefined === this.$task ? false : true
43+
}
44+
getdata = (key) => {
45+
if (isSurge()) return $persistentStore.read(key)
46+
if (isQuanX()) return $prefs.valueForKey(key)
47+
}
48+
setdata = (key, val) => {
49+
if (isSurge()) return $persistentStore.write(key, val)
50+
if (isQuanX()) return $prefs.setValueForKey(key, val)
51+
}
52+
msg = (title, subtitle, body) => {
53+
if (isSurge()) $notification.post(title, subtitle, body)
54+
if (isQuanX()) $notify(title, subtitle, body)
55+
}
56+
log = (message) => console.log(message)
57+
get = (url, cb) => {
58+
if (isSurge()) {
59+
$httpClient.get(url, cb)
60+
}
61+
if (isQuanX()) {
62+
url.method = 'GET'
63+
$task.fetch(url).then((resp) => cb(null, resp, resp.body))
64+
}
65+
}
66+
post = (url, cb) => {
67+
if (isSurge()) {
68+
$httpClient.post(url, cb)
69+
}
70+
if (isQuanX()) {
71+
url.method = 'POST'
72+
$task.fetch(url).then((resp) => cb(null, resp, resp.body))
73+
}
74+
}
75+
done = (value = {}) => {
76+
$done(value)
77+
}
78+
return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done }
79+
}

0 commit comments

Comments
 (0)