Rules-For-Quantumult-X/Scripts/SignIn/JDHome/jddj.js

75 lines
2.4 KiB
JavaScript
Raw Normal View History

2020-07-02 11:52:57 +08:00
const cookieName = '京东到家'
2020-07-02 11:50:39 +08:00
const signheaderKey = 'chen_signheader_jddj'
const chen = init()
const signheaderVal = chen.getdata(signheaderKey)
sign()
2020-07-02 11:52:57 +08:00
2020-07-02 11:50:39 +08:00
function sign() {
2020-07-02 11:52:57 +08:00
let url = {
url: `https://daojia.jd.com/client?functionId=signin%2FuserSigninNew&body=%7B%7D`,
headers: JSON.parse(signheaderVal)
}
2020-07-02 11:50:39 +08:00
chen.get(url, (error, response, data) => {
2020-07-02 11:52:57 +08:00
chen.log(`${cookieName}, data: ${data}`)
let res = JSON.parse(data)
const title = `${cookieName}`
let subTitle = ``
let detail = ``
if (res.success && res.result.points != 'undefined') {
subTitle = `签到结果:成功`
detail = `获取鲜豆:${res.result.points}`
} else if (!res.success && res.code == 202) {
subTitle = `签到结果: 失败`
detail = `说明: ${res.msg}`
} else if (!res.success && res.code == -1) {
subTitle = `签到成功,请勿重复操作`
} else {
subTitle = `未知错误,截图日志`
}
chen.msg(title, subTitle, detail)
2020-07-02 11:50:39 +08:00
})
2020-07-02 11:52:57 +08:00
}
2020-07-02 11:50:39 +08:00
2020-07-02 11:52:57 +08:00
function init() {
2020-07-02 11:50:39 +08:00
isSurge = () => {
2020-07-02 11:52:57 +08:00
return undefined === this.$httpClient ? false : true
2020-07-02 11:50:39 +08:00
}
isQuanX = () => {
2020-07-02 11:52:57 +08:00
return undefined === this.$task ? false : true
2020-07-02 11:50:39 +08:00
}
getdata = (key) => {
2020-07-02 11:52:57 +08:00
if (isSurge()) return $persistentStore.read(key)
if (isQuanX()) return $prefs.valueForKey(key)
2020-07-02 11:50:39 +08:00
}
setdata = (key, val) => {
2020-07-02 11:52:57 +08:00
if (isSurge()) return $persistentStore.write(key, val)
if (isQuanX()) return $prefs.setValueForKey(key, val)
2020-07-02 11:50:39 +08:00
}
msg = (title, subtitle, body) => {
2020-07-02 11:52:57 +08:00
if (isSurge()) $notification.post(title, subtitle, body)
if (isQuanX()) $notify(title, subtitle, body)
2020-07-02 11:50:39 +08:00
}
log = (message) => console.log(message)
get = (url, cb) => {
2020-07-02 11:52:57 +08:00
if (isSurge()) {
$httpClient.get(url, cb)
}
if (isQuanX()) {
url.method = 'GET'
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
}
2020-07-02 11:50:39 +08:00
}
post = (url, cb) => {
2020-07-02 11:52:57 +08:00
if (isSurge()) {
$httpClient.post(url, cb)
}
if (isQuanX()) {
url.method = 'POST'
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
}
2020-07-02 11:50:39 +08:00
}
done = (value = {}) => {
2020-07-02 11:52:57 +08:00
$done(value)
2020-07-02 11:50:39 +08:00
}
2020-07-02 11:52:57 +08:00
return {isSurge, isQuanX, msg, log, getdata, setdata, get, post, done}
}