Skip to content

Commit c69435c

Browse files
committed
添加[人人视频]签到脚本
1 parent 4a2377d commit c69435c

3 files changed

Lines changed: 256 additions & 0 deletions

File tree

‎rrtv/README.md‎

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

‎rrtv/rrtv.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_rrtv'
3+
const chavy = init()
4+
const cookieVal = $request.headers['token']
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()

‎rrtv/rrtv.js‎

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
const cookieName = '人人视频'
2+
const cookieKey = 'chavy_cookie_rrtv'
3+
const chavy = init()
4+
let cookieVal = chavy.getdata(cookieKey)
5+
6+
sign()
7+
8+
function sign() {
9+
let url = { url: `https://api.rr.tv/rrtv-activity/sign/sign`, headers: { token: cookieVal } }
10+
url.headers['clientType'] = `ios_rrsp_jzsp`
11+
url.headers['Accept-Encoding'] = `gzip, deflate, br`
12+
url.headers['Connection'] = `keep-alive`
13+
url.headers['clientVersion'] = `4.3.5`
14+
url.headers['Content-Type'] = `application/x-www-form-urlencoded; charset=UTF-8`
15+
url.headers['Origin'] = `https://mobile.rr.tv`
16+
url.headers['Referer'] = `https://mobile.rr.tv/`
17+
url.headers['Accept'] = `application/json, text/plain, */*`
18+
url.headers['Host'] = `api.rr.tv`
19+
url.headers['Accept-Language'] = `zh-cn`
20+
url.headers['Content-Length'] = `12`
21+
url.headers['User-Agent'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 App/RRSPApp platform/iPhone AppVersion/4.3.5'
22+
23+
chavy.post(url, (error, response, data) => {
24+
chavy.log(`${cookieName}, data: ${data}`)
25+
getinfo(JSON.parse(data))
26+
})
27+
chavy.done()
28+
}
29+
30+
function getinfo(signresult) {
31+
let url = { url: `https://api.rr.tv/user/profile`, headers: { token: cookieVal } }
32+
url.headers['clientType'] = `ios_rrsp_jzsp`
33+
url.headers['Accept-Encoding'] = `gzip, deflate, br`
34+
url.headers['Connection'] = `keep-alive`
35+
url.headers['clientVersion'] = `4.3.5`
36+
url.headers['Content-Type'] = `application/x-www-form-urlencoded; charset=UTF-8`
37+
url.headers['Origin'] = `https://mobile.rr.tv`
38+
url.headers['Referer'] = `https://mobile.rr.tv/`
39+
url.headers['Accept'] = `application/json, text/plain, */*`
40+
url.headers['Host'] = `api.rr.tv`
41+
url.headers['Accept-Language'] = `zh-cn`
42+
url.headers['Content-Length'] = `0`
43+
url.headers['User-Agent'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 App/RRSPApp platform/iPhone AppVersion/4.3.5'
44+
45+
chavy.post(url, (error, response, data) => {
46+
chavy.log(`${cookieName}, data: ${data}`)
47+
const result = JSON.parse(data)
48+
const title = `${cookieName}`
49+
let subTitle = ``
50+
let detail = ``
51+
if (signresult.code == '0000') {
52+
subTitle = `签到结果: 成功`
53+
detail = `等级: ${result.data.user.level} (${result.data.user.levelStr}), 说明: ${signresult.msg}`
54+
} else if (signresult.code == '8750') {
55+
subTitle = `签到结果: 成功 (重复签到)`
56+
detail = `等级: ${result.data.user.level} (${result.data.user.levelStr}), 说明: ${signresult.msg}`
57+
} else if (signresult.code == '8400') {
58+
subTitle = `签到失败: 失败`
59+
detail = `说明: ${signresult.msg}`
60+
} else {
61+
subTitle = `签到失败: 未知`
62+
detail = `编码: ${signresult.code}, 说明: ${signresult.msg}`
63+
}
64+
65+
chavy.msg(title, subTitle, detail)
66+
})
67+
}
68+
69+
function init() {
70+
isSurge = () => {
71+
return undefined === this.$httpClient ? false : true
72+
}
73+
isQuanX = () => {
74+
return undefined === this.$task ? false : true
75+
}
76+
getdata = (key) => {
77+
if (isSurge()) return $persistentStore.read(key)
78+
if (isQuanX()) return $prefs.valueForKey(key)
79+
}
80+
setdata = (key, val) => {
81+
if (isSurge()) return $persistentStore.write(key, val)
82+
if (isQuanX()) return $prefs.setValueForKey(key, val)
83+
}
84+
msg = (title, subtitle, body) => {
85+
if (isSurge()) $notification.post(title, subtitle, body)
86+
if (isQuanX()) $notify(title, subtitle, body)
87+
}
88+
log = (message) => console.log(message)
89+
get = (url, cb) => {
90+
if (isSurge()) {
91+
$httpClient.get(url, cb)
92+
}
93+
if (isQuanX()) {
94+
url.method = 'GET'
95+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
96+
}
97+
}
98+
post = (url, cb) => {
99+
if (isSurge()) {
100+
$httpClient.post(url, cb)
101+
}
102+
if (isQuanX()) {
103+
url.method = 'POST'
104+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
105+
}
106+
}
107+
done = (value = {}) => {
108+
$done(value)
109+
}
110+
return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done }
111+
}

0 commit comments

Comments
 (0)