Change Directory.
This commit is contained in:
parent
cfc8aee69e
commit
d2cbfe94f3
|
@ -4,54 +4,55 @@ const KEY_signbody = 'chavy_signbody_10000'
|
|||
const KEY_mobile = 'chavy_mobile_10000'
|
||||
const chavy = init()
|
||||
if (this.$request && this.$request.headers && this.$request.body) {
|
||||
const VAL_signheader = JSON.stringify($request.headers)
|
||||
const VAL_signbody = this.$request.body
|
||||
if (VAL_signheader) chavy.setdata(VAL_signheader, KEY_signheader)
|
||||
if (VAL_signbody) chavy.setdata(VAL_signbody, KEY_signbody)
|
||||
chavy.msg(cookieName, `获取Cookie: 成功`, ``)
|
||||
const VAL_signheader = JSON.stringify($request.headers)
|
||||
const VAL_signbody = this.$request.body
|
||||
if (VAL_signheader) chavy.setdata(VAL_signheader, KEY_signheader)
|
||||
if (VAL_signbody) chavy.setdata(VAL_signbody, KEY_signbody)
|
||||
chavy.msg(cookieName, `获取Cookie: 成功`, ``)
|
||||
}
|
||||
|
||||
function init() {
|
||||
isSurge = () => {
|
||||
return undefined === this.$httpClient ? false : true
|
||||
}
|
||||
isQuanX = () => {
|
||||
return undefined === this.$task ? false : true
|
||||
}
|
||||
getdata = (key) => {
|
||||
if (isSurge()) return $persistentStore.read(key)
|
||||
if (isQuanX()) return $prefs.valueForKey(key)
|
||||
}
|
||||
setdata = (key, val) => {
|
||||
if (isSurge()) return $persistentStore.write(key, val)
|
||||
if (isQuanX()) return $prefs.setValueForKey(key, val)
|
||||
}
|
||||
msg = (title, subtitle, body) => {
|
||||
if (isSurge()) $notification.post(title, subtitle, body)
|
||||
if (isQuanX()) $notify(title, subtitle, body)
|
||||
}
|
||||
log = (message) => console.log(message)
|
||||
get = (url, cb) => {
|
||||
if (isSurge()) {
|
||||
$httpClient.get(url, cb)
|
||||
isSurge = () => {
|
||||
return undefined === this.$httpClient ? false : true
|
||||
}
|
||||
if (isQuanX()) {
|
||||
url.method = 'GET'
|
||||
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
|
||||
isQuanX = () => {
|
||||
return undefined === this.$task ? false : true
|
||||
}
|
||||
}
|
||||
post = (url, cb) => {
|
||||
if (isSurge()) {
|
||||
$httpClient.post(url, cb)
|
||||
getdata = (key) => {
|
||||
if (isSurge()) return $persistentStore.read(key)
|
||||
if (isQuanX()) return $prefs.valueForKey(key)
|
||||
}
|
||||
if (isQuanX()) {
|
||||
url.method = 'POST'
|
||||
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
|
||||
setdata = (key, val) => {
|
||||
if (isSurge()) return $persistentStore.write(key, val)
|
||||
if (isQuanX()) return $prefs.setValueForKey(key, val)
|
||||
}
|
||||
}
|
||||
done = (value = {}) => {
|
||||
$done(value)
|
||||
}
|
||||
return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done }
|
||||
msg = (title, subtitle, body) => {
|
||||
if (isSurge()) $notification.post(title, subtitle, body)
|
||||
if (isQuanX()) $notify(title, subtitle, body)
|
||||
}
|
||||
log = (message) => console.log(message)
|
||||
get = (url, cb) => {
|
||||
if (isSurge()) {
|
||||
$httpClient.get(url, cb)
|
||||
}
|
||||
if (isQuanX()) {
|
||||
url.method = 'GET'
|
||||
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
|
||||
}
|
||||
}
|
||||
post = (url, cb) => {
|
||||
if (isSurge()) {
|
||||
$httpClient.post(url, cb)
|
||||
}
|
||||
if (isQuanX()) {
|
||||
url.method = 'POST'
|
||||
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
|
||||
}
|
||||
}
|
||||
done = (value = {}) => {
|
||||
$done(value)
|
||||
}
|
||||
return {isSurge, isQuanX, msg, log, getdata, setdata, get, post, done}
|
||||
}
|
||||
|
||||
chavy.done()
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -39,7 +39,7 @@ let VAL_findlotteryheader = chavy.getdata(KEY_findlotteryheader)
|
|||
|
||||
function loginapp() {
|
||||
return new Promise((resolve, reject) => {
|
||||
const url = { url: VAL_loginurl, headers: JSON.parse(VAL_loginheader) }
|
||||
const url = {url: VAL_loginurl, headers: JSON.parse(VAL_loginheader)}
|
||||
chavy.post(url, (error, response, data) => {
|
||||
try {
|
||||
resolve()
|
||||
|
@ -56,7 +56,7 @@ function loginapp() {
|
|||
function signapp() {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (VAL_signurl.endsWith('.do')) VAL_signurl = VAL_signurl.replace('.do', '')
|
||||
const url = { url: 'https://act.10010.com/SigninApp/signin/daySign', headers: JSON.parse(VAL_signheader) }
|
||||
const url = {url: 'https://act.10010.com/SigninApp/signin/daySign', headers: JSON.parse(VAL_signheader)}
|
||||
chavy.post(url, (error, response, data) => {
|
||||
try {
|
||||
signinfo.signapp = JSON.parse(data)
|
||||
|
@ -73,7 +73,7 @@ function signapp() {
|
|||
|
||||
function loginlottery() {
|
||||
return new Promise((resolve, reject) => {
|
||||
const url = { url: VAL_loginlotteryurl, headers: JSON.parse(VAL_loginlotteryheader) }
|
||||
const url = {url: VAL_loginlotteryurl, headers: JSON.parse(VAL_loginlotteryheader)}
|
||||
chavy.get(url, (error, response, data) => {
|
||||
try {
|
||||
const encryptmobileMatch = data.match(/encryptmobile=([^('|")]*)/)
|
||||
|
@ -99,7 +99,7 @@ function findlottery() {
|
|||
return new Promise((resolve, reject) => {
|
||||
VAL_findlotteryurl = VAL_findlotteryurl.replace(/encryptmobile=[^(&|$)]*/, `encryptmobile=${signinfo.encryptmobile}`)
|
||||
VAL_findlotteryurl = VAL_findlotteryurl.replace(/mobile=[^(&|$)]*/, `mobile=${signinfo.encryptmobile}`)
|
||||
const url = { url: VAL_findlotteryurl, headers: JSON.parse(VAL_findlotteryheader) }
|
||||
const url = {url: VAL_findlotteryurl, headers: JSON.parse(VAL_findlotteryheader)}
|
||||
chavy.get(url, (error, response, data) => {
|
||||
try {
|
||||
signinfo.findlottery = JSON.parse(data)
|
||||
|
@ -116,7 +116,10 @@ function findlottery() {
|
|||
|
||||
function lottery() {
|
||||
return new Promise((resolve, reject) => {
|
||||
const url = { url: `https://m.client.10010.com/dailylottery/static/doubleball/choujiang?usernumberofjsp=${signinfo.encryptmobile}`, headers: JSON.parse(VAL_loginlotteryheader) }
|
||||
const url = {
|
||||
url: `https://m.client.10010.com/dailylottery/static/doubleball/choujiang?usernumberofjsp=${signinfo.encryptmobile}`,
|
||||
headers: JSON.parse(VAL_loginlotteryheader)
|
||||
}
|
||||
url.headers['Referer'] = `https://m.client.10010.com/dailylottery/static/doubleball/firstpage?encryptmobile=${signinfo.encryptmobile}`
|
||||
chavy.post(url, (error, response, data) => {
|
||||
try {
|
||||
|
@ -145,7 +148,7 @@ function gettel() {
|
|||
|
||||
function getinfo() {
|
||||
return new Promise((resolve, reject) => {
|
||||
const url = { url: `https://mina.10010.com/wxapplet/bind/getIndexData/alipay/alipaymini?user_id=${gettel()}` }
|
||||
const url = {url: `https://mina.10010.com/wxapplet/bind/getIndexData/alipay/alipaymini?user_id=${gettel()}`}
|
||||
chavy.get(url, (error, response, data) => {
|
||||
try {
|
||||
signinfo.info = JSON.parse(data)
|
||||
|
@ -249,5 +252,5 @@ function init() {
|
|||
done = (value = {}) => {
|
||||
$done(value)
|
||||
}
|
||||
return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done }
|
||||
return {isSurge, isQuanX, msg, log, getdata, setdata, get, post, done}
|
||||
}
|
||||
|
|
|
@ -1,28 +1,46 @@
|
|||
const $ = new Env('ApkTw')
|
||||
|
||||
!(async () => {
|
||||
$.log('', `🔔 ${$.name}, 获取会话: 开始!`, '')
|
||||
const session = {}
|
||||
session.url = $request.url
|
||||
session.body = $request.body
|
||||
session.headers = $request.headers
|
||||
delete session.headers['Content-Length']
|
||||
delete session.headers['Cookie']
|
||||
$.log('', `url: ${session.url}`, `body: ${session.body}`, `headers: ${JSON.stringify(session.headers)}`)
|
||||
if ($.setdata(JSON.stringify(session), 'chavy_cookie_apktw')) {
|
||||
$.subt = '获取会话: 成功!'
|
||||
} else {
|
||||
$.subt = '获取会话: 失败!'
|
||||
}
|
||||
$.log('', `🔔 ${$.name}, 获取会话: 开始!`, '')
|
||||
const session = {}
|
||||
session.url = $request.url
|
||||
session.body = $request.body
|
||||
session.headers = $request.headers
|
||||
delete session.headers['Content-Length']
|
||||
delete session.headers['Cookie']
|
||||
$.log('', `url: ${session.url}`, `body: ${session.body}`, `headers: ${JSON.stringify(session.headers)}`)
|
||||
if ($.setdata(JSON.stringify(session), 'chavy_cookie_apktw')) {
|
||||
$.subt = '获取会话: 成功!'
|
||||
} else {
|
||||
$.subt = '获取会话: 失败!'
|
||||
}
|
||||
})()
|
||||
.catch((e) => {
|
||||
$.subt = '获取会话: 失败!'
|
||||
$.desc = `原因: ${e}`
|
||||
$.log(`❌ ${$.name}, 获取会话: 失败! 原因: ${e}!`)
|
||||
})
|
||||
.finally(() => {
|
||||
$.msg($.name, $.subt, $.desc), $.log('', `🔔 ${$.name}, 获取会话: 结束!`, ''), $.done()
|
||||
})
|
||||
.catch((e) => {
|
||||
$.subt = '获取会话: 失败!'
|
||||
$.desc = `原因: ${e}`
|
||||
$.log(`❌ ${$.name}, 获取会话: 失败! 原因: ${e}!`)
|
||||
})
|
||||
.finally(() => {
|
||||
$.msg($.name, $.subt, $.desc), $.log('', `🔔 ${$.name}, 获取会话: 结束!`, ''), $.done()
|
||||
})
|
||||
|
||||
// prettier-ignore
|
||||
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);const e=["","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];t&&e.push(t),s&&e.push(s),i&&e.push(i),console.log(e.join("\n"))}),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))}
|
||||
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);
|
||||
const e = ["", "==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];
|
||||
t && e.push(t), s && e.push(s), i && e.push(i), console.log(e.join("\n"))
|
||||
}), 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))
|
||||
}
|
||||
|
|
|
@ -2,95 +2,113 @@ const $ = new Env('ApkTw')
|
|||
$.VAL_login = $.getdata('chavy_cookie_apktw')
|
||||
|
||||
!(async () => {
|
||||
$.log('', `🔔 ${$.name}, 开始!`, '')
|
||||
await login()
|
||||
await getHash()
|
||||
await sign()
|
||||
await showmsg()
|
||||
$.log('', `🔔 ${$.name}, 开始!`, '')
|
||||
await login()
|
||||
await getHash()
|
||||
await sign()
|
||||
await showmsg()
|
||||
})()
|
||||
.catch((e) => {
|
||||
$.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '')
|
||||
})
|
||||
.finally(() => {
|
||||
$.msg($.name, $.subt, ''), $.log('', `🔔 ${$.name}, 结束!`, ''), $.done()
|
||||
})
|
||||
.catch((e) => {
|
||||
$.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '')
|
||||
})
|
||||
.finally(() => {
|
||||
$.msg($.name, $.subt, ''), $.log('', `🔔 ${$.name}, 结束!`, ''), $.done()
|
||||
})
|
||||
|
||||
// 登录
|
||||
function login() {
|
||||
const url = JSON.parse($.VAL_login)
|
||||
return new Promise((resove) => $.post(url, (error, response, data) => resove()))
|
||||
const url = JSON.parse($.VAL_login)
|
||||
return new Promise((resove) => $.post(url, (error, response, data) => resove()))
|
||||
}
|
||||
|
||||
function getHash() {
|
||||
return new Promise((resove) => {
|
||||
const url = { url: 'https://apk.tw/', headers: {} }
|
||||
url.headers['Host'] = 'apk.tw'
|
||||
url.headers['Referer'] = 'https://apk.tw/forum.php'
|
||||
url.headers['Accept'] = '*/*'
|
||||
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'
|
||||
$.get(url, (error, response, data) => {
|
||||
try {
|
||||
if (error) throw new Error(error)
|
||||
if (/\/source\/plugin\/dsu_amupper\/images\/wb\.gif/.test(data)) {
|
||||
$.isSigned = true
|
||||
$.isSignSuc = true
|
||||
} else {
|
||||
$.isSigned = false
|
||||
const [hash] = /plugin.php\?id=dsu_amupper:pper([^('|")]*)/.exec(data)
|
||||
if (hash) {
|
||||
$.hash = hash
|
||||
} else {
|
||||
$.isSignSuc = false
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
$.log(`❗️ ${$.name}, 执行失败!`, ` error = ${error || e}`, `response = ${JSON.stringify(response)}`, '')
|
||||
} finally {
|
||||
resove()
|
||||
}
|
||||
return new Promise((resove) => {
|
||||
const url = {url: 'https://apk.tw/', headers: {}}
|
||||
url.headers['Host'] = 'apk.tw'
|
||||
url.headers['Referer'] = 'https://apk.tw/forum.php'
|
||||
url.headers['Accept'] = '*/*'
|
||||
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'
|
||||
$.get(url, (error, response, data) => {
|
||||
try {
|
||||
if (error) throw new Error(error)
|
||||
if (/\/source\/plugin\/dsu_amupper\/images\/wb\.gif/.test(data)) {
|
||||
$.isSigned = true
|
||||
$.isSignSuc = true
|
||||
} else {
|
||||
$.isSigned = false
|
||||
const [hash] = /plugin.php\?id=dsu_amupper:pper([^('|")]*)/.exec(data)
|
||||
if (hash) {
|
||||
$.hash = hash
|
||||
} else {
|
||||
$.isSignSuc = false
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
$.log(`❗️ ${$.name}, 执行失败!`, ` error = ${error || e}`, `response = ${JSON.stringify(response)}`, '')
|
||||
} finally {
|
||||
resove()
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function sign() {
|
||||
if ($.isSigned && !$.hash) return
|
||||
return new Promise((resove) => {
|
||||
const url = { url: `https://apk.tw/${$.hash}&inajax=1&ajaxtarget=my_amupper`, headers: {} }
|
||||
$.log(`❕ ${url.url}!`)
|
||||
url.headers['Host'] = 'apk.tw'
|
||||
url.headers['Referer'] = 'https://apk.tw/forum.php'
|
||||
url.headers['Accept'] = '*/*'
|
||||
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'
|
||||
$.get(url, (error, response, data) => {
|
||||
try {
|
||||
if (error) throw new Error(error)
|
||||
if (/\/source\/plugin\/dsu_amupper\/images\/wb\.gif/.test(data)) {
|
||||
$.isSignSuc = true
|
||||
} else {
|
||||
$.isSignSuc = false
|
||||
}
|
||||
} catch (e) {
|
||||
$.isSignSuc = false
|
||||
$.log(`❗️ ${$.name}, 执行失败!`, ` error = ${error || e}`, `response = ${JSON.stringify(response)}`, '')
|
||||
} finally {
|
||||
resove()
|
||||
}
|
||||
if ($.isSigned && !$.hash) return
|
||||
return new Promise((resove) => {
|
||||
const url = {url: `https://apk.tw/${$.hash}&inajax=1&ajaxtarget=my_amupper`, headers: {}}
|
||||
$.log(`❕ ${url.url}!`)
|
||||
url.headers['Host'] = 'apk.tw'
|
||||
url.headers['Referer'] = 'https://apk.tw/forum.php'
|
||||
url.headers['Accept'] = '*/*'
|
||||
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'
|
||||
$.get(url, (error, response, data) => {
|
||||
try {
|
||||
if (error) throw new Error(error)
|
||||
if (/\/source\/plugin\/dsu_amupper\/images\/wb\.gif/.test(data)) {
|
||||
$.isSignSuc = true
|
||||
} else {
|
||||
$.isSignSuc = false
|
||||
}
|
||||
} catch (e) {
|
||||
$.isSignSuc = false
|
||||
$.log(`❗️ ${$.name}, 执行失败!`, ` error = ${error || e}`, `response = ${JSON.stringify(response)}`, '')
|
||||
} finally {
|
||||
resove()
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function showmsg() {
|
||||
return new Promise((resove) => {
|
||||
if ($.isSigned) {
|
||||
$.subt = '签到: 重复'
|
||||
} else if (!$.isSigned && $.isSignSuc) {
|
||||
$.subt = '签到: 成功'
|
||||
} else {
|
||||
$.subt = '签到: 失败'
|
||||
}
|
||||
resove()
|
||||
})
|
||||
return new Promise((resove) => {
|
||||
if ($.isSigned) {
|
||||
$.subt = '签到: 重复'
|
||||
} else if (!$.isSigned && $.isSignSuc) {
|
||||
$.subt = '签到: 成功'
|
||||
} else {
|
||||
$.subt = '签到: 失败'
|
||||
}
|
||||
resove()
|
||||
})
|
||||
}
|
||||
|
||||
// prettier-ignore
|
||||
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);const e=["","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];t&&e.push(t),s&&e.push(s),i&&e.push(i),console.log(e.join("\n"))}),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))}
|
||||
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);
|
||||
const e = ["", "==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];
|
||||
t && e.push(t), s && e.push(s), i && e.push(i), console.log(e.join("\n"))
|
||||
}), 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))
|
||||
}
|
||||
|
|
|
@ -4,59 +4,61 @@ const shareKey = 'senku_key_bcz'
|
|||
const senku = init()
|
||||
|
||||
if (this.$request && this.$request.headers) {
|
||||
const cookieVal = $request.headers['Cookie']
|
||||
const url = $request.url
|
||||
const index1 = url.indexOf('=')
|
||||
const index2 = url.indexOf('&')
|
||||
const shareVal = url.substring(index1 + 1, index2)
|
||||
if (cookieVal && shareVal) {
|
||||
if (senku.setdata(cookieVal, cookieKey) && senku.setdata(shareVal, shareKey)) {
|
||||
senku.msg(`${cookieName}`, '获取Cookie: 成功', '')
|
||||
senku.log(`[${cookieName}] 获取Cookie: 成功, cookie: ${cookieVal}`)
|
||||
const cookieVal = $request.headers['Cookie']
|
||||
const url = $request.url
|
||||
const index1 = url.indexOf('=')
|
||||
const index2 = url.indexOf('&')
|
||||
const shareVal = url.substring(index1 + 1, index2)
|
||||
if (cookieVal && shareVal) {
|
||||
if (senku.setdata(cookieVal, cookieKey) && senku.setdata(shareVal, shareKey)) {
|
||||
senku.msg(`${cookieName}`, '获取Cookie: 成功', '')
|
||||
senku.log(`[${cookieName}] 获取Cookie: 成功, cookie: ${cookieVal}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function init() {
|
||||
isSurge = () => {
|
||||
return undefined === this.$httpClient ? false : true
|
||||
}
|
||||
isQuanX = () => {
|
||||
return undefined === this.$task ? false : true
|
||||
}
|
||||
getdata = (key) => {
|
||||
if (isSurge()) return $persistentStore.read(key)
|
||||
if (isQuanX()) return $prefs.valueForKey(key)
|
||||
}
|
||||
setdata = (key, val) => {
|
||||
if (isSurge()) return $persistentStore.write(key, val)
|
||||
if (isQuanX()) return $prefs.setValueForKey(key, val)
|
||||
}
|
||||
msg = (title, subtitle, body) => {
|
||||
if (isSurge()) $notification.post(title, subtitle, body)
|
||||
if (isQuanX()) $notify(title, subtitle, body)
|
||||
}
|
||||
log = (message) => console.log(message)
|
||||
get = (url, cb) => {
|
||||
if (isSurge()) {
|
||||
$httpClient.get(url, cb)
|
||||
isSurge = () => {
|
||||
return undefined === this.$httpClient ? false : true
|
||||
}
|
||||
if (isQuanX()) {
|
||||
url.method = 'GET'
|
||||
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
|
||||
isQuanX = () => {
|
||||
return undefined === this.$task ? false : true
|
||||
}
|
||||
}
|
||||
post = (url, cb) => {
|
||||
if (isSurge()) {
|
||||
$httpClient.post(url, cb)
|
||||
getdata = (key) => {
|
||||
if (isSurge()) return $persistentStore.read(key)
|
||||
if (isQuanX()) return $prefs.valueForKey(key)
|
||||
}
|
||||
if (isQuanX()) {
|
||||
url.method = 'POST'
|
||||
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
|
||||
setdata = (key, val) => {
|
||||
if (isSurge()) return $persistentStore.write(key, val)
|
||||
if (isQuanX()) return $prefs.setValueForKey(key, val)
|
||||
}
|
||||
}
|
||||
done = (value = {}) => {
|
||||
$done(value)
|
||||
}
|
||||
return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done }
|
||||
msg = (title, subtitle, body) => {
|
||||
if (isSurge()) $notification.post(title, subtitle, body)
|
||||
if (isQuanX()) $notify(title, subtitle, body)
|
||||
}
|
||||
log = (message) => console.log(message)
|
||||
get = (url, cb) => {
|
||||
if (isSurge()) {
|
||||
$httpClient.get(url, cb)
|
||||
}
|
||||
if (isQuanX()) {
|
||||
url.method = 'GET'
|
||||
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
|
||||
}
|
||||
}
|
||||
post = (url, cb) => {
|
||||
if (isSurge()) {
|
||||
$httpClient.post(url, cb)
|
||||
}
|
||||
if (isQuanX()) {
|
||||
url.method = 'POST'
|
||||
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
|
||||
}
|
||||
}
|
||||
done = (value = {}) => {
|
||||
$done(value)
|
||||
}
|
||||
return {isSurge, isQuanX, msg, log, getdata, setdata, get, post, done}
|
||||
}
|
||||
|
||||
senku.done()
|
||||
|
|
|
@ -8,75 +8,76 @@ const shareVal = senku.getdata(shareKey)
|
|||
let signinfo = {}
|
||||
senku.log()
|
||||
check()
|
||||
|
||||
function check(cb) {
|
||||
const url = { url: `https://group.baicizhan.com/group/apply_reward`, headers: { Cookie: cookieVal } }
|
||||
url.headers['Content-Type'] = `text/plain;charset=utf-8`
|
||||
url.headers['User-Agent'] = `Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/7.0.10(0x17000a21) NetType/4G Language/zh_CN`
|
||||
const key = { share_key: shareVal }
|
||||
url.body = JSON.stringify(key)
|
||||
senku.log(url.body)
|
||||
senku.post(url, (error, response, data) => {
|
||||
signinfo = JSON.parse(data)
|
||||
senku.log(JSON.stringify(signinfo))
|
||||
const title = `${cookieName}`
|
||||
let subTitle = ``
|
||||
let detail = ''
|
||||
if (signinfo.code == 1) {
|
||||
if (signinfo.data.is_new) {
|
||||
subTitle += `成功`
|
||||
detail = `获取铜板数${signinfo.data.reward[2]}`
|
||||
} else {
|
||||
subTitle += `今天的铜板已经领取,但是单词还是可以继续背的`
|
||||
}
|
||||
} else {
|
||||
detail = `状态: 还玩手机?快去背单词`
|
||||
subTitle += '失败'
|
||||
}
|
||||
senku.msg(title, subTitle, detail)
|
||||
senku.done()
|
||||
})
|
||||
const url = {url: `https://group.baicizhan.com/group/apply_reward`, headers: {Cookie: cookieVal}}
|
||||
url.headers['Content-Type'] = `text/plain;charset=utf-8`
|
||||
url.headers['User-Agent'] = `Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/7.0.10(0x17000a21) NetType/4G Language/zh_CN`
|
||||
const key = {share_key: shareVal}
|
||||
url.body = JSON.stringify(key)
|
||||
senku.log(url.body)
|
||||
senku.post(url, (error, response, data) => {
|
||||
signinfo = JSON.parse(data)
|
||||
senku.log(JSON.stringify(signinfo))
|
||||
const title = `${cookieName}`
|
||||
let subTitle = ``
|
||||
let detail = ''
|
||||
if (signinfo.code == 1) {
|
||||
if (signinfo.data.is_new) {
|
||||
subTitle += `成功`
|
||||
detail = `获取铜板数${signinfo.data.reward[2]}`
|
||||
} else {
|
||||
subTitle += `今天的铜板已经领取,但是单词还是可以继续背的`
|
||||
}
|
||||
} else {
|
||||
detail = `状态: 还玩手机?快去背单词`
|
||||
subTitle += '失败'
|
||||
}
|
||||
senku.msg(title, subTitle, detail)
|
||||
senku.done()
|
||||
})
|
||||
}
|
||||
|
||||
function init() {
|
||||
isSurge = () => {
|
||||
return undefined === this.$httpClient ? false : true
|
||||
}
|
||||
isQuanX = () => {
|
||||
return undefined === this.$task ? false : true
|
||||
}
|
||||
getdata = (key) => {
|
||||
if (isSurge()) return $persistentStore.read(key)
|
||||
if (isQuanX()) return $prefs.valueForKey(key)
|
||||
}
|
||||
setdata = (key, val) => {
|
||||
if (isSurge()) return $persistentStore.write(key, val)
|
||||
if (isQuanX()) return $prefs.setValueForKey(key, val)
|
||||
}
|
||||
msg = (title, subtitle, body) => {
|
||||
if (isSurge()) $notification.post(title, subtitle, body)
|
||||
if (isQuanX()) $notify(title, subtitle, body)
|
||||
}
|
||||
log = (message) => console.log(message)
|
||||
get = (url, cb) => {
|
||||
if (isSurge()) {
|
||||
$httpClient.get(url, cb)
|
||||
isSurge = () => {
|
||||
return undefined === this.$httpClient ? false : true
|
||||
}
|
||||
if (isQuanX()) {
|
||||
url.method = 'GET'
|
||||
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
|
||||
isQuanX = () => {
|
||||
return undefined === this.$task ? false : true
|
||||
}
|
||||
}
|
||||
post = (url, cb) => {
|
||||
if (isSurge()) {
|
||||
$httpClient.post(url, cb)
|
||||
getdata = (key) => {
|
||||
if (isSurge()) return $persistentStore.read(key)
|
||||
if (isQuanX()) return $prefs.valueForKey(key)
|
||||
}
|
||||
if (isQuanX()) {
|
||||
url.method = 'POST'
|
||||
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
|
||||
setdata = (key, val) => {
|
||||
if (isSurge()) return $persistentStore.write(key, val)
|
||||
if (isQuanX()) return $prefs.setValueForKey(key, val)
|
||||
}
|
||||
}
|
||||
done = (value = {}) => {
|
||||
$done(value)
|
||||
}
|
||||
return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done }
|
||||
msg = (title, subtitle, body) => {
|
||||
if (isSurge()) $notification.post(title, subtitle, body)
|
||||
if (isQuanX()) $notify(title, subtitle, body)
|
||||
}
|
||||
log = (message) => console.log(message)
|
||||
get = (url, cb) => {
|
||||
if (isSurge()) {
|
||||
$httpClient.get(url, cb)
|
||||
}
|
||||
if (isQuanX()) {
|
||||
url.method = 'GET'
|
||||
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
|
||||
}
|
||||
}
|
||||
post = (url, cb) => {
|
||||
if (isSurge()) {
|
||||
$httpClient.post(url, cb)
|
||||
}
|
||||
if (isQuanX()) {
|
||||
url.method = 'POST'
|
||||
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
|
||||
}
|
||||
}
|
||||
done = (value = {}) => {
|
||||
$done(value)
|
||||
}
|
||||
return {isSurge, isQuanX, msg, log, getdata, setdata, get, post, done}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue