|
| 1 | +const cookieName = '懂球帝' |
| 2 | +const cookieKey = 'chavy_cookie_dongqiudi' |
| 3 | +const chavy = init() |
| 4 | +const cookieVal = JSON.parse(chavy.getdata(cookieKey)) |
| 5 | + |
| 6 | +sign() |
| 7 | + |
| 8 | +function sign() { |
| 9 | + let url = { url: `https://api.dongqiudi.com/v3/useract/sign/tasknew/index`, headers: {} } |
| 10 | + url.headers['UUID'] = `${cookieVal.UUID}` |
| 11 | + url.headers['Authorization'] = `${cookieVal.Authorization}` |
| 12 | + url.headers['Accept-Encoding'] = `gzip, deflate, br` |
| 13 | + url.headers['Origin'] = `https://n.dongqiudi.com` |
| 14 | + url.headers['Connection'] = `keep-alive` |
| 15 | + url.headers['Accept'] = `application/json, text/plain, */*` |
| 16 | + url.headers['Referer'] = `https://n.dongqiudi.com/webapp/signIn.html` |
| 17 | + url.headers['Host'] = `api.dongqiudi.com` |
| 18 | + 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 NewsApp/7.3.3 NetType/NA Technology/Wifi (iPhone; iOS 13.3; Scale/2.00) dongqiudiClientApp (modelIdentifier/iPhone10,1 )` |
| 19 | + url.headers['Accept-Language'] = `zh-cn` |
| 20 | + |
| 21 | + chavy.get(url, (error, response, data) => { |
| 22 | + chavy.log(`${cookieName}, data: ${data}`) |
| 23 | + let result = JSON.parse(data) |
| 24 | + const title = `${cookieName}` |
| 25 | + let subTitle = `` |
| 26 | + let detail = `` |
| 27 | + if (result.code == 0) { |
| 28 | + if (result.data.sign_gold != 0) subTitle = '签到结果: 成功' |
| 29 | + else subTitle = '签到结果: 成功 (重复签到)' |
| 30 | + detail = `连签: ${result.data.continue_sign_days}天, 金币: ${result.data.gold_num} (+${result.data.sign_gold}), 价值: ${result.data.convertible_money}元` |
| 31 | + } else { |
| 32 | + subTitle = '签到结果: 失败' |
| 33 | + detail = `编码: ${result.code}, 说明: ${result.message}` |
| 34 | + } |
| 35 | + chavy.msg(title, subTitle, detail) |
| 36 | + }) |
| 37 | + chavy.done() |
| 38 | +} |
| 39 | + |
| 40 | +function init() { |
| 41 | + isSurge = () => { |
| 42 | + return undefined === this.$httpClient ? false : true |
| 43 | + } |
| 44 | + isQuanX = () => { |
| 45 | + return undefined === this.$task ? false : true |
| 46 | + } |
| 47 | + getdata = (key) => { |
| 48 | + if (isSurge()) return $persistentStore.read(key) |
| 49 | + if (isQuanX()) return $prefs.valueForKey(key) |
| 50 | + } |
| 51 | + setdata = (key, val) => { |
| 52 | + if (isSurge()) return $persistentStore.write(key, val) |
| 53 | + if (isQuanX()) return $prefs.setValueForKey(key, val) |
| 54 | + } |
| 55 | + msg = (title, subtitle, body) => { |
| 56 | + if (isSurge()) $notification.post(title, subtitle, body) |
| 57 | + if (isQuanX()) $notify(title, subtitle, body) |
| 58 | + } |
| 59 | + log = (message) => console.log(message) |
| 60 | + get = (url, cb) => { |
| 61 | + if (isSurge()) { |
| 62 | + $httpClient.get(url, cb) |
| 63 | + } |
| 64 | + if (isQuanX()) { |
| 65 | + url.method = 'GET' |
| 66 | + $task.fetch(url).then((resp) => cb(null, {}, resp.body)) |
| 67 | + } |
| 68 | + } |
| 69 | + post = (url, cb) => { |
| 70 | + if (isSurge()) { |
| 71 | + $httpClient.post(url, cb) |
| 72 | + } |
| 73 | + if (isQuanX()) { |
| 74 | + url.method = 'POST' |
| 75 | + $task.fetch(url).then((resp) => cb(null, {}, resp.body)) |
| 76 | + } |
| 77 | + } |
| 78 | + done = (value = {}) => { |
| 79 | + $done(value) |
| 80 | + } |
| 81 | + return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done } |
| 82 | +} |
0 commit comments