docs: align qx repo with legacy layout

This commit is contained in:
2026-05-17 12:37:34 +08:00
parent de33953c3c
commit 295e6bd0de
6 changed files with 186 additions and 80 deletions
+71
View File
@@ -0,0 +1,71 @@
/*
* 启点读书 Cookie 自动获取/更新 - Quantumult X
* 只负责抓取 Cookie 并弹窗展示“复制给 Autman 机器人”的快速登录命令,不主动请求 Autman,也不本地持久化。
*
* 抓取:打开起点读书 App → 我的 → 福利中心。
* 抓到后会:
* 1. 解析 uid 用于弹窗标题
* 2. 通知/弹窗里展示完整快速登录命令 + CK,便于直接复制
*/
function getHeader(headers, name) {
const lower = String(name).toLowerCase()
for (const k in (headers || {})) if (String(k).toLowerCase() === lower) return headers[k]
return ''
}
function parseCookie(cookie) {
const jar = {}
String(cookie || '').split(';').forEach(part => {
const i = part.indexOf('=')
if (i <= 0) return
const k = part.slice(0, i).trim()
const v = part.slice(i + 1).trim()
if (k) jar[k] = v
})
return jar
}
function b64decode(s) {
try { return decodeURIComponent(escape(atob(String(s || '')))) } catch (e) { return '' }
}
function uidFromQDHeader(qdheader) {
const decoded = b64decode(qdheader)
return decoded ? String(decoded.split('|')[0] || '').trim() : ''
}
function parseJson(s, def) { try { return JSON.parse(s) } catch (e) { return def } }
function getUid(cookie, body) {
const jar = parseCookie(cookie)
let uid = uidFromQDHeader(jar.QDHeader || jar.qdheader || jar.QDHEADER || '')
if (uid) return uid
if (jar.uid) return String(jar.uid)
const obj = parseJson(body || '', null)
uid = obj && obj.Data && obj.Data.UserInfo && (obj.Data.UserInfo.UserId || obj.Data.UserInfo.userId)
return uid ? String(uid) : ''
}
function notify(title, sub, msg, opts) {
try { $notify(title, sub || '', msg || '', opts || {}) } catch (e) { $notify(title, sub || '', msg || '') }
}
function copyAction(command) {
return {
'open-url': 'shortcuts://run-shortcut?name=Copy&input=text&text=' + encodeURIComponent(command),
'media-url': 'data:text/plain;charset=utf-8,' + encodeURIComponent(command)
}
}
const cookie = getHeader($request && $request.headers, 'Cookie')
if (!cookie) {
notify('启点读书', 'Cookie 获取失败', '请求中没有 Cookie')
$done({})
} else {
const body = typeof $response !== 'undefined' ? ($response.body || '') : ''
const uid = getUid(cookie, body)
if (!uid) {
notify('启点读书', 'Cookie 获取失败', '无法识别 uid,请确认已登录并进入福利中心')
$done({})
} else {
// 发给 Autman 机器人的完整快速登录命令。Autman 插件保留“启点ck <cookie>”快速提交通道。
const submitText = `启点ck ${cookie}`
const msg = submitText
notify('启点读书', `抓取成功 uid:${uid}`, msg, copyAction(submitText))
$done({})
}
}