MCPcopy Create free account
hub / github.com/ClydeTime/Surge / persistentStore

Function persistentStore

Script/Task/BiliBili.js:92–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90 (config.coins.num < exec_times * 10 && Math.floor(config.user.money) > 5)
91
92const persistentStore = async config => {
93 if (config.cookie.DedeUserID) {
94 const url = $request.url
95 config.key = url.match(/.*access_key=(.*?)&/)?.[1]
96 config.cookieStr = `DedeUserID=${config.cookie.DedeUserID}; DedeUserID__ckMd5=${config.cookie.DedeUserID__ckMd5}; SESSDATA=${config.cookie.SESSDATA}; bili_jct=${config.cookie.bili_jct}; sid=${config.cookie.sid}`
97 if (!config.key) { //网页方式登录
98 let auth_code = "0", access_key = "0", login_confirm = false
99 auth_code = await getAuthCode()
100 if (auth_code !== "0") login_confirm = await loginConfirm(auth_code)
101 if (login_confirm) access_key = await getAccessKey(auth_code)
102 if (access_key !== "0") {
103 config.key = access_key
104 } else {
105 $.log("- 获取用户access_key失败!")
106 $.msg($.name, "🤒获取用户access_key失败!")
107 }
108 }
109 const isFirstInsert = config.FirstInsert
110 delete config.FirstInsert
111 $.log($.toStr(config))
112 const successMessage = $.setItem($.name + "_daily_bonus", $.toStr(config))
113 ? "🎉cookie存储成功"
114 : "🤒cookie存储失败"
115 $.msg($.name, isFirstInsert ? "首次获取cookie" : "检测到cookie已更新", successMessage)
116 } else {
117 $.msg($.name, "- 尚未登录, 请登录后重新获取cookie")
118 }
119}
120
121const $ = new Env("bilibili")
122const startTime = format()

Callers 1

getCookieFunction · 0.85

Calls 7

getAuthCodeFunction · 0.85
loginConfirmFunction · 0.85
getAccessKeyFunction · 0.85
logMethod · 0.45
msgMethod · 0.45
toStrMethod · 0.45
setItemMethod · 0.45

Tested by

no test coverage detected