|
| 1 | +const cookieName = '电信营业厅' |
| 2 | +const cookieKey = 'chavy_cookie_10000' |
| 3 | +const mobileKey = 'chavy_mobile_10000' |
| 4 | +const chavy = init() |
| 5 | +const cookieVal = chavy.getdata(cookieKey) |
| 6 | +const mobileVal = chavy.getdata(mobileKey) |
| 7 | + |
| 8 | +sign() |
| 9 | + |
| 10 | +function sign() { |
| 11 | + let url = { url: `https://wapside.189.cn:9001/api/home/sign`, headers: { Cookie: cookieVal } } |
| 12 | + url.headers['Content-Type'] = 'application/json;charset=utf-8' |
| 13 | + 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;CtClient;7.6.0;iOS;13.3;iPhone XR' |
| 14 | + url.headers['Host'] = 'wapside.189.cn:9001' |
| 15 | + url.headers['Origin'] = 'https://wapside.189.cn:9001' |
| 16 | + url.headers['Referer'] = 'https://wapside.189.cn:9001/resources/dist/signInActivity.html?cmpid=jt-khd-my-zygn&ticket=0ab000281b4a8139f264620ae1d8b1ce067a6587921f90a6260dca4389a4e01a&version=7.6.0' |
| 17 | + url.body = JSON.stringify({ phone: mobileVal }) |
| 18 | + chavy.post(url, (error, response, data) => { |
| 19 | + chavy.log(`${cookieName}, data: ${data}`) |
| 20 | + let result = JSON.parse(data) |
| 21 | + const title = `${cookieName}` |
| 22 | + let subTitle = `` |
| 23 | + let detail = `` |
| 24 | + if (result.data.code == 1) { |
| 25 | + subTitle = `签到结果: 成功 (${mobileVal})` |
| 26 | + detail = `获得金币${result.data.coin}, 金豆${result.data.flow}` |
| 27 | + } else if (result.data.code == 0) { |
| 28 | + subTitle = `签到结果: 重复 (${mobileVal})` |
| 29 | + detail = `说明: ${result.data.msg}` |
| 30 | + } else { |
| 31 | + subTitle = `签到结果: 失败 (${mobileVal})` |
| 32 | + detail = `说明: ${result.data.msg}` |
| 33 | + } |
| 34 | + chavy.msg(title, subTitle, detail) |
| 35 | + }) |
| 36 | + chavy.done() |
| 37 | +} |
| 38 | + |
| 39 | +function init() { |
| 40 | + isSurge = () => { |
| 41 | + return undefined === this.$httpClient ? false : true |
| 42 | + } |
| 43 | + isQuanX = () => { |
| 44 | + return undefined === this.$task ? false : true |
| 45 | + } |
| 46 | + getdata = (key) => { |
| 47 | + if (isSurge()) return $persistentStore.read(key) |
| 48 | + if (isQuanX()) return $prefs.valueForKey(key) |
| 49 | + } |
| 50 | + setdata = (key, val) => { |
| 51 | + if (isSurge()) return $persistentStore.write(key, val) |
| 52 | + if (isQuanX()) return $prefs.setValueForKey(key, val) |
| 53 | + } |
| 54 | + msg = (title, subtitle, body) => { |
| 55 | + if (isSurge()) $notification.post(title, subtitle, body) |
| 56 | + if (isQuanX()) $notify(title, subtitle, body) |
| 57 | + } |
| 58 | + log = (message) => console.log(message) |
| 59 | + get = (url, cb) => { |
| 60 | + if (isSurge()) { |
| 61 | + $httpClient.get(url, cb) |
| 62 | + } |
| 63 | + if (isQuanX()) { |
| 64 | + url.method = 'GET' |
| 65 | + $task.fetch(url).then((resp) => cb(null, {}, resp.body)) |
| 66 | + } |
| 67 | + } |
| 68 | + post = (url, cb) => { |
| 69 | + if (isSurge()) { |
| 70 | + $httpClient.post(url, cb) |
| 71 | + } |
| 72 | + if (isQuanX()) { |
| 73 | + url.method = 'POST' |
| 74 | + $task.fetch(url).then((resp) => cb(null, {}, resp.body)) |
| 75 | + } |
| 76 | + } |
| 77 | + done = (value = {}) => { |
| 78 | + $done(value) |
| 79 | + } |
| 80 | + return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done } |
| 81 | +} |
0 commit comments