|
| 1 | +const cookieName = '喜马拉雅' |
| 2 | +const cookieKey = 'chavy_cookie_ximalaya' |
| 3 | +const chavy = init() |
| 4 | +const cookieVal = chavy.getdata(cookieKey) |
| 5 | + |
| 6 | +sign() |
| 7 | + |
| 8 | +function sign() { |
| 9 | + getinfo((signinfo) => { |
| 10 | + if (signinfo.isTickedToday == false) { |
| 11 | + let url = { url: `https://m.ximalaya.com/starwar/lottery/check-in/check/action`, headers: { Cookie: cookieVal } } |
| 12 | + url.headers['Accept'] = `application/json, text/plain, */*` |
| 13 | + url.headers['Accept-Encoding'] = `gzip, deflate, br` |
| 14 | + url.headers['Accept-Language'] = `zh-cn` |
| 15 | + url.headers['Connection'] = `keep-alive` |
| 16 | + url.headers['Host'] = `m.ximalaya.com` |
| 17 | + url.headers['User-Agent'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 iting/6.6.45 kdtunion_iting/1.0 iting(main)/6.6.45/ios_1' |
| 18 | + chavy.post(url, (error, response, data) => { |
| 19 | + const title = `${cookieName}` |
| 20 | + let subTitle = `` |
| 21 | + let detail = `` |
| 22 | + if (data == 'true') { |
| 23 | + getacc((accinfo) => { |
| 24 | + subTitle = `签到结果: 成功` |
| 25 | + detail = `共签: ${signinfo.totalCheckedCounts + 1}天, 积分: ${accinfo.data.score}(+${signinfo.awardAmount})` |
| 26 | + chavy.msg(title, subTitle, detail) |
| 27 | + chavy.log(`${cookieName}, sign: ${data}`) |
| 28 | + }) |
| 29 | + } else { |
| 30 | + subTitle = `签到结果: 失败` |
| 31 | + detail = `说明: ${data}` |
| 32 | + chavy.msg(title, subTitle, detail) |
| 33 | + chavy.log(`${cookieName}, sign: ${data}`) |
| 34 | + } |
| 35 | + }) |
| 36 | + chavy.done() |
| 37 | + } |
| 38 | + }) |
| 39 | +} |
| 40 | + |
| 41 | +function getinfo(cb) { |
| 42 | + let url = { url: `https://m.ximalaya.com/starwar/lottery/check-in/record`, headers: { Cookie: cookieVal } } |
| 43 | + url.headers['Accept'] = `application/json, text/plain, */*` |
| 44 | + url.headers['Accept-Encoding'] = `gzip, deflate, br` |
| 45 | + url.headers['Accept-Language'] = `zh-cn` |
| 46 | + url.headers['Connection'] = `keep-alive` |
| 47 | + url.headers['Content-Type'] = `application/json;charset=utf-8` |
| 48 | + url.headers['Host'] = `m.ximalaya.com` |
| 49 | + url.headers['User-Agent'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 iting/6.6.45 kdtunion_iting/1.0 iting(main)/6.6.45/ios_1' |
| 50 | + chavy.get(url, (error, response, data) => { |
| 51 | + chavy.log(`${cookieName}, signinfo: ${data}`) |
| 52 | + if (data) { |
| 53 | + const signinfo = JSON.parse(data) |
| 54 | + if (signinfo.isTickedToday == true) { |
| 55 | + getacc((accinfo) => { |
| 56 | + const title = `${cookieName}` |
| 57 | + let subTitle = `签到结果: 成功 (重复签到)` |
| 58 | + let detail = `共签: ${signinfo.totalCheckedCounts}天, 积分: ${accinfo.data.score}(+${signinfo.awardAmount})` |
| 59 | + chavy.msg(title, subTitle, detail) |
| 60 | + chavy.log(`${cookieName}, data: ${data}`) |
| 61 | + }) |
| 62 | + } else { |
| 63 | + cb(signinfo) |
| 64 | + } |
| 65 | + } else { |
| 66 | + const title = `${cookieName}` |
| 67 | + let subTitle = `签到结果: 失败` |
| 68 | + let detail = `说明: 请选登录` |
| 69 | + chavy.msg(title, subTitle, detail) |
| 70 | + } |
| 71 | + }) |
| 72 | +} |
| 73 | + |
| 74 | +function getacc(cb) { |
| 75 | + let url = { url: `https://m.ximalaya.com/starwar/task/listen/account`, headers: { Cookie: cookieVal } } |
| 76 | + url.headers['Accept'] = `application/json, text/plain, */*` |
| 77 | + url.headers['Accept-Encoding'] = `gzip, deflate, br` |
| 78 | + url.headers['Accept-Language'] = `zh-cn` |
| 79 | + url.headers['Connection'] = `keep-alive` |
| 80 | + url.headers['Content-Type'] = `application/json;charset=utf-8` |
| 81 | + url.headers['Host'] = `m.ximalaya.com` |
| 82 | + url.headers['User-Agent'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 iting/6.6.45 kdtunion_iting/1.0 iting(main)/6.6.45/ios_1' |
| 83 | + chavy.get(url, (error, response, data) => { |
| 84 | + cb(JSON.parse(data)) |
| 85 | + chavy.log(`${cookieName}, acc: ${data}`) |
| 86 | + }) |
| 87 | +} |
| 88 | + |
| 89 | +function init() { |
| 90 | + isSurge = () => { |
| 91 | + return undefined === this.$httpClient ? false : true |
| 92 | + } |
| 93 | + isQuanX = () => { |
| 94 | + return undefined === this.$task ? false : true |
| 95 | + } |
| 96 | + getdata = (key) => { |
| 97 | + if (isSurge()) return $persistentStore.read(key) |
| 98 | + if (isQuanX()) return $prefs.valueForKey(key) |
| 99 | + } |
| 100 | + setdata = (key, val) => { |
| 101 | + if (isSurge()) return $persistentStore.write(key, val) |
| 102 | + if (isQuanX()) return $prefs.setValueForKey(key, val) |
| 103 | + } |
| 104 | + msg = (title, subtitle, body) => { |
| 105 | + if (isSurge()) $notification.post(title, subtitle, body) |
| 106 | + if (isQuanX()) $notify(title, subtitle, body) |
| 107 | + } |
| 108 | + log = (message) => console.log(message) |
| 109 | + get = (url, cb) => { |
| 110 | + if (isSurge()) { |
| 111 | + $httpClient.get(url, cb) |
| 112 | + } |
| 113 | + if (isQuanX()) { |
| 114 | + url.method = 'GET' |
| 115 | + $task.fetch(url).then((resp) => cb(null, {}, resp.body)) |
| 116 | + } |
| 117 | + } |
| 118 | + post = (url, cb) => { |
| 119 | + if (isSurge()) { |
| 120 | + $httpClient.post(url, cb) |
| 121 | + } |
| 122 | + if (isQuanX()) { |
| 123 | + url.method = 'POST' |
| 124 | + $task.fetch(url).then((resp) => cb(null, {}, resp.body)) |
| 125 | + } |
| 126 | + } |
| 127 | + done = (value = {}) => { |
| 128 | + $done(value) |
| 129 | + } |
| 130 | + return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done } |
| 131 | +} |
0 commit comments