|
| 1 | +const cookieName = '字幕组' |
| 2 | +const cookieKey = 'chavy_cookie_zimuzu' |
| 3 | +const chavy = init() |
| 4 | +const cookieVal = chavy.getdata(cookieKey) |
| 5 | + |
| 6 | +sign() |
| 7 | + |
| 8 | +function sign() { |
| 9 | + const timestamp = Date.parse(new Date()) |
| 10 | + let url = { url: `http://www.zmz2019.com/user/login/getCurUserTopInfo`, headers: { Cookie: cookieVal } } |
| 11 | + url.headers['User-Agent'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.4 Safari/605.1.15' |
| 12 | + |
| 13 | + chavy.get(url, (error, response, data) => { |
| 14 | + chavy.log(`${cookieName}, data: ${data}`) |
| 15 | + let result = JSON.parse(data) |
| 16 | + const title = `${cookieName}` |
| 17 | + let subTitle = '' |
| 18 | + let detail = '' |
| 19 | + if (result.status == 1) { |
| 20 | + if (result.data.new_login) subTitle = '签到结果: 成功' |
| 21 | + else subTitle = '签到结果: 成功 (重复签到)' |
| 22 | + detail = `人人钻: ${result.data.userinfo.point}, 登录天数: ${result.data.usercount.cont_login} -> ${result.data.upgrade_day}` |
| 23 | + chavy.msg(title, subTitle, detail) |
| 24 | + } else { |
| 25 | + subTitle = '签到结果: 未知' |
| 26 | + chavy.msg(title, subTitle, detail) |
| 27 | + } |
| 28 | + }) |
| 29 | + chavy.done() |
| 30 | +} |
| 31 | + |
| 32 | +function init() { |
| 33 | + isSurge = () => { |
| 34 | + return undefined === this.$httpClient ? false : true |
| 35 | + } |
| 36 | + isQuanX = () => { |
| 37 | + return undefined === this.$task ? false : true |
| 38 | + } |
| 39 | + getdata = (key) => { |
| 40 | + if (isSurge()) return $persistentStore.read(key) |
| 41 | + if (isQuanX()) return $prefs.valueForKey(key) |
| 42 | + } |
| 43 | + setdata = (key, val) => { |
| 44 | + if (isSurge()) return $persistentStore.write(key, val) |
| 45 | + if (isQuanX()) return $prefs.setValueForKey(key, val) |
| 46 | + } |
| 47 | + msg = (title, subtitle, body) => { |
| 48 | + if (isSurge()) $notification.post(title, subtitle, body) |
| 49 | + if (isQuanX()) $notify(title, subtitle, body) |
| 50 | + } |
| 51 | + log = (message) => console.log(message) |
| 52 | + get = (url, cb) => { |
| 53 | + if (isSurge()) { |
| 54 | + $httpClient.get(url, cb) |
| 55 | + } |
| 56 | + if (isQuanX()) { |
| 57 | + url.method = 'GET' |
| 58 | + $task.fetch(url).then((resp) => cb(null, {}, resp.body)) |
| 59 | + } |
| 60 | + } |
| 61 | + post = (url, cb) => { |
| 62 | + if (isSurge()) { |
| 63 | + $httpClient.post(url, cb) |
| 64 | + } |
| 65 | + if (isQuanX()) { |
| 66 | + url.method = 'POST' |
| 67 | + $task.fetch(url).then((resp) => cb(null, {}, resp.body)) |
| 68 | + } |
| 69 | + } |
| 70 | + done = (value = {}) => { |
| 71 | + $done(value) |
| 72 | + } |
| 73 | + return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done } |
| 74 | +} |
0 commit comments