Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 034a7df

Browse files
committed
增加随机观看请求,以获得足够活跃值开金宝箱。增加每周礼包抽奖,若未达到抽奖条件,则尝试使用骰子进行刷新卡片以满足条件直至骰子用完(为了节省骰子,此过程设定为周日进行,测试版)。
1 parent 2ca8d40 commit 034a7df

File tree

2 files changed

+168
-25
lines changed

2 files changed

+168
-25
lines changed

rrtv/README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22

33
> 代码已同时兼容 Surge & QuanX, 使用同一份签到脚本即可
44
5+
> 2020.8.24 增加随机观看请求,以获得足够活跃值开金宝箱。增加每周礼包抽奖,若未达到抽奖条件,则尝试使用骰子进行刷新卡片以满足条件直至骰子用完(为了节省骰子,此过程设定为周日进行,测试版)。
6+
7+
> 2020.8.21 删去多余 header,去除版本信息以绕过验证,并修正开宝箱请求体
8+
59
> 2020.1.11 QuanX 在`190`版本开始, 获取 Cookie 方式需要从`script-response-body`改为`script-request-header`
610
711
> 2020.1.31 增加自动领取每日福利 (无需重新获取 Cookie, 直接更新脚本即可!)
812
913
> 2020.3.4 (1) 增加每日答题 (无需重新获取 Cookie, 直接更新脚本即可!) (答题是判断哪个选项回答的人数最多来选择的,所以建议把签到时间放在 00:10 以后!)
1014
11-
> 2020.3.4 (2) 增加自动开启宝箱 (60 活跃可开`铜箱``银箱`, 100 活跃开`金箱`) (仅靠脚本能自动开`铜箱``银箱`, `金箱`需要观看视频达一定分钟数, 平常有看视频的朋友可以把签到时间压后一点, 如: `50 23 * * *` )
15+
> 2020.3.4 (2) 增加自动开启宝箱 (60 活跃可开`铜箱``银箱`, 100 活跃开`金箱`) ~~(仅靠脚本能自动开`铜箱``银箱`, `金箱`需要观看视频达一定分钟数, 平常有看视频的朋友可以把签到时间压后一点, 如: `50 23 * * *` )~~
1216
1317
## 配置 (Surge)
1418

@@ -34,7 +38,7 @@ cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scr
3438
^https:\/\/api\.rr\.tv\/user\/profile url script-request-header rrtv.cookie.js
3539

3640
[task_local]
37-
1 0 * * * rrtv.js
41+
10 0 * * * rrtv.js
3842
```
3943

4044
## 说明
@@ -79,7 +83,7 @@ cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scr
7983
cron "30 0 0 * * *" script-path=xxx.js # 每天00:00:30执行一次
8084

8185
# 再粗暴点,直接:
82-
cron "* */60 * * * *" script-path=xxx.js # 每60分执行一次
86+
cron "0 0 * * * *" script-path=xxx.js # 每60分整点执行一次
8387
```
8488

8589
- `QuanX`配置:
@@ -90,7 +94,7 @@ cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scr
9094
2 0 * * * xxx.js # 每天00:02执行一次
9195
3 0 * * * xxx.js # 每天00:03执行一次
9296

93-
*/60 * * * * xxx.js # 每60分执行一次
97+
0 * * * * xxx.js # 每60分整点执行一次
9498
```
9599

96100
## 感谢

rrtv/rrtv.js

Lines changed: 160 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,31 @@ const KEY_signcookie = 'chavy_cookie_rrtv'
44

55
const signinfo = {}
66
let VAL_signcookie = chavy.getdata(KEY_signcookie)
7+
const week = "日一二三四五六".charAt(new Date().getDay())
78

89
;(exec = async () => {
910
chavy.log(`🔔 ${cookieName} 开始签到`)
11+
await getuid()
12+
await watch()
1013
await signdaily()
1114
await signwelfare()
15+
if (week == "日") {
16+
signinfo.canOpenBag = false
17+
signinfo.diceCount = 1
18+
while (!signinfo.canOpenBag && signinfo.diceCount) {
19+
await baginfo()
20+
if (signinfo.baginfo) {
21+
if (signinfo.canOpenBag) {
22+
await openbag()
23+
} else {
24+
await refresh()
25+
}
26+
} else {
27+
break
28+
}
29+
30+
}
31+
}
1232
await getquestion()
1333
if (!signinfo.hasAnswered) {
1434
await answerquestion()
@@ -34,6 +54,48 @@ let VAL_signcookie = chavy.getdata(KEY_signcookie)
3454
chavy.done()
3555
})().catch((e) => chavy.log(`❌ ${cookieName} 签到失败: ${e}`), chavy.done())
3656

57+
function getuid() {
58+
return new Promise((resolve, reject) => {
59+
let url = { url: `https://api.rr.tv/user/profile`, headers: { token: VAL_signcookie } }
60+
url.headers['clientType'] = `web`
61+
url.headers['clientVersion'] = ``
62+
chavy.post(url, (error, response, data) => {
63+
try {
64+
let obj = JSON.parse(data)
65+
signinfo.uid = obj.data.user.id
66+
resolve()
67+
} catch (e) {
68+
chavy.msg(cookieName, `获取会员信息: 失败`, `说明: ${e}`)
69+
chavy.log(`❌ ${cookieName} getinfo - 获取会员信息失败: ${e}`)
70+
chavy.log(`❌ ${cookieName} getinfo - response: ${JSON.stringify(response)}`)
71+
resolve()
72+
}
73+
})
74+
})
75+
}
76+
77+
function watch() {
78+
return new Promise((resolve, reject) => {
79+
let playDuration = Math.floor(Math.random() * -30 + 10800)
80+
let objId = Math.floor(Math.random() * 99 + 153300)
81+
let playTime = Math.round(new Date().getTime()/1000)
82+
let url = { url: `https://api.rr.tv/constant/growthCallback`, headers: { token: VAL_signcookie } }
83+
url.body = "growthStr=" + encodeURIComponent('{"growthRecordDtos":[{"userId":'+signinfo.uid+',"clientVersion":"","playDuration":"'+playDuration+'","clientType":"web","objId":"'+objId+'","type":"season","playTime":"'+playTime+'"}]}') + "&token=" + VAL_signcookie
84+
url.headers['clientType'] = `web`
85+
url.headers['clientVersion'] = ``
86+
chavy.post(url, (error, response, data) => {
87+
try {
88+
resolve();
89+
} catch (e) {
90+
chavy.msg(cookieName, `随机观影: 失败`, `说明: ${e}`)
91+
chavy.log(`❌ ${cookieName} watch - 随机观影失败: ${e}`)
92+
chavy.log(`❌ ${cookieName} watch - response: ${JSON.stringify(response)}`)
93+
resolve()
94+
}
95+
});
96+
});
97+
}
98+
3799
function signdaily() {
38100
return new Promise((resolve, reject) => {
39101
let url = { url: `https://api.rr.tv/rrtv-activity/sign/sign`, headers: { token: VAL_signcookie } }
@@ -162,6 +224,72 @@ function openbox(boxcode, boxname, body) {
162224
})
163225
}
164226

227+
function baginfo() {
228+
return new Promise((resolve, reject) => {
229+
let url = { url: `https://api.rr.tv/rrtv-activity/sign/getInfo`, headers: { token: VAL_signcookie } }
230+
url.headers['clientType'] = `web`
231+
url.headers['clientVersion'] = ``
232+
chavy.post(url, (error, response, data) => {
233+
try {
234+
signinfo.baginfo = JSON.parse(data)
235+
signinfo.canOpenBag = signinfo.baginfo.data.canOpenBag
236+
signinfo.diceCount = signinfo.baginfo.data.diceCount
237+
resolve()
238+
} catch (e) {
239+
chavy.msg(cookieName, `获取礼包信息: 失败`, `说明: ${e}`)
240+
chavy.log(`❌ ${cookieName} baginfo - 获取礼包信息失败: ${e}`)
241+
chavy.log(`❌ ${cookieName} baginfo - response: ${JSON.stringify(response)}`)
242+
resolve()
243+
}
244+
})
245+
})
246+
}
247+
248+
function openbag() {
249+
return new Promise((resolve, reject) => {
250+
let url = { url: `https://api.rr.tv/rrtv-activity/sign/openBag`, headers: { token: VAL_signcookie } }
251+
url.headers['clientType'] = `web`
252+
url.headers['clientVersion'] = ``
253+
chavy.post(url, (error, response, data) => {
254+
try {
255+
signinfo.openbag = JSON.parse(data)
256+
resolve()
257+
} catch (e) {
258+
chavy.msg(cookieName, `打开礼包: 失败`, `说明: ${e}`)
259+
chavy.log(`❌ ${cookieName} openbag - 获取会员信息失败: ${e}`)
260+
chavy.log(`❌ ${cookieName} openbag - response: ${JSON.stringify(response)}`)
261+
resolve()
262+
}
263+
})
264+
})
265+
}
266+
267+
function refresh() {
268+
return new Promise((resolve, reject) => {
269+
let cardDetailList = signinfo.baginfo.data.cardDetailList
270+
for (l of cardDetailList) {
271+
if (l.showDice) {
272+
var cardId = l.id
273+
break
274+
}
275+
}
276+
let url = { url: `https://api.rr.tv/rrtv-activity/sign/reflashUserCard`, headers: { token: VAL_signcookie } }
277+
url.body = "cardDetailId=" + cardId
278+
url.headers['clientType'] = `web`
279+
url.headers['clientVersion'] = ``
280+
chavy.post(url, (error, response, data) => {
281+
try {
282+
resolve()
283+
} catch (e) {
284+
chavy.msg(cookieName, `刷新卡片: 失败`, `说明: ${e}`)
285+
chavy.log(`❌ ${cookieName} refresh - 获取会员信息失败: ${e}`)
286+
chavy.log(`❌ ${cookieName} refresh - response: ${JSON.stringify(response)}`)
287+
resolve()
288+
}
289+
})
290+
})
291+
}
292+
165293
function showmsg() {
166294
let subTitle = ''
167295
let detail = ''
@@ -193,42 +321,53 @@ function showmsg() {
193321
} else {
194322
detail = `编码: ${signinfo.userinfo.code}, 说明: ${signinfo.userinfo.msg}`
195323
}
196-
197-
if (signinfo.question.data.question) {
198-
detail += `\n查看答题详情`
199-
detail += `\n\n问题: ${signinfo.question.data.question.questionStr}`
200-
for (key in signinfo.questionopts)
201-
detail += `\n选项: ${signinfo.questionopts[key].optionStr}, 回答人数: ${signinfo.questionopts[key].answererCount} (${signinfo.questionopts[key].percent})`
202-
if (signinfo.selectId) {
203-
detail += `\n最佳回答: ${signinfo.answeropt.optionStr}`
204-
detail += `\n我的回答: ${signinfo.questionopts[signinfo.selectId].optionStr}`
205-
detail += `${signinfo.isRight ? '✅' : '❌'}\n`
206-
} else {
207-
detail += `\n最佳回答: ${signinfo.answeropt.optionStr}\n`
208-
}
209-
}
210-
324+
325+
detail += '\n'
211326
if (signinfo.copperbox) {
212327
if (signinfo.copperbox.code == '0000') {
213-
for (box of signinfo.copperbox.data.boxs) detail += `\n铜宝箱: ${box.rewardName} (+${box.rewardNum})`
328+
detail += '铜宝箱: '
329+
for (box of signinfo.copperbox.data.boxs) detail += `${box.rewardName} (+${box.rewardNum}) `
214330
} else {
215-
detail += `\n铜宝箱: ${signinfo.copperbox.msg}`
331+
detail += `铜宝箱: ${signinfo.copperbox.msg} `
216332
}
217333
}
218334

219335
if (signinfo.silverbox) {
220336
if (signinfo.silverbox.code == '0000') {
221-
for (box of signinfo.silverbox.data.boxs) detail += `\n银宝箱: ${box.rewardName} (+${box.rewardNum})`
337+
detail += '银宝箱: '
338+
for (box of signinfo.silverbox.data.boxs) detail += `${box.rewardName} (+${box.rewardNum}) `
222339
} else {
223-
detail += `\n银宝箱: ${signinfo.silverbox.msg}`
340+
detail += `银宝箱: ${signinfo.silverbox.msg} `
224341
}
225342
}
226343

227344
if (signinfo.goldenbox) {
228345
if (signinfo.goldenbox.code == '0000') {
229-
for (box of signinfo.goldenbox.data.boxs) detail += `\n金宝箱: ${box.rewardName} (+${box.rewardNum})`
346+
detail += '金宝箱: '
347+
for (box of signinfo.goldenbox.data.boxs) detail += `${box.rewardName} (+${box.rewardNum}) `
348+
} else {
349+
detail += `金宝箱: ${signinfo.goldenbox.msg} `
350+
}
351+
}
352+
353+
if (signinfo.openbag) {
354+
if (signinfo.openbag.code == '0000') {
355+
detail += `\n每周礼盒: ${signinfo.openbag.data.name}`
230356
} else {
231-
detail += `\n金宝箱: ${signinfo.goldenbox.msg}`
357+
detail += `\n每周礼盒: ${signinfo.openbag.msg}`
358+
}
359+
}
360+
361+
if (signinfo.question.data.question) {
362+
detail += `\n\n问题: ${signinfo.question.data.question.questionStr}`
363+
for (key in signinfo.questionopts)
364+
detail += `\n选项: ${signinfo.questionopts[key].optionStr}, 回答人数: ${signinfo.questionopts[key].answererCount} (${signinfo.questionopts[key].percent})`
365+
if (signinfo.selectId) {
366+
detail += `\n最佳回答: ${signinfo.answeropt.optionStr}`
367+
detail += `\n我的回答: ${signinfo.questionopts[signinfo.selectId].optionStr}`
368+
detail += `${signinfo.isRight ? '✅' : '❌'}\n`
369+
} else {
370+
detail += `\n最佳回答: ${signinfo.answeropt.optionStr}\n`
232371
}
233372
}
234373
chavy.msg(cookieName, subTitle, detail)

0 commit comments

Comments
 (0)