|
| 1 | +const cookieName = '美团外卖' |
| 2 | +const tokenurlKey = 'chavy_tokenurl_wmmeituan' |
| 3 | +const tokenheaderKey = 'chavy_tokenheader_wmmeituan' |
| 4 | +const signurlKey = 'chavy_signurl_wmmeituan' |
| 5 | +const signheaderKey = 'chavy_signheader_wmmeituan' |
| 6 | +const signbodyKey = 'chavy_signbody_wmmeituan' |
| 7 | +const chavy = init() |
| 8 | + |
| 9 | +const requrl = $request.url |
| 10 | +const reqRef = $request.headers.Referer |
| 11 | +if ($request && $request.method != 'OPTIONS' && requrl.match(/playcenter\/signIn\/entry/)) { |
| 12 | + const tokenurlVal = requrl |
| 13 | + const tokenheaderVal = JSON.stringify($request.headers) |
| 14 | + if (tokenurlVal) chavy.setdata(tokenurlVal, tokenurlKey) |
| 15 | + if (tokenheaderVal) chavy.setdata(tokenheaderVal, tokenheaderKey) |
| 16 | + title = chavy.msg(cookieName, `获取刷新链接: 成功`, ``) |
| 17 | +} else if ($request && $request.method != 'OPTIONS' && requrl.match(/playcenter\/signIn\/doaction/)) { |
| 18 | + const signurlVal = requrl |
| 19 | + const signheaderVal = JSON.stringify($request.headers) |
| 20 | + const signbodyVal = $request.body |
| 21 | + if (signurlVal) chavy.setdata(signurlVal, signurlKey) |
| 22 | + if (signheaderVal) chavy.setdata(signheaderVal, signheaderKey) |
| 23 | + if (signbodyVal) chavy.setdata(signbodyVal, signbodyKey) |
| 24 | + else { |
| 25 | + const tokenurlVal = chavy.getdata(tokenurlKey) |
| 26 | + const body = {} |
| 27 | + body.activityViewId = tokenurlVal.match(/activityViewId=(.*?)(&|$)/)[1] |
| 28 | + body.lat = tokenurlVal.match(/lat=(.*?)(&|$)/)[1] |
| 29 | + body.lng = tokenurlVal.match(/lng=(.*?)(&|$)/)[1] |
| 30 | + body.checkLogin = true |
| 31 | + body.appType = 3 |
| 32 | + body.deviceType = 2 |
| 33 | + chavy.setdata(JSON.stringify(body), signbodyKey) |
| 34 | + } |
| 35 | + title = chavy.msg(cookieName, `获取Cookie: 成功`, ``) |
| 36 | +} |
| 37 | + |
| 38 | +function init() { |
| 39 | + isSurge = () => { |
| 40 | + return undefined === this.$httpClient ? false : true |
| 41 | + } |
| 42 | + isQuanX = () => { |
| 43 | + return undefined === this.$task ? false : true |
| 44 | + } |
| 45 | + getdata = (key) => { |
| 46 | + if (isSurge()) return $persistentStore.read(key) |
| 47 | + if (isQuanX()) return $prefs.valueForKey(key) |
| 48 | + } |
| 49 | + setdata = (key, val) => { |
| 50 | + if (isSurge()) return $persistentStore.write(key, val) |
| 51 | + if (isQuanX()) return $prefs.setValueForKey(key, val) |
| 52 | + } |
| 53 | + msg = (title, subtitle, body) => { |
| 54 | + if (isSurge()) $notification.post(title, subtitle, body) |
| 55 | + if (isQuanX()) $notify(title, subtitle, body) |
| 56 | + } |
| 57 | + log = (message) => console.log(message) |
| 58 | + get = (url, cb) => { |
| 59 | + if (isSurge()) { |
| 60 | + $httpClient.get(url, cb) |
| 61 | + } |
| 62 | + if (isQuanX()) { |
| 63 | + url.method = 'GET' |
| 64 | + $task.fetch(url).then((resp) => cb(null, {}, resp.body)) |
| 65 | + } |
| 66 | + } |
| 67 | + post = (url, cb) => { |
| 68 | + if (isSurge()) { |
| 69 | + $httpClient.post(url, cb) |
| 70 | + } |
| 71 | + if (isQuanX()) { |
| 72 | + url.method = 'POST' |
| 73 | + $task.fetch(url).then((resp) => cb(null, {}, resp.body)) |
| 74 | + } |
| 75 | + } |
| 76 | + done = (value = {}) => { |
| 77 | + $done(value) |
| 78 | + } |
| 79 | + return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done } |
| 80 | +} |
| 81 | +chavy.done() |
0 commit comments