Skip to content

Commit 3e3abff

Browse files
committed
更新[腾讯视频]签到脚本: 增加新的Cookie获取方式&Cookie心跳器
1 parent b529d32 commit 3e3abff

2 files changed

Lines changed: 73 additions & 3 deletions

File tree

‎videoqq/README.md‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
**2020.1.7 从 APP 获取 Cookie,目测有效期能撑一段时间 (需要观察)**
66

77
**2020.1.8 如果从 APP 获取 Cookie 还发现失败,请尝试新的正则 (详见下面 Surge & QuanX 配置内容)**
8+
**2020.1.8 增加 Cookie 心跳器, 尝试每 1 小时或 2 小时运行一次来保持 Cookie 活性 (详见下面 Surge & QuanX 配置内容)**
89

910
> 代码已同时兼容 Surge & QuanX, 使用同一份签到脚本即可
1011
@@ -14,21 +15,23 @@
1415

1516
```properties
1617
[MITM]
17-
vip.video.qq.com
18+
*.video.qq.com
1819

1920
[Script]
2021
# App Cookie
2122
http-request ^https:\/\/vip\.video\.qq\.com\/?.? script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/videoqq/videoqq.cookie.js
2223
# 页面 Cookie (如果App Cookie还是容易失效, 尝试这个正则, 手机页面访问v.qq.com随便看一个vip视频触发)
2324
http-request ^https:\/\/access\.video\.qq.com\/user\/auth_refresh script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/videoqq/videoqq.cookie.js
2425
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/videoqq/videoqq.js
26+
# 新的尝试: 尝试每1小时或2小时运行下面脚本来保持Cookie的活性 (效果未知)
27+
cron "* */1 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/videoqq/videoqq.cookie.keeper.js
2528
```
2629

2730
## 配置 (QuanX)
2831

2932
```properties
3033
[MITM]
31-
vip.video.qq.com
34+
*.video.qq.com
3235

3336
[rewrite_local]
3437
# App Cookie
@@ -38,11 +41,13 @@ vip.video.qq.com
3841

3942
[task_local]
4043
1 0 * * * videoqq.js
44+
# 新的尝试: 尝试每1小时或2小时运行下面脚本来保持Cookie的活性 (效果未知)
45+
* */1 * * * videoqq.cookie.keeper.js
4146
```
4247

4348
## 说明
4449

45-
1. 先把`vip.video.qq.com`加到`[MITM]`
50+
1. 先把`*.video.qq.com`加到`[MITM]`
4651
2. 再配置重写规则:
4752
- Surge: 把两条远程脚本放到`[Script]`
4853
- QuanX: 把`videoqq.cookie.js`和`videoqq.js`传到`On My iPhone - Quantumult X - Scripts` (传到 iCloud 相同目录也可, 注意要打开 quanx 的 iCloud 开关)

‎videoqq/videoqq.cookie.keeper.js‎

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/**
2+
* Cookie 心跳
3+
* 尝试每2小时运行一次本脚本来保持Cookie的活性 (效果待验证)
4+
*/
5+
6+
const cookieName = '腾讯视频'
7+
const cookieKey = 'chavy_cookie_videoqq'
8+
const chavy = init()
9+
const cookieVal = chavy.getdata(cookieKey)
10+
11+
keep()
12+
13+
function keep() {
14+
const timestamp = Date.parse(new Date())
15+
let url = { url: `https://vip.video.qq.com/fcgi-bin/comm_cgi?name=spp_PropertyNum&cmd=1&growth_value=1&otype=json&_=${timestamp}`, headers: { Cookie: cookieVal } }
16+
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'
17+
chavy.get(url, (error, response, data) => {
18+
chavy.log(`[${cookieName} 心跳], data: ${data}`)
19+
})
20+
chavy.done()
21+
}
22+
23+
function init() {
24+
isSurge = () => {
25+
return undefined === this.$httpClient ? false : true
26+
}
27+
isQuanX = () => {
28+
return undefined === this.$task ? false : true
29+
}
30+
getdata = (key) => {
31+
if (isSurge()) return $persistentStore.read(key)
32+
if (isQuanX()) return $prefs.valueForKey(key)
33+
}
34+
setdata = (key, val) => {
35+
if (isSurge()) return $persistentStore.write(key, val)
36+
if (isQuanX()) return $prefs.setValueForKey(key, val)
37+
}
38+
msg = (title, subtitle, body) => {
39+
if (isSurge()) $notification.post(title, subtitle, body)
40+
if (isQuanX()) $notify(title, subtitle, body)
41+
}
42+
log = (message) => console.log(message)
43+
get = (url, cb) => {
44+
if (isSurge()) {
45+
$httpClient.get(url, cb)
46+
}
47+
if (isQuanX()) {
48+
url.method = 'GET'
49+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
50+
}
51+
}
52+
post = (url, cb) => {
53+
if (isSurge()) {
54+
$httpClient.post(url, cb)
55+
}
56+
if (isQuanX()) {
57+
url.method = 'POST'
58+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
59+
}
60+
}
61+
done = (value = {}) => {
62+
$done(value)
63+
}
64+
return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done }
65+
}

0 commit comments

Comments
 (0)