MCPcopy Create free account
hub / github.com/NobyDa/Script / Checkin

Function Checkin

KuaiKan-DailyBonus/KKMH.js:85–133  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

83})
84
85function Checkin() {
86 return new Promise(resolve => {
87 $.get({
88 url: 'https://h5.kuaikanmanhua.com/v2/checkin/task_center/checkin',
89 headers: {
90 'Cookie': cookie || $.getdata("@KKMH.COOKIE"),
91 'User-Agent': 'Kuaikan/5.75.0/575000(iPhone;Scale/3.00) (iPhone; CPU)',
92 'X-Device': '0'
93 }
94 }, async (error, response, data) => {
95 try {
96 if (error) throw new Error(error)
97 const cc = JSON.parse(data)
98 const Details = LogDetails ? data ? `response:\n${data}` : '' : ''
99 if (cc.code == 200) {
100 $.log(`${$.name} 成功${Details}`)
101 const pop = cc.data.check_in_home_info.pop_title
102 const text = cc.data.check_in_home_info.check_in_bubble_text
103 const title = cc.data.check_in_home_info.check_in_title
104 const score = cc.data.check_in_home_info.user_score
105 const kkb = cc.data.check_in_home_info.user_kkb
106 const uid = $.getdata("@KKMH.COOKIE") ? $.getdata("@KKMH.COOKIE").match(/uid=(\d+)/) : ''
107 const rep = $.getdata("@KKMH.DATE") == date.getDate() && (uid ? uid[1] : '') == $.getdata("@KKMH.UID")
108 const gift = await GiftPack(title);
109 $.subtitle = rep ? '今天已签过!' : pop;
110 $.msgBody = `${rep?``:text+', '}现有${$.score||score}积分, ${$.kkb||kkb}KK币\n${gift||title} 🎉`;
111 $.setdata(JSON.stringify(date.getDate()), "@KKMH.DATE")
112 $.setdata(uid ? uid[1] : '', "@KKMH.UID")
113 } else {
114 $.log(`${$.name} 失败${Details}`)
115 if (cc.code == 401) {
116 $.msgBody = 'Cookie失效 ⚠️';
117 } else {
118 $.msgBody = cc.message || '未知错误 ⚠️';
119 }
120 }
121 } catch (err) {
122 $.logErr(err)
123 $.msgBody = `错误, 已输出日志 ⚠️`;
124 } finally {
125 $.msg($.name, $.subtitle || '', $.msgBody, imgUrl);
126 if (barkKey) {
127 await BarkNotify($, barkKey, $.name, $.msgBody);
128 }
129 resolve()
130 }
131 })
132 })
133}
134
135function GiftPack(type) {
136 return new Promise(resolve => {

Callers 1

KKMH.jsFile · 0.70

Calls 9

GiftPackFunction · 0.85
BarkNotifyFunction · 0.70
getMethod · 0.45
getdataMethod · 0.45
logMethod · 0.45
setdataMethod · 0.45
stringifyMethod · 0.45
logErrMethod · 0.45
msgMethod · 0.45

Tested by

no test coverage detected