forked from chavyleung/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
videoqq.js
147 lines (140 loc) · 5.13 KB
/
videoqq.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
const chavy = init()
const cookieName = '腾讯视频'
const KEY_signcookie = 'chavy_cookie_videoqq'
const KEY_loginurl = 'chavy_auth_url_videoqq'
const KEY_loginheader = 'chavy_auth_header_videoqq'
const KEY_mh5signurl = 'chavy_msign_url_videoqq'
const KEY_mh5signheader = 'chavy_msign_header_videoqq'
const signinfo = {}
let VAL_signcookie = chavy.getdata(KEY_signcookie)
let VAL_loginurl = chavy.getdata(KEY_loginurl)
let VAL_loginheader = chavy.getdata(KEY_loginheader)
let VAL_mh5signurl = chavy.getdata(KEY_mh5signurl)
let VAL_mh5signheader = chavy.getdata(KEY_mh5signheader)
;(sign = async () => {
chavy.log(`🔔 ${cookieName}`)
await login()
await signapp()
await getexp()
showmsg()
})()
.catch((e) => chavy.log(`❌ ${cookieName} 签到失败: ${e}`))
.finally(() => chavy.done())
function login() {
return new Promise((resolve, reject) => {
const url = { url: VAL_loginurl, headers: JSON.parse(VAL_loginheader) }
chavy.get(url, (error, response, data) => {
try {
resolve()
} catch (e) {
chavy.msg(cookieName, `签到结果: 失败`, `说明: ${e}`)
chavy.log(`❌ ${cookieName} login - 登录失败: ${e}`)
chavy.log(`❌ ${cookieName} login - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
function signapp() {
return new Promise((resolve, reject) => {
const timestamp = Math.round(new Date().getTime() / 1000).toString()
const VAL_signurl = `https://vip.video.qq.com/fcgi-bin/comm_cgi?name=hierarchical_task_system&cmd=2&_=${timestamp}`
let url = { url: VAL_signurl, headers: {} }
url.headers['User-Agent'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.4 Safari/605.1.15'
chavy.get(url, (error, response, data) => {
try {
signinfo.signapp = JSON.parse(data.match(/\((.*)\);/)[1])
resolve()
} catch (e) {
chavy.msg(cookieName, `签到结果: 失败`, `说明: ${e}`)
chavy.log(`❌ ${cookieName} signapp - 签到失败: ${e}`)
chavy.log(`❌ ${cookieName} signapp - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
function getexp() {
return new Promise((resolve, reject) => {
const timestamp = Math.round(new Date().getTime() / 1000).toString()
const VAL_getexpurl = `https://vip.video.qq.com/fcgi-bin/comm_cgi?name=spp_PropertyNum&cmd=1&growth_value=1&otype=json&_=${timestamp}`
let url = { url: VAL_getexpurl, headers: {} }
url.headers['User-Agent'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.4 Safari/605.1.15'
chavy.get(url, (error, response, data) => {
try {
signinfo.expinfo = JSON.parse(data.match(/\((.*)\);/)[1])
resolve()
} catch (e) {
chavy.msg(cookieName, `签到结果: 失败`, `说明: ${e}`)
chavy.log(`❌ ${cookieName} getexp - 签到失败: ${e}`)
chavy.log(`❌ ${cookieName} getexp - response: ${JSON.stringify(response)}`)
resolve()
}
})
})
}
function showmsg() {
if (signinfo.signapp) {
let subTitle, detail
if (signinfo.signapp.ret == 0) {
subTitle = '签到结果: 成功'
if (signinfo.expinfo) {
subTitle += !signinfo.signapp.checkin_score ? ' (重复签到)' : ''
detail = `V力值: ${signinfo.expinfo.GrowthValue.num} (+${signinfo.signapp.checkin_score}), 观影券: ${signinfo.expinfo.MovieTicket.num}, 赠片资格: ${signinfo.expinfo.GiveMovie.num}`
}
} else if (signinfo.signapp.ret == -10006) {
subTitle = '签到结果: 失败'
detail = `原因: 未登录, 说明: ${signinfo.signapp.msg}`
} else if (signinfo.signapp.ret == -10019) {
subTitle = '签到结果: 失败'
detail = `原因: 非会员, 说明: ${signinfo.signapp.msg}`
} else {
subTitle = '签到结果: 未知'
detail = `编码: ${signinfo.signapp.ret}, 说明: ${signinfo.signapp.msg}`
}
chavy.msg(cookieName, subTitle, detail)
}
}
function init() {
isSurge = () => {
return undefined === this.$httpClient ? false : true
}
isQuanX = () => {
return undefined === this.$task ? false : true
}
getdata = (key) => {
if (isSurge()) return $persistentStore.read(key)
if (isQuanX()) return $prefs.valueForKey(key)
}
setdata = (key, val) => {
if (isSurge()) return $persistentStore.write(key, val)
if (isQuanX()) return $prefs.setValueForKey(key, val)
}
msg = (title, subtitle, body) => {
if (isSurge()) $notification.post(title, subtitle, body)
if (isQuanX()) $notify(title, subtitle, body)
}
log = (message) => console.log(message)
get = (url, cb) => {
if (isSurge()) {
$httpClient.get(url, cb)
}
if (isQuanX()) {
url.method = 'GET'
$task.fetch(url).then((resp) => cb(null, resp, resp.body))
}
}
post = (url, cb) => {
if (isSurge()) {
$httpClient.post(url, cb)
}
if (isQuanX()) {
url.method = 'POST'
$task.fetch(url).then((resp) => cb(null, resp, resp.body))
}
}
done = (value = {}) => {
$done(value)
}
return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done }
}