Repository navigation
Expand file tree
/
Copy pathmidu.cookie.js
More file actions
171 lines (165 loc) · 6.75 KB
/
Copy pathmidu.cookie.js
File metadata and controls
171 lines (165 loc) · 6.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
// 账号一
const readTimeheaderKey = 'senku_readTimeheader_midu'
const signbodyKey = 'senku_signbody_midu'
// 账号二
const readTimeheaderKey2 = 'senku_readTimeheader_midu2'
const signbodyKey2 = 'senku_signbody_midu2'
const senku = init()
const requrl = $request.url
if ($request && $request.method != 'OPTIONS' && requrl.match(/\/user\/readTimeBase\/readTime/)) {
try {
const readTimebodyVal = $request.body
const CookieValue = $request.headers
senku.log(`🍎${readTimebodyVal}`)
senku.log(`🍎${senku.getdata(readTimebodyKey)}`)
var account = senku.getdata('tokenMidu_read') ? senku.getdata('tokenMidu_read') : null
var account2 = senku.getdata('tokenMidu_read2') ? senku.getdata('tokenMidu_read2') : null
var tokenVal = CookieValue['token']
if (!account || tokenVal == account) {
var CookieName = '【账号一】'
var CookieKey = 'senku_readTimeheader_midu'
var tokenKey = 'tokenMidu_read'
var readTimebodyKey = 'senku_readTimebody_midu'
} else if (!account2 || tokenVal == account2) {
var CookieName = '【账号二】'
var CookieKey = 'senku_readTimeheader_midu2'
var tokenKey = 'tokenMidu_read2'
var readTimebodyKey = 'senku_readTimebody_midu2'
}
senku.log(`🍎${CookieName}`)
if (CookieName && senku.getdata(tokenKey)) {
if (senku.getdata(tokenKey) != tokenVal) {
var token = senku.setdata(tokenVal, tokenKey)
var header = senku.setdata(JSON.stringify(CookieValue), CookieKey)
var body = senku.setdata(readTimebodyVal, readTimebodyKey)
senku.setdata(readTimebodyVal, readTimebodyKey)
senku.log(`🔔${readTimebodyVal}`)
senku.log(`🔔${JSON.stringify(CookieValue)}`)
if (!token && !header && !body) {
senku.msg("米读", "阅读文章数据", "获取Cookie失败 ‼️")
senku.msg("米读", "阅读", "更新" + CookieName + "Cookie失败 ‼️")
} else {
senku.msg("米读", "阅读文章数据", "获取Cookie成功 🎉")
senku.msg("米读", "阅读", "更新" + CookieName + "Cookie成功 🎉")
}
}
} else if (CookieName) {
var token = senku.setdata(tokenVal, tokenKey)
var header = senku.setdata(CookieValue['tk'], CookieKey)
var body = senku.setdata(readTimebodyVal, readTimebodyKey)
senku.log(`🍎${tokenVal}`)
senku.log(`🔔${readTimebodyVal}`)
if (!header && !token && !body) {
senku.msg("米读", "阅读文章数据", "获取Cookie失败 ‼️")
senku.msg("米读", "阅读", "首次写入" + CookieName + "Cookie失败 ‼️")
} else {
senku.setdata('no', 'bind')
senku.msg("米读", "阅读文章数据", "获取Cookie成功 🎉")
senku.msg("米读", "阅读", "首次写入" + CookieName + "Cookie成功 🎉")
}
} else {
senku.msg("米读", "更新米读->阅读Cookie失败", '非历史写入账号 ‼️')
}
} catch (error) {
senku.log(`❌error:${error}`)
}
}
if ($request && $request.method != 'OPTIONS' && requrl.match(/\/wz\/dice\/index/)) {
try {
var CookieValue = $request.body
var account = senku.getdata('tokenMidu_sign') ? senku.getdata('tokenMidu_sign') : null
var account2 = senku.getdata('tokenMidu_sign2') ? senku.getdata('tokenMidu_sign2') : null
var tkVal = CookieValue.match(/token=[a-zA-Z0-9._-]+/)[0]
var tokenVal = tkVal.substring(6, tkVal.length)
if (!account || tokenVal == account) {
var CookieName = '【账号一】'
var CookieKey = 'senku_signbody_midu'
var tokenKey = 'tokenMidu_sign'
} else if (!account2 || tokenVal == account2) {
var CookieName = '【账号二】'
var CookieKey = 'senku_signbody_midu2'
var tokenKey = 'tokenMidu_sign2'
} else {
senku.msg("米读", "更新米读->签到Cookie失败", '非历史写入账号 ‼️')
}
senku.log(`🍎${senku.getdata(tokenKey)}`)
senku.log(`🍎${tokenVal}`)
if (senku.getdata(tokenKey)) {
if (senku.getdata(tokenKey) != tokenVal) {
var token = senku.setdata(tokenVal, tokenKey)
var body = senku.setdata(CookieValue, CookieKey)
if (!body && !token) {
senku.msg("米读", "签到", "更新" + CookieName + "Cookie失败 ‼️")
} else {
senku.msg("米读", "签到", "更新" + CookieName + "Cookie成功 🎉")
}
}
} else {
var token = senku.setdata(tokenVal, tokenKey)
var body = senku.setdata(CookieValue, CookieKey)
senku.log(`🍎${tokenVal}`)
if (!body && !token) {
senku.msg("米读", "签到", "首次写入" + CookieName + "Cookie失败 ‼️")
} else {
senku.setdata('no', 'bind')
senku.msg("米读", "签到", "首次写入" + CookieName + "Cookie成功 🎉")
}
}
} catch (error) {
senku.log(`❌error:${error}`)
}
}
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)
}
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()