2020-07-02 11:50:39 +08:00
|
|
|
const $ = new Env('有道云笔记')
|
|
|
|
|
|
|
|
!(async () => {
|
2020-07-02 11:52:57 +08:00
|
|
|
$.log('', `🔔 ${$.name}, 获取会话: 开始!`, '')
|
|
|
|
const VAL_url = $request.url
|
|
|
|
const VAL_body = $request.body
|
|
|
|
const VAL_headers = JSON.stringify($request.headers)
|
2020-07-02 11:50:39 +08:00
|
|
|
|
2020-07-02 11:52:57 +08:00
|
|
|
$.log('', `❌ ${$.name}`, `url: ${$request.url}`, `body: ${$request.body}`, `headers: ${JSON.stringify($request.headers)}`, '')
|
2020-07-02 11:50:39 +08:00
|
|
|
|
2020-07-02 11:52:57 +08:00
|
|
|
if (VAL_url && VAL_body && VAL_headers) {
|
|
|
|
$.setdata(VAL_url, 'chavy_signurl_noteyoudao')
|
|
|
|
$.setdata(VAL_body, 'chavy_signbody_noteyoudao')
|
|
|
|
$.setdata(VAL_headers, 'chavy_signheaders_noteyoudao')
|
|
|
|
$.subt = '获取会话: 成功 (签到)!'
|
|
|
|
}
|
2020-07-02 11:50:39 +08:00
|
|
|
})()
|
2020-07-02 11:52:57 +08:00
|
|
|
.catch((e) => {
|
|
|
|
$.subt = '获取会话: 失败!'
|
|
|
|
$.desc = `原因: ${e}`
|
|
|
|
$.log(`❌ ${$.name}, 获取会话: 失败! 原因: ${e}!`)
|
|
|
|
})
|
|
|
|
.finally(() => {
|
|
|
|
$.msg($.name, $.subt, $.desc), $.log('', `🔔 ${$.name}, 获取会话: 结束!`, ''), $.done()
|
|
|
|
})
|
2020-07-02 11:50:39 +08:00
|
|
|
|
|
|
|
// prettier-ignore
|
2020-07-02 11:52:57 +08:00
|
|
|
function Env(t) {
|
|
|
|
this.name = t, this.logs = [], this.isSurge = (() => "undefined" != typeof $httpClient), this.isQuanX = (() => "undefined" != typeof $task), this.log = ((...t) => {
|
|
|
|
this.logs = [...this.logs, ...t], t ? console.log(t.join("\n")) : console.log(this.logs.join("\n"))
|
|
|
|
}), this.msg = ((t = this.name, s = "", i = "") => {
|
|
|
|
this.isSurge() && $notification.post(t, s, i), this.isQuanX() && $notify(t, s, i), this.log("==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="), t && this.log(t), s && this.log(s), i && this.log(i)
|
|
|
|
}), this.getdata = (t => this.isSurge() ? $persistentStore.read(t) : this.isQuanX() ? $prefs.valueForKey(t) : void 0), this.setdata = ((t, s) => this.isSurge() ? $persistentStore.write(t, s) : this.isQuanX() ? $prefs.setValueForKey(t, s) : void 0), this.get = ((t, s) => this.send(t, "GET", s)), this.wait = ((t, s = t) => i => setTimeout(() => i(), Math.floor(Math.random() * (s - t + 1) + t))), this.post = ((t, s) => this.send(t, "POST", s)), this.send = ((t, s, i) => {
|
|
|
|
if (this.isSurge()) {
|
|
|
|
const e = "POST" == s ? $httpClient.post : $httpClient.get;
|
|
|
|
e(t, (t, s, e) => {
|
|
|
|
s && (s.body = e, s.statusCode = s.status), i(t, s, e)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
this.isQuanX() && (t.method = s, $task.fetch(t).then(t => {
|
|
|
|
t.status = t.statusCode, i(null, t, t.body)
|
|
|
|
}, t => i(t.error, t, t)))
|
|
|
|
}), this.done = ((t = {}) => $done(t))
|
|
|
|
}
|