Skip to content

Commit b5afd94

Browse files
committed
更新[腾讯视频]脚本: 增加移动端网页版移动
1 parent 45e3a17 commit b5afd94

3 files changed

Lines changed: 84 additions & 7 deletions

File tree

videoqq/README.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,35 @@
44
55
> 2020.2.7 从网页端获取的 Cookie 很稳定!
66
7+
> 2020.2.17 增加移动端网页版签到 (请仔细阅读移动端网页版的操作说明) (MITM 新增一条、获取 Cookie 脚本新增一条、两脚本需要更新)
8+
79
## 配置 (Surge)
810

911
```properties
1012
[MITM]
11-
*.video.qq.com
13+
*.video.qq.com, v.qq.com
1214

1315
[Script]
1416
http-request ^https:\/\/access.video.qq.com\/user\/auth_refresh script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/videoqq/videoqq.cookie.js
17+
http-request ^https?:\/\/v.qq.com\/x\/bu\/mobile_checkin script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/videoqq/videoqq.cookie.js
1518
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/videoqq/videoqq.js
1619
```
1720

1821
## 配置 (QuanX)
1922

2023
```properties
2124
[MITM]
22-
*.video.qq.com
25+
*.video.qq.com, v.qq.com
2326

2427
[rewrite_local]
25-
# 189及以前版本
26-
^https:\/\/access.video.qq.com\/user\/auth_refresh url script-response-body videoqq.cookie.js
27-
# 190及以后版本
2828
^https:\/\/access.video.qq.com\/user\/auth_refresh url script-request-header videoqq.cookie.js
29+
^https?:\/\/v.qq.com\/x\/bu\/mobile_checkin url script-request-header videoqq.cookie.js
2930

3031
[task_local]
3132
1 0 * * * videoqq.js
3233
```
3334

34-
## 说明
35+
## 说明 (PC 端)
3536

3637
1. 先把`*.video.qq.com`加到`[MITM]`
3738
2. 再配置重写规则:
@@ -47,6 +48,14 @@ cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scr
4748
4849
> 第 2 条脚本是签到脚本, 每天`00:00:10`执行一次.
4950
51+
## 说明 (移动端网页版)
52+
53+
1. 先把`v.qq.com`加到`[MITM]`
54+
2. 手机浏览器访问下: https://film.qq.com/ 随便选 1 部电影观看
55+
3. 手机浏览器访问下: http://v.qq.com/x/bu/mobile_checkin 页面提示提示`签到成功`, 系统提示: `获取Cookie: 成功` (为保成功率,请刷新一下页面再获取一次)
56+
4. 运行下签到脚本看是否提示
57+
5. 最后就可以把第 1 条脚本注释掉了
58+
5059
## 常见问题
5160

5261
1. 无法写入 Cookie

videoqq/videoqq.cookie.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ const cookieName = '腾讯视频'
22
const cookieKey = 'chavy_cookie_videoqq'
33
const authUrlKey = 'chavy_auth_url_videoqq'
44
const authHeaderKey = 'chavy_auth_header_videoqq'
5+
const msignurlKey = 'chavy_msign_url_videoqq'
6+
const msignheaderKey = 'chavy_msign_header_videoqq'
57
const chavy = init()
68

79
const cookieVal = $request.headers['Cookie']
@@ -16,6 +18,14 @@ if (cookieVal) {
1618
chavy.log(`[${cookieName}] 获取Cookie: 成功, Cookie: ${cookieVal}`)
1719
chavy.log(`[${cookieName}] 获取Cookie: 成功, AuthUrl: ${authurl}`)
1820
chavy.log(`[${cookieName}] 获取Cookie: 成功, AuthHeader: ${authHeader}`)
21+
} else if ($request.url.indexOf('mobile_checkin') > 0) {
22+
const msignurl = $request.url
23+
const msignheader = JSON.stringify($request.headers)
24+
if (msignurl) chavy.setdata(msignurl, msignurlKey)
25+
if (msignheader) chavy.setdata(msignheader, msignheaderKey)
26+
chavy.msg(`${cookieName}`, '获取Cookie: 成功', '')
27+
chavy.log(`[${cookieName}] 获取Cookie: 成功, msignurl: ${msignurl}`)
28+
chavy.log(`[${cookieName}] 获取Cookie: 成功, msignheader: ${msignheader}`)
1929
} else {
2030
chavy.setdata(cookieVal, cookieKey)
2131
chavy.setdata(``, authUrlKey)

videoqq/videoqq.js

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,15 @@ const cookieName = '腾讯视频'
22
const cookieKey = 'chavy_cookie_videoqq'
33
const authUrlKey = 'chavy_auth_url_videoqq'
44
const authHeaderKey = 'chavy_auth_header_videoqq'
5+
const msignurlKey = 'chavy_msign_url_videoqq'
6+
const msignheaderKey = 'chavy_msign_header_videoqq'
57
const chavy = init()
68
let cookieVal = chavy.getdata(cookieKey)
79
const authUrlVal = chavy.getdata(authUrlKey)
810
const authHeaderVal = chavy.getdata(authHeaderKey)
11+
const msignurlVal = chavy.getdata(msignurlKey)
12+
const msignheaderVal = chavy.getdata(msignheaderKey)
13+
const signinfo = {}
914

1015
sign()
1116

@@ -24,6 +29,7 @@ function sign() {
2429
respcookie = respcookie.replace(/Domain=(.*?); ?/g, '')
2530
respcookie = respcookie.replace(/;$/g, '')
2631
if (result.errcode == 0) {
32+
let setcookies = []
2733
for (setcookie of respcookie.split(';')) {
2834
const setcookieKey = setcookie.split('=')[0]
2935
const setcookieVal = setcookie.split('=')[1]
@@ -32,17 +38,22 @@ function sign() {
3238
} else {
3339
cookieVal += `; ${setcookieKey}=${setcookieVal}`
3440
}
41+
setcookies.push({ key: setcookieKey, val: setcookieVal })
3542
// chavy.log(`${cookieName}, auth_refresh - set-cookie: ${setcookieKey} = ${setcookieVal}`)
3643
}
3744
for (resultcookie in result) {
3845
if (cookieVal.indexOf(resultcookie) >= 0) {
3946
cookieVal = cookieVal.replace(new RegExp(`${resultcookie}=[^;]*`, 'g'), `${resultcookie}=${result[resultcookie]}`)
47+
setcookies.push({ key: resultcookie, val: result[resultcookie] })
4048
// chavy.log(`${cookieName}, auth_refresh - ret-cookie: ${resultcookie} = ${result[resultcookie]}`)
4149
}
4250
}
4351
// chavy.log(`${cookieName}, auth_refresh - new-cookie: ${cookieVal}`)
52+
// chavy.log(`${cookieName}, auth_refresh - setcookies: ${JSON.stringify(setcookies)}`)
4453
chavy.setdata(cookieVal, cookieKey)
4554
signapp()
55+
signmobile(setcookies)
56+
chavy.done()
4657
}
4758
})
4859
} else {
@@ -78,7 +89,54 @@ function signapp() {
7889
chavy.msg(title, subTitle, detail)
7990
}
8091
})
81-
chavy.done()
92+
// chavy.done()
93+
}
94+
95+
function signmobile(cookies) {
96+
if (msignheaderVal) {
97+
let msignheaderObj = JSON.parse(msignheaderVal)
98+
let msignCookies = msignheaderObj.Cookie
99+
// chavy.log(`${cookieName} updatemobile old-cookie: ${msignCookies}`)
100+
for (c of cookies) {
101+
if (msignCookies.indexOf(c.key) >= 0) {
102+
msignCookies = msignCookies.replace(new RegExp(`${c.key}=[^;]*`, 'g'), `${c.key}=${c.val}`)
103+
}
104+
}
105+
// chavy.log(`${cookieName} updatemobile new-cookie: ${msignCookies}`)
106+
msignheaderObj.Cookie = msignCookies
107+
108+
const url = { url: msignurlVal, headers: msignheaderObj }
109+
chavy.get(url, (error, response, data) => {
110+
const dmatch = data.match(/window\.__STATE__=(.*?)<\/script>/)
111+
let result = {}
112+
result.msg = '未知'
113+
result.ret = -9999
114+
if (dmatch) {
115+
try {
116+
result = JSON.parse(dmatch[1]).payloads.execCheck
117+
} catch (e) {
118+
chavy.log(`${cookieName} catch - error: ${e}`)
119+
}
120+
}
121+
const title = `${cookieName} (移动端)`
122+
let subtitle = ``
123+
let detail = ``
124+
if (result.ret == -9999) {
125+
// chavy.log(`${cookieName} updatemobile data: ${data}`)
126+
subtitle = `签到结果: 失败`
127+
detail = `说明: 未知`
128+
} else {
129+
if (result.ret == 0) {
130+
subtitle = `签到结果: 成功`
131+
if (result.data && result.data.show_text_1) detail = `说明: ${result.data.show_text_1}`
132+
else detail = `说明: ${result.msg}`
133+
} else if (result.ret == -2021) {
134+
subtitle = `签到结果: 成功(重复签到)`
135+
}
136+
}
137+
chavy.msg(title, subtitle, detail)
138+
})
139+
}
82140
}
83141

84142
function getexp(signresult) {

0 commit comments

Comments
 (0)