Skip to content

Commit 8e7b63f

Browse files
committed
添加[趣头条]视频广告奖励
1 parent b954b9a commit 8e7b63f

2 files changed

Lines changed: 135 additions & 24 deletions

File tree

‎qtt/README.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
77
> 感谢 [@GideonSenku](https://github.com/GideonSenku) Commit
88
9+
> 2020.04.07 添加签到脚本
10+
11+
> 2020.04.08 添加视频广告奖励
12+
913
## 配置 (Surge)
1014

1115
```properties

‎qtt/qtt.js‎

Lines changed: 131 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,143 @@ const signbodyKey = 'senku_signbody_qtt'
55
const senku = init()
66
const signurlVal = senku.getdata(signurlKey)
77
const signheaderVal = senku.getdata(signheaderKey)
8+
const adUrl = signurlVal.replace(/sign\?/, "adDone?").concat("&GUID=58711eba362605e8c3afa9be885.31911288")
9+
const getinfoUrlVal = signurlVal.replace(/sign\?/, "info?")
10+
const signinfo = { playList: [] }
811

9-
sign()
12+
console.log(getinfoUrlVal)
13+
let playUrl = [adUrl.concat("&pos=one"), adUrl.concat("&pos=two"), adUrl.concat("&pos=three"), adUrl.concat("&pos=four")]
1014

11-
function sign() {
12-
// Todo: 1.each hour can get rewards,about 30-gold/phase
13-
// Todo: 2.each hour play ads can get rewards about:200-golds/phase,total have four ads
14-
// Todo: 3.Watting for someone do it!
15-
const url = { url: signurlVal, headers: JSON.parse(signheaderVal) }
16-
senku.get(url, (error, response, data) => {
17-
const result = JSON.parse(data)
18-
let subTitle = ``
19-
let detail = ``
20-
const code = result.code
21-
const message = result.message
22-
if (code == 0) {
23-
const amount = result.data.amount
24-
const continuationSignIn = result.data.continuationSignIn
25-
subTitle = `签到结果: 成功`
26-
detail = `获得${amount}💰连续签到天数:${continuationSignIn}天`
27-
} else if (code == -132) {
28-
subTitle = `${message}`
29-
}
30-
else {
31-
subTitle = `签到结果: 失败`
32-
}
33-
senku.msg(cookieName, subTitle, detail)
15+
16+
; (sign = async () => {
17+
senku.log(`🔔 ${cookieName}`)
18+
await signDay()
19+
await play()
20+
await getinfo()
21+
22+
showmsg()
3423
senku.done()
24+
})().catch((e) => senku.log(`❌ ${cookieName} 签到失败: ${e}`), senku.done())
25+
26+
27+
function signDay() {
28+
return new Promise((resolve, reject) => {
29+
const url = { url: signurlVal, headers: JSON.parse(signheaderVal) }
30+
senku.get(url, (error, response, data) => {
31+
try {
32+
senku.log(`❕ ${cookieName} signDay - response: ${JSON.stringify(response)}`)
33+
signinfo.signDay = JSON.parse(data)
34+
resolve()
35+
} catch (e) {
36+
senku.msg(cookieName, `签到结果: 失败`, `说明: ${e}`)
37+
senku.log(`❌ ${cookieName} signDay - 签到失败: ${e}`)
38+
senku.log(`❌ ${cookieName} signDay - response: ${JSON.stringify(response)}`)
39+
resolve()
40+
}
41+
})
42+
})
43+
}
44+
45+
function getinfo() {
46+
return new Promise((resolve, reject) => {
47+
const url = { url: getinfoUrlVal, headers: JSON.parse(signheaderVal) }
48+
senku.get(url, (error, response, data) => {
49+
try {
50+
senku.log(`❕ ${cookieName} getinfo - response: ${JSON.stringify(response)}`)
51+
signinfo.info = JSON.parse(data)
52+
resolve()
53+
} catch (e) {
54+
senku.msg(cookieName, `签到结果: 失败`, `说明: ${e}`)
55+
senku.log(`❌ ${cookieName} getinfo - 签到失败: ${e}`)
56+
senku.log(`❌ ${cookieName} getinfo - response: ${JSON.stringify(response)}`)
57+
resolve()
58+
}
59+
})
60+
})
61+
}
62+
63+
// 播放广告获取奖励
64+
function playAd(urlParameter) {
65+
return new Promise((resolve, reject) => {
66+
const url = { url: urlParameter, headers: JSON.parse(signheaderVal) }
67+
senku.get(url, (error, response, data) => {
68+
try {
69+
senku.log(`❕ ${cookieName} playAd - response: ${JSON.stringify(response)}`)
70+
signinfo.playList.push(JSON.parse(data))
71+
resolve()
72+
} catch (e) {
73+
senku.msg(cookieName, `签到结果: 失败`, `说明: ${e}`)
74+
senku.log(`❌ ${cookieName} playAd - 签到失败: ${e}`)
75+
senku.log(`❌ ${cookieName} playAd - response: ${JSON.stringify(response)}`)
76+
resolve()
77+
}
78+
})
3579
})
3680
}
3781

82+
// 播放广告
83+
function play() {
84+
return new Promise((resolve, reject) => {
85+
playUrl.forEach((url) => {
86+
playAd(url)
87+
resolve()
88+
})
89+
})
90+
}
91+
92+
// 将时间戳格式化
93+
function tTime(timestamp) {
94+
const date = new Date(timestamp * 1000)
95+
const M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'
96+
const D = date.getDate() + ' '
97+
const h = date.getHours() + ':'
98+
const m = date.getMinutes() + ':'
99+
const s = date.getSeconds()
100+
return M + D + h + m + s
101+
}
102+
103+
function showmsg() {
104+
let subTitle = ''
105+
let detail = ''
106+
let moreDetail = ''
107+
// signDay
108+
if (signinfo.info && signinfo.info.data.signIn.today == 1) {
109+
if (signinfo.signDay.code == 0) {
110+
const continuation = signinfo.info.data.signIn.continuation
111+
const amount = signinfo.info.data.signIn.amount
112+
const currentCoin = amount[continuation]
113+
const nextCoin = amount[continuation + 1]
114+
const coins = signinfo.info.data.show_balance_info.coins
115+
subTitle = '签到: 成功'
116+
detail += detail == '' ? '' : ', '
117+
detail += `获得${currentCoin}金币,下次:${nextCoin},总共:${coins}连续签到${continuation}天`
118+
}
119+
else subTitle = '签到: 重复'
120+
} else {
121+
subTitle = '签到: 失败'
122+
senku.log(`❌ ${cookieName} showmsg - 每日签到: ${JSON.stringify(signinfo.signDay)}`)
123+
}
124+
125+
// playAds
126+
subTitle += subTitle == '' ? '' : ', '
127+
if (signinfo.playList) {
128+
subTitle += '广告奖励: 成功'
129+
moreDetail += moreDetail == '' ? '' : '\n'
130+
const icon = signinfo.info.data.signIn.ext_ad.icon
131+
const coins = signinfo.info.data.show_balance_info.coins
132+
const continuation = signinfo.info.data.signIn.continuation
133+
for (const poss of icon) {
134+
const time = tTime(poss.next_time)
135+
moreDetail += `\n视频${poss.pos}: 下次签到时间${time},可获得${poss.amount}`
136+
}
137+
detail += detail == '' ? '' : ', '
138+
detail += `总共:${coins}连续签到${continuation}天`
139+
} else subTitle += '广告奖励: 失败'
140+
141+
if (moreDetail) detail += `\n查看签到详情\n${moreDetail}`
142+
senku.msg(cookieName, subTitle, detail)
143+
senku.done()
144+
}
38145

39146
function init() {
40147
isSurge = () => {

0 commit comments

Comments
 (0)