Skip to content

Commit

Permalink
Merge pull request #224 from zZPiglet/master
Browse files Browse the repository at this point in the history
增加随机观看请求,以获得足够活跃值开金宝箱。增加每周礼包抽奖,若未达到抽奖条件,则尝试使用骰子进行刷新卡片以满足条件直至骰子用完(为了节省…
  • Loading branch information
chavyleung authored Aug 24, 2020
2 parents 2ca8d40 + 034a7df commit 747fd56
Show file tree
Hide file tree
Showing 2 changed files with 168 additions and 25 deletions.
12 changes: 8 additions & 4 deletions rrtv/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@

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

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

[task_local]
1 0 * * * rrtv.js
10 0 * * * rrtv.js
```

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

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

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

*/60 * * * * xxx.js # 每60分执行一次
0 * * * * xxx.js # 每60分整点执行一次
```

## 感谢
Expand Down
181 changes: 160 additions & 21 deletions rrtv/rrtv.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,31 @@ const KEY_signcookie = 'chavy_cookie_rrtv'

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

;(exec = async () => {
chavy.log(`🔔 ${cookieName} 开始签到`)
await getuid()
await watch()
await signdaily()
await signwelfare()
if (week == "日") {
signinfo.canOpenBag = false
signinfo.diceCount = 1
while (!signinfo.canOpenBag && signinfo.diceCount) {
await baginfo()
if (signinfo.baginfo) {
if (signinfo.canOpenBag) {
await openbag()
} else {
await refresh()
}
} else {
break
}

}
}
await getquestion()
if (!signinfo.hasAnswered) {
await answerquestion()
Expand All @@ -34,6 +54,48 @@ let VAL_signcookie = chavy.getdata(KEY_signcookie)
chavy.done()
})().catch((e) => chavy.log(`❌ ${cookieName} 签到失败: ${e}`), chavy.done())

function getuid() {
return new Promise((resolve, reject) => {
let url = { url: `https://api.rr.tv/user/profile`, headers: { token: VAL_signcookie } }
url.headers['clientType'] = `web`
url.headers['clientVersion'] = ``
chavy.post(url, (error, response, data) => {
try {
let obj = JSON.parse(data)
signinfo.uid = obj.data.user.id
resolve()
} catch (e) {
chavy.msg(cookieName, `获取会员信息: 失败`, `说明: ${e}`)
chavy.log(`❌ ${cookieName} getinfo - 获取会员信息失败: ${e}`)
chavy.log(`❌ ${cookieName} getinfo - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}

function watch() {
return new Promise((resolve, reject) => {
let playDuration = Math.floor(Math.random() * -30 + 10800)
let objId = Math.floor(Math.random() * 99 + 153300)
let playTime = Math.round(new Date().getTime()/1000)
let url = { url: `https://api.rr.tv/constant/growthCallback`, headers: { token: VAL_signcookie } }
url.body = "growthStr=" + encodeURIComponent('{"growthRecordDtos":[{"userId":'+signinfo.uid+',"clientVersion":"","playDuration":"'+playDuration+'","clientType":"web","objId":"'+objId+'","type":"season","playTime":"'+playTime+'"}]}') + "&token=" + VAL_signcookie
url.headers['clientType'] = `web`
url.headers['clientVersion'] = ``
chavy.post(url, (error, response, data) => {
try {
resolve();
} catch (e) {
chavy.msg(cookieName, `随机观影: 失败`, `说明: ${e}`)
chavy.log(`❌ ${cookieName} watch - 随机观影失败: ${e}`)
chavy.log(`❌ ${cookieName} watch - response: ${JSON.stringify(response)}`)
resolve()
}
});
});
}

function signdaily() {
return new Promise((resolve, reject) => {
let url = { url: `https://api.rr.tv/rrtv-activity/sign/sign`, headers: { token: VAL_signcookie } }
Expand Down Expand Up @@ -162,6 +224,72 @@ function openbox(boxcode, boxname, body) {
})
}

function baginfo() {
return new Promise((resolve, reject) => {
let url = { url: `https://api.rr.tv/rrtv-activity/sign/getInfo`, headers: { token: VAL_signcookie } }
url.headers['clientType'] = `web`
url.headers['clientVersion'] = ``
chavy.post(url, (error, response, data) => {
try {
signinfo.baginfo = JSON.parse(data)
signinfo.canOpenBag = signinfo.baginfo.data.canOpenBag
signinfo.diceCount = signinfo.baginfo.data.diceCount
resolve()
} catch (e) {
chavy.msg(cookieName, `获取礼包信息: 失败`, `说明: ${e}`)
chavy.log(`❌ ${cookieName} baginfo - 获取礼包信息失败: ${e}`)
chavy.log(`❌ ${cookieName} baginfo - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}

function openbag() {
return new Promise((resolve, reject) => {
let url = { url: `https://api.rr.tv/rrtv-activity/sign/openBag`, headers: { token: VAL_signcookie } }
url.headers['clientType'] = `web`
url.headers['clientVersion'] = ``
chavy.post(url, (error, response, data) => {
try {
signinfo.openbag = JSON.parse(data)
resolve()
} catch (e) {
chavy.msg(cookieName, `打开礼包: 失败`, `说明: ${e}`)
chavy.log(`❌ ${cookieName} openbag - 获取会员信息失败: ${e}`)
chavy.log(`❌ ${cookieName} openbag - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}

function refresh() {
return new Promise((resolve, reject) => {
let cardDetailList = signinfo.baginfo.data.cardDetailList
for (l of cardDetailList) {
if (l.showDice) {
var cardId = l.id
break
}
}
let url = { url: `https://api.rr.tv/rrtv-activity/sign/reflashUserCard`, headers: { token: VAL_signcookie } }
url.body = "cardDetailId=" + cardId
url.headers['clientType'] = `web`
url.headers['clientVersion'] = ``
chavy.post(url, (error, response, data) => {
try {
resolve()
} catch (e) {
chavy.msg(cookieName, `刷新卡片: 失败`, `说明: ${e}`)
chavy.log(`❌ ${cookieName} refresh - 获取会员信息失败: ${e}`)
chavy.log(`❌ ${cookieName} refresh - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}

function showmsg() {
let subTitle = ''
let detail = ''
Expand Down Expand Up @@ -193,42 +321,53 @@ function showmsg() {
} else {
detail = `编码: ${signinfo.userinfo.code}, 说明: ${signinfo.userinfo.msg}`
}

if (signinfo.question.data.question) {
detail += `\n查看答题详情`
detail += `\n\n问题: ${signinfo.question.data.question.questionStr}`
for (key in signinfo.questionopts)
detail += `\n选项: ${signinfo.questionopts[key].optionStr}, 回答人数: ${signinfo.questionopts[key].answererCount} (${signinfo.questionopts[key].percent})`
if (signinfo.selectId) {
detail += `\n最佳回答: ${signinfo.answeropt.optionStr}`
detail += `\n我的回答: ${signinfo.questionopts[signinfo.selectId].optionStr}`
detail += `${signinfo.isRight ? '✅' : '❌'}\n`
} else {
detail += `\n最佳回答: ${signinfo.answeropt.optionStr}\n`
}
}


detail += '\n'
if (signinfo.copperbox) {
if (signinfo.copperbox.code == '0000') {
for (box of signinfo.copperbox.data.boxs) detail += `\n铜宝箱: ${box.rewardName} (+${box.rewardNum})`
detail += '铜宝箱: '
for (box of signinfo.copperbox.data.boxs) detail += `${box.rewardName} (+${box.rewardNum}) `
} else {
detail += `\n铜宝箱: ${signinfo.copperbox.msg}`
detail += `铜宝箱: ${signinfo.copperbox.msg} `
}
}

if (signinfo.silverbox) {
if (signinfo.silverbox.code == '0000') {
for (box of signinfo.silverbox.data.boxs) detail += `\n银宝箱: ${box.rewardName} (+${box.rewardNum})`
detail += '银宝箱: '
for (box of signinfo.silverbox.data.boxs) detail += `${box.rewardName} (+${box.rewardNum}) `
} else {
detail += `\n银宝箱: ${signinfo.silverbox.msg}`
detail += `银宝箱: ${signinfo.silverbox.msg} `
}
}

if (signinfo.goldenbox) {
if (signinfo.goldenbox.code == '0000') {
for (box of signinfo.goldenbox.data.boxs) detail += `\n金宝箱: ${box.rewardName} (+${box.rewardNum})`
detail += '金宝箱: '
for (box of signinfo.goldenbox.data.boxs) detail += `${box.rewardName} (+${box.rewardNum}) `
} else {
detail += `金宝箱: ${signinfo.goldenbox.msg} `
}
}

if (signinfo.openbag) {
if (signinfo.openbag.code == '0000') {
detail += `\n每周礼盒: ${signinfo.openbag.data.name}`
} else {
detail += `\n金宝箱: ${signinfo.goldenbox.msg}`
detail += `\n每周礼盒: ${signinfo.openbag.msg}`
}
}

if (signinfo.question.data.question) {
detail += `\n\n问题: ${signinfo.question.data.question.questionStr}`
for (key in signinfo.questionopts)
detail += `\n选项: ${signinfo.questionopts[key].optionStr}, 回答人数: ${signinfo.questionopts[key].answererCount} (${signinfo.questionopts[key].percent})`
if (signinfo.selectId) {
detail += `\n最佳回答: ${signinfo.answeropt.optionStr}`
detail += `\n我的回答: ${signinfo.questionopts[signinfo.selectId].optionStr}`
detail += `${signinfo.isRight ? '✅' : '❌'}\n`
} else {
detail += `\n最佳回答: ${signinfo.answeropt.optionStr}\n`
}
}
chavy.msg(cookieName, subTitle, detail)
Expand Down

0 comments on commit 747fd56

Please sign in to comment.