Skip to content

Commit 162970b

Browse files
committed
添加[腾讯视频]签到脚本 (beta)
1 parent c6de5b8 commit 162970b

3 files changed

Lines changed: 230 additions & 0 deletions

File tree

videoqq/README.md

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

videoqq/videoqq.cookie.js

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

videoqq/videoqq.js

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
const cookieName = '腾讯视频'
2+
const cookieKey = 'chavy_cookie_videoqq'
3+
const chavy = init()
4+
const cookieVal = chavy.getdata(cookieKey)
5+
6+
sign()
7+
8+
function sign() {
9+
const timestamp = Date.parse(new Date())
10+
let url = { url: `https://vip.video.qq.com/fcgi-bin/comm_cgi?name=hierarchical_task_system&cmd=2&_=${timestamp}`, headers: { Cookie: cookieVal } }
11+
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'
12+
13+
chavy.get(url, (error, response, data) => {
14+
chavy.log(`${cookieName}, data: ${data}`)
15+
let result = JSON.parse(data.match(/QZOutputJson=\(([^\)]*)\)/)[1])
16+
const title = `${cookieName}`
17+
let subTitle = ''
18+
let detail = ''
19+
if (result.ret == 0) {
20+
subTitle = '签到结果: 成功'
21+
chavy.msg(title, subTitle, detail)
22+
} else if (result.ret == -10006) {
23+
subTitle = '签到结果: 失败'
24+
detail = `原因: 未登录, 说明: ${result.msg}`
25+
chavy.msg(title, subTitle, detail)
26+
} else if (result.ret == -10019) {
27+
subTitle = '签到结果: 失败'
28+
detail = `原因: 非VIP会员, 说明: ${result.msg}`
29+
chavy.msg(title, subTitle, detail)
30+
} else {
31+
subTitle = '签到结果: 未知'
32+
detail = `编码: ${result.ret}, 说明: ${result.msg}`
33+
chavy.msg(title, subTitle, detail)
34+
}
35+
})
36+
37+
chavy.done()
38+
}
39+
40+
function init() {
41+
isSurge = () => {
42+
return undefined === this.$httpClient ? false : true
43+
}
44+
isQuanX = () => {
45+
return undefined === this.$task ? false : true
46+
}
47+
getdata = (key) => {
48+
if (isSurge()) return $persistentStore.read(key)
49+
if (isQuanX()) return $prefs.valueForKey(key)
50+
}
51+
setdata = (key, val) => {
52+
if (isSurge()) return $persistentStore.write(key, val)
53+
if (isQuanX()) return $prefs.setValueForKey(key, val)
54+
}
55+
msg = (title, subtitle, body) => {
56+
if (isSurge()) $notification.post(title, subtitle, body)
57+
if (isQuanX()) $notify(title, subtitle, body)
58+
}
59+
log = (message) => console.log(message)
60+
get = (url, cb) => {
61+
if (isSurge()) {
62+
$httpClient.get(url, cb)
63+
}
64+
if (isQuanX()) {
65+
url.method = 'GET'
66+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
67+
}
68+
}
69+
post = (url, cb) => {
70+
if (isSurge()) {
71+
$httpClient.post(url, cb)
72+
}
73+
if (isQuanX()) {
74+
url.method = 'POST'
75+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
76+
}
77+
}
78+
done = (value = {}) => {
79+
$done(value)
80+
}
81+
return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done }
82+
}

0 commit comments

Comments
 (0)