Skip to content

Commit 6098892

Browse files
committed
更新[人人视频]签到: 增加每日答题
1 parent 07aafb8 commit 6098892

2 files changed

Lines changed: 206 additions & 115 deletions

File tree

‎rrtv/README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
77
> 2020.1.31 增加自动领取每日福利 (无需重新获取 Cookie, 直接更新脚本即可!)
88
9+
> 2020.3.4 增加每日答题 (无需重新获取 Cookie, 直接更新脚本即可!) (答题是判断哪个选项回答的人数最多来选择的,所以建议把签到时间放在 00:10 以后!)
10+
911
## 配置 (Surge)
1012

1113
```properties

‎rrtv/rrtv.js‎

Lines changed: 204 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -1,137 +1,226 @@
1-
const cookieName = '人人视频'
2-
const cookieKey = 'chavy_cookie_rrtv'
31
const chavy = init()
4-
let cookieVal = chavy.getdata(cookieKey)
2+
const cookieName = '人人视频'
3+
const KEY_signcookie = 'chavy_cookie_rrtv'
4+
55
const signinfo = {}
6+
let VAL_signcookie = chavy.getdata(KEY_signcookie)
67

7-
sign()
8+
;(exec = async () => {
9+
chavy.log(`🔔 ${cookieName} 开始签到`)
10+
await signdaily()
11+
await signwelfare()
12+
await getquestion()
13+
if (!signinfo.hasAnswered) {
14+
await answerquestion()
15+
await getquestion()
16+
}
17+
await getinfo()
18+
await showmsg()
19+
})().catch((e) => chavy.log(`❌ ${cookieName} 签到失败: ${e}`))
820

9-
function sign() {
10-
signdaily()
11-
signwelfare()
12-
check()
21+
function signdaily() {
22+
return new Promise((resolve, reject) => {
23+
let url = { url: `https://api.rr.tv/rrtv-activity/sign/sign`, headers: { token: VAL_signcookie } }
24+
url.headers['clientType'] = `ios_rrsp_jzsp`
25+
url.headers['Accept-Encoding'] = `gzip, deflate, br`
26+
url.headers['Connection'] = `keep-alive`
27+
url.headers['clientVersion'] = `4.3.5`
28+
url.headers['Content-Type'] = `application/x-www-form-urlencoded; charset=UTF-8`
29+
url.headers['Origin'] = `https://mobile.rr.tv`
30+
url.headers['Referer'] = `https://mobile.rr.tv/`
31+
url.headers['Accept'] = `application/json, text/plain, */*`
32+
url.headers['Host'] = `api.rr.tv`
33+
url.headers['Accept-Language'] = `zh-cn`
34+
url.headers['Content-Length'] = `12`
35+
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'
36+
chavy.post(url, (error, response, data) => {
37+
try {
38+
signinfo.signdaily = JSON.parse(data)
39+
resolve()
40+
} catch (e) {
41+
chavy.msg(cookieName, `日常签到: 失败`, `说明: ${e}`)
42+
chavy.log(`❌ ${cookieName} signdaily - 日常签到失败: ${e}`)
43+
chavy.log(`❌ ${cookieName} signdaily - response: ${JSON.stringify(response)}`)
44+
resolve()
45+
}
46+
})
47+
})
1348
}
1449

15-
function signdaily() {
16-
let url = { url: `https://api.rr.tv/rrtv-activity/sign/sign`, headers: { token: cookieVal } }
17-
url.headers['clientType'] = `ios_rrsp_jzsp`
18-
url.headers['Accept-Encoding'] = `gzip, deflate, br`
19-
url.headers['Connection'] = `keep-alive`
20-
url.headers['clientVersion'] = `4.3.5`
21-
url.headers['Content-Type'] = `application/x-www-form-urlencoded; charset=UTF-8`
22-
url.headers['Origin'] = `https://mobile.rr.tv`
23-
url.headers['Referer'] = `https://mobile.rr.tv/`
24-
url.headers['Accept'] = `application/json, text/plain, */*`
25-
url.headers['Host'] = `api.rr.tv`
26-
url.headers['Accept-Language'] = `zh-cn`
27-
url.headers['Content-Length'] = `12`
28-
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'
50+
function signwelfare() {
51+
return new Promise((resolve, reject) => {
52+
let url = { url: `https://api.rr.tv/dailyWelfare/getWelfare`, headers: { token: VAL_signcookie } }
53+
url.headers['clientType'] = `web`
54+
url.headers['Accept-Encoding'] = `gzip, deflate, br`
55+
url.headers['Connection'] = `keep-alive`
56+
url.headers['clientVersion'] = `0.0.1`
57+
url.headers['Content-Type'] = `application/x-www-form-urlencoded; charset=UTF-8`
58+
url.headers['Origin'] = `https://mobile.rr.tv`
59+
url.headers['Referer'] = `https://mobile.rr.tv/mission/`
60+
url.headers['Accept'] = `application/json, text/plain, */*`
61+
url.headers['Host'] = `api.rr.tv`
62+
url.headers['Accept-Language'] = `zh-cn`
63+
url.headers['Content-Length'] = `45`
64+
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'
65+
chavy.post(url, (error, response, data) => {
66+
try {
67+
signinfo.signwelfare = JSON.parse(data)
68+
resolve()
69+
} catch (e) {
70+
chavy.msg(cookieName, `日常签到: 失败`, `说明: ${e}`)
71+
chavy.log(`❌ ${cookieName} signwelfare - 日常签到失败: ${e}`)
72+
chavy.log(`❌ ${cookieName} signwelfare - response: ${JSON.stringify(response)}`)
73+
resolve()
74+
}
75+
})
76+
})
77+
}
2978

30-
chavy.post(url, (error, response, data) => {
31-
chavy.log(`${cookieName}, signdaily.data: ${data}`)
32-
signinfo.signdaily = JSON.parse(data)
79+
function getinfo() {
80+
return new Promise((resolve, reject) => {
81+
let url = { url: `https://api.rr.tv/user/profile`, headers: { token: VAL_signcookie } }
82+
url.headers['clientType'] = `ios_rrsp_jzsp`
83+
url.headers['Accept-Encoding'] = `gzip, deflate, br`
84+
url.headers['Connection'] = `keep-alive`
85+
url.headers['clientVersion'] = `4.3.5`
86+
url.headers['Content-Type'] = `application/x-www-form-urlencoded; charset=UTF-8`
87+
url.headers['Origin'] = `https://mobile.rr.tv`
88+
url.headers['Referer'] = `https://mobile.rr.tv/`
89+
url.headers['Accept'] = `application/json, text/plain, */*`
90+
url.headers['Host'] = `api.rr.tv`
91+
url.headers['Accept-Language'] = `zh-cn`
92+
url.headers['Content-Length'] = `0`
93+
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'
94+
chavy.post(url, (error, response, data) => {
95+
try {
96+
signinfo.userinfo = JSON.parse(data)
97+
resolve()
98+
} catch (e) {
99+
chavy.msg(cookieName, `获取会员信息: 失败`, `说明: ${e}`)
100+
chavy.log(`❌ ${cookieName} getinfo - 获取会员信息失败: ${e}`)
101+
chavy.log(`❌ ${cookieName} getinfo - response: ${JSON.stringify(response)}`)
102+
resolve()
103+
}
104+
})
33105
})
34106
}
35107

36-
function signwelfare() {
37-
let url = { url: `https://api.rr.tv/dailyWelfare/getWelfare`, headers: { token: cookieVal } }
38-
url.headers['clientType'] = `web`
39-
url.headers['Accept-Encoding'] = `gzip, deflate, br`
40-
url.headers['Connection'] = `keep-alive`
41-
url.headers['clientVersion'] = `0.0.1`
42-
url.headers['Content-Type'] = `application/x-www-form-urlencoded; charset=UTF-8`
43-
url.headers['Origin'] = `https://mobile.rr.tv`
44-
url.headers['Referer'] = `https://mobile.rr.tv/mission/`
45-
url.headers['Accept'] = `application/json, text/plain, */*`
46-
url.headers['Host'] = `api.rr.tv`
47-
url.headers['Accept-Language'] = `zh-cn`
48-
url.headers['Content-Length'] = `45`
49-
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'
108+
function getquestion() {
109+
return new Promise((resolve, reject) => {
110+
let url = { url: `https://api.rr.tv/v3plus/question/getQuestion`, headers: { token: VAL_signcookie } }
111+
url.headers['clientType'] = `ios_rrsp_jzsp`
112+
url.headers['Accept-Encoding'] = `gzip, deflate, br`
113+
url.headers['Connection'] = `keep-alive`
114+
url.headers['clientVersion'] = `4.3.5`
115+
url.headers['Content-Type'] = `application/x-www-form-urlencoded; charset=UTF-8`
116+
url.headers['Origin'] = `https://mobile.rr.tv`
117+
url.headers['Referer'] = `https://mobile.rr.tv/`
118+
url.headers['Accept'] = `application/json, text/plain, */*`
119+
url.headers['Host'] = `api.rr.tv`
120+
url.headers['Accept-Language'] = `zh-cn`
121+
url.headers['Content-Length'] = `0`
122+
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'
123+
chavy.post(url, (error, response, data) => {
124+
try {
125+
signinfo.question = JSON.parse(data)
126+
signinfo.questionopts = {}
127+
for (opt of signinfo.question.data.question.optionViewList) {
128+
signinfo.questionopts[opt.id] = opt
129+
if (!signinfo.answeropt) signinfo.answeropt = opt
130+
else signinfo.answeropt = opt.answererCount > signinfo.answeropt.answererCount ? opt : signinfo.answeropt
131+
}
132+
signinfo.hasAnswered = signinfo.question.data.question.hasAnswered
133+
if (signinfo.hasAnswered) {
134+
signinfo.selectId = signinfo.question.data.question.selectId
135+
signinfo.isRight = signinfo.questionopts[signinfo.selectId].isRight
136+
}
137+
resolve()
138+
} catch (e) {
139+
chavy.msg(cookieName, `获取问题: 失败`, `说明: ${e}`)
140+
chavy.log(`❌ ${cookieName} getquestion - 获取问题失败: ${e}`)
141+
chavy.log(`❌ ${cookieName} getquestion - response: ${JSON.stringify(response)}`)
142+
resolve()
143+
}
144+
})
145+
})
146+
}
50147

51-
chavy.post(url, (error, response, data) => {
52-
chavy.log(`${cookieName}, signwelfare.data: ${data}`)
53-
signinfo.signwelfare = JSON.parse(data)
148+
function answerquestion() {
149+
return new Promise((resolve, reject) => {
150+
let url = { url: `https://api.rr.tv/v3plus/question/answerQuestion`, headers: { token: VAL_signcookie } }
151+
url.body = `optionId=${signinfo.answeropt.id}`
152+
url.headers['clientType'] = `ios_rrsp_jzsp`
153+
url.headers['Accept-Encoding'] = `gzip, deflate, br`
154+
url.headers['Connection'] = `keep-alive`
155+
url.headers['clientVersion'] = `4.3.5`
156+
url.headers['Content-Type'] = `application/x-www-form-urlencoded; charset=UTF-8`
157+
url.headers['Origin'] = `https://mobile.rr.tv`
158+
url.headers['Referer'] = `https://mobile.rr.tv/`
159+
url.headers['Accept'] = `application/json, text/plain, */*`
160+
url.headers['Host'] = `api.rr.tv`
161+
url.headers['Accept-Language'] = `zh-cn`
162+
url.headers['Content-Length'] = `0`
163+
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'
164+
chavy.post(url, (error, response, data) => {
165+
try {
166+
chavy.log(`❕ ${cookieName} answerquestion: ${data}`)
167+
signinfo.answerquestion = JSON.parse(data)
168+
resolve()
169+
} catch (e) {
170+
chavy.msg(cookieName, `获取问题: 失败`, `说明: ${e}`)
171+
chavy.log(`❌ ${cookieName} getquestion - 获取问题失败: ${e}`)
172+
chavy.log(`❌ ${cookieName} getquestion - response: ${JSON.stringify(response)}`)
173+
resolve()
174+
}
175+
})
54176
})
55177
}
56178

57-
function check(checkms = 0) {
58-
if (signinfo.signdaily && signinfo.signwelfare) {
59-
getinfo()
60-
} else {
61-
if (checkms > 5000) {
62-
chavy.msg(`${cookieName}`, `签到失败: 超时退出`, ``)
63-
chavy.done()
179+
function showmsg() {
180+
let subTitle = ''
181+
let detail = ''
182+
if (signinfo.signdaily) {
183+
subTitle = `签到: `
184+
if (signinfo.signdaily.code == '0000' || signinfo.signdaily.code == '8750') {
185+
subTitle += signinfo.signdaily.code == '0000' ? '成功; ' : ''
186+
subTitle += signinfo.signdaily.code == '8750' ? '重复; ' : ''
64187
} else {
65-
setTimeout(() => check(checkms + 100), 100)
188+
subTitle += '失败; '
66189
}
67190
}
68-
}
191+
if (signinfo.signwelfare) {
192+
subTitle += `福利: `
193+
if (signinfo.signwelfare.code == '0000' || signinfo.signwelfare.code == '8623') {
194+
subTitle += signinfo.signwelfare.code == '0000' ? '成功; ' : ''
195+
subTitle += signinfo.signwelfare.code == '8623' ? '重复; ' : ''
196+
} else {
197+
subTitle += '失败;'
198+
}
199+
}
200+
if (signinfo.question && signinfo.questionopts) {
201+
subTitle += `答题: ${signinfo.isRight ? '✅' : '❌'}`
202+
}
69203

70-
function getinfo() {
71-
let url = { url: `https://api.rr.tv/user/profile`, headers: { token: cookieVal } }
72-
url.headers['clientType'] = `ios_rrsp_jzsp`
73-
url.headers['Accept-Encoding'] = `gzip, deflate, br`
74-
url.headers['Connection'] = `keep-alive`
75-
url.headers['clientVersion'] = `4.3.5`
76-
url.headers['Content-Type'] = `application/x-www-form-urlencoded; charset=UTF-8`
77-
url.headers['Origin'] = `https://mobile.rr.tv`
78-
url.headers['Referer'] = `https://mobile.rr.tv/`
79-
url.headers['Accept'] = `application/json, text/plain, */*`
80-
url.headers['Host'] = `api.rr.tv`
81-
url.headers['Accept-Language'] = `zh-cn`
82-
url.headers['Content-Length'] = `0`
83-
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'
204+
if (signinfo.userinfo.code == '0000') {
205+
const levelStr = signinfo.userinfo.data.user.levelStr ? ` (${signinfo.userinfo.data.user.levelStr})` : ``
206+
detail = `等级: ${signinfo.userinfo.data.user.level}${levelStr}, 积分: ${signinfo.userinfo.data.user.score}`
207+
} else {
208+
detail = `编码: ${signinfo.userinfo.code}, 说明: ${signinfo.userinfo.msg}`
209+
}
84210

85-
chavy.post(url, (error, response, data) => {
86-
chavy.log(`${cookieName}, userinfo: ${data}`)
87-
const result = JSON.parse(data)
88-
const title = `${cookieName}`
89-
let subTitle = ``
90-
let detail = ``
91-
if (signinfo.signdaily) {
92-
subTitle = `每日签到: `
93-
if (signinfo.signdaily.code == '0000' || signinfo.signdaily.code == '8750') {
94-
subTitle += signinfo.signdaily.code == '0000' ? '成功; ' : ''
95-
subTitle += signinfo.signdaily.code == '8750' ? '重复; ' : ''
96-
} else {
97-
subTitle += '失败; '
98-
}
99-
}
100-
if (signinfo.signwelfare) {
101-
subTitle += `每日福利: `
102-
if (signinfo.signwelfare.code == '0000' || signinfo.signwelfare.code == '8623') {
103-
subTitle += signinfo.signwelfare.code == '0000' ? '成功; ' : ''
104-
subTitle += signinfo.signwelfare.code == '8623' ? '重复; ' : ''
105-
} else {
106-
subTitle += '失败;'
107-
}
108-
}
109-
if (result.code == '0000') {
110-
const levelStr = result.data.user.levelStr ? ` (${result.data.user.levelStr})` : ``
111-
detail = `等级: ${result.data.user.level}${levelStr}, 积分: ${result.data.user.score}`
211+
if (signinfo.question.data.question) {
212+
detail += `\n查看答题详情`
213+
detail += `\n\n问题: ${signinfo.question.data.question.questionStr}`
214+
for (key in signinfo.questionopts) detail += `\n选项: ${signinfo.questionopts[key].optionStr}, 回答人数: ${signinfo.questionopts[key].answererCount} (${signinfo.questionopts[key].percent})`
215+
if (signinfo.selectId) {
216+
detail += `\n最佳回答: ${signinfo.answeropt.optionStr}`
217+
detail += `\n我的回答: ${signinfo.questionopts[signinfo.selectId].optionStr}`
218+
detail += `${signinfo.isRight ? '✅' : '❌'}`
112219
} else {
113-
detail = `编码: ${result.code}, 说明: ${result.msg}`
220+
detail += `\n最佳回答: ${signinfo.answeropt.optionStr}`
114221
}
115-
chavy.msg(title, subTitle, detail)
116-
// if (signresult.code == '0000') {
117-
// const levelStr = result.data.user.levelStr ? ` (${result.data.user.levelStr})` : ``
118-
// subTitle = `签到结果: 成功`
119-
// detail = `等级: ${result.data.user.level}${levelStr}, 说明: ${signresult.msg}`
120-
// } else if (signresult.code == '8750') {
121-
// const levelStr = result.data.user.levelStr ? ` (${result.data.user.levelStr})` : ``
122-
// subTitle = `签到结果: 成功 (重复签到)`
123-
// detail = `等级: ${result.data.user.level}${levelStr}, 说明: ${signresult.msg}`
124-
// } else if (signresult.code == '8400') {
125-
// subTitle = `签到失败: 失败`
126-
// detail = `说明: ${signresult.msg}`
127-
// } else {
128-
// subTitle = `签到失败: 未知`
129-
// detail = `编码: ${signresult.code}, 说明: ${signresult.msg}`
130-
// }
131-
132-
// chavy.msg(title, subTitle, detail)
133-
})
134-
chavy.done()
222+
}
223+
chavy.msg(cookieName, subTitle, detail)
135224
}
136225

137226
function init() {
@@ -160,7 +249,7 @@ function init() {
160249
}
161250
if (isQuanX()) {
162251
url.method = 'GET'
163-
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
252+
$task.fetch(url).then((resp) => cb(null, resp, resp.body))
164253
}
165254
}
166255
post = (url, cb) => {
@@ -169,7 +258,7 @@ function init() {
169258
}
170259
if (isQuanX()) {
171260
url.method = 'POST'
172-
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
261+
$task.fetch(url).then((resp) => cb(null, resp, resp.body))
173262
}
174263
}
175264
done = (value = {}) => {

0 commit comments

Comments
 (0)