|
| 1 | +const cookieName = '美团' |
| 2 | +const signurlKey = 'senku_signurl_fenqile' |
| 3 | +const signheaderKey = 'senku_signheader_fenqile' |
| 4 | +const signbodyKey = 'senku_signbody_fenqile' |
| 5 | +const senku = init() |
| 6 | +const signurlVal = senku.getdata(signurlKey) |
| 7 | +const signheaderVal = senku.getdata(signheaderKey) |
| 8 | +const signBodyVal = senku.getdata(signbodyKey) |
| 9 | + |
| 10 | +sign() |
| 11 | + |
| 12 | +function sign() { |
| 13 | + const url = { url: signurlVal, headers: JSON.parse(signheaderVal), body: signBodyVal } |
| 14 | + senku.post(url, (error, response, data) => { |
| 15 | + senku.log(`${cookieName}, data: ${data}`) |
| 16 | + const res = JSON.parse(data) |
| 17 | + let subTitle = `` |
| 18 | + let detail = `` |
| 19 | + if (res.data.result == 0) { |
| 20 | + subTitle = `签到结果: 成功` |
| 21 | + detail = `账户乐星总数: ${res.data.result_rows.postStar}` |
| 22 | + } else if (res.data.result == 12130020) { |
| 23 | + subTitle = `签到结果: 成功 (重复签到)` |
| 24 | + } else { |
| 25 | + subTitle = `签到结果: 失败` |
| 26 | + detail = `编码: ${res.data.result}, 说明: ${res.data.res_info}` |
| 27 | + } |
| 28 | + senku.msg(cookieName, subTitle, detail) |
| 29 | + senku.done() |
| 30 | + }) |
| 31 | +} |
| 32 | + |
| 33 | +function init() { |
| 34 | + isSurge = () => { |
| 35 | + return undefined === this.$httpClient ? false : true |
| 36 | + } |
| 37 | + isQuanX = () => { |
| 38 | + return undefined === this.$task ? false : true |
| 39 | + } |
| 40 | + getdata = (key) => { |
| 41 | + if (isSurge()) return $persistentStore.read(key) |
| 42 | + if (isQuanX()) return $prefs.valueForKey(key) |
| 43 | + } |
| 44 | + setdata = (key, val) => { |
| 45 | + if (isSurge()) return $persistentStore.write(key, val) |
| 46 | + if (isQuanX()) return $prefs.setValueForKey(key, val) |
| 47 | + } |
| 48 | + msg = (title, subtitle, body) => { |
| 49 | + if (isSurge()) $notification.post(title, subtitle, body) |
| 50 | + if (isQuanX()) $notify(title, subtitle, body) |
| 51 | + } |
| 52 | + log = (message) => console.log(message) |
| 53 | + get = (url, cb) => { |
| 54 | + if (isSurge()) { |
| 55 | + $httpClient.get(url, cb) |
| 56 | + } |
| 57 | + if (isQuanX()) { |
| 58 | + url.method = 'GET' |
| 59 | + $task.fetch(url).then((resp) => cb(null, resp, resp.body)) |
| 60 | + } |
| 61 | + } |
| 62 | + post = (url, cb) => { |
| 63 | + if (isSurge()) { |
| 64 | + $httpClient.post(url, cb) |
| 65 | + } |
| 66 | + if (isQuanX()) { |
| 67 | + url.method = 'POST' |
| 68 | + $task.fetch(url).then((resp) => cb(null, resp, resp.body)) |
| 69 | + } |
| 70 | + } |
| 71 | + done = (value = {}) => { |
| 72 | + $done(value) |
| 73 | + } |
| 74 | + return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done } |
| 75 | +} |
0 commit comments