fix: prefer qdreader qdheader embedded user id

This commit is contained in:
2026-05-17 17:17:45 +08:00
parent 11530c342d
commit c040ca40df
3 changed files with 23 additions and 4 deletions
+7 -2
View File
@@ -142,8 +142,13 @@ function isRealUid(uid) {
}
function uidFromQDHeader(qdheader) {
var decoded = b64decode(qdheader)
var uid = decoded ? trim(decoded.split("|")[0] || "") : ""
return isRealUid(uid)
if (!decoded) return ""
var parts = decoded.split("|").map(function (x) { return trim(x || "") })
for (var i = 0; i < [0, 11].length; i++) {
var uid = isRealUid(parts[[0, 11][i]])
if (uid) return uid
}
return ""
}
function extractUid(cookie) {
var jar = parseCookieString(cookie)
+7 -2
View File
@@ -142,8 +142,13 @@ function isRealUid(uid) {
}
function uidFromQDHeader(qdheader) {
var decoded = b64decode(qdheader)
var uid = decoded ? trim(decoded.split("|")[0] || "") : ""
return isRealUid(uid)
if (!decoded) return ""
var parts = decoded.split("|").map(function (x) { return trim(x || "") })
for (var i = 0; i < [0, 11].length; i++) {
var uid = isRealUid(parts[[0, 11][i]])
if (uid) return uid
}
return ""
}
function extractUid(cookie) {
var jar = parseCookieString(cookie)
+9
View File
@@ -73,6 +73,15 @@ test('manual cookie save falls back to ywguid when QDHeader uid is null', () =>
assert.equal(JSON.parse(r.store.qdreader_cookie_json)['54321'], fallbackCookie);
});
test('manual cookie save falls back to QDHeader embedded UserId before ywguid', () => {
const streamQdheader = 'KG51bGwpfChudWxsKXwxMTc5fDI1NTZ8KG51bGwpfDE2LjEwfDB8aU9TL2lQaG9uZS8obnVsbCl8MHwobnVsbCl8KG51bGwpfDQ3NTcwMDk3NXwxNzc5MDA5MTM2MDAwfDB8KG51bGwpfHx8KG51bGwpfChudWxsKXww';
const streamCookie = `QDHeader=${streamQdheader}; ywguid=120098575768; qdh=qdh; sessionyw=s; appId=12`;
const r = runPlugin({ content: '启点ck ' + streamCookie });
assert.match(r.replies.join('\n'), /CK新增成功/);
assert.match(r.replies.join('\n'), /uid: 475700975/);
assert.equal(JSON.parse(r.store.qdreader_cookie_json)['475700975'], streamCookie);
});
test('manual sign and cron sign both call sign gateway then qidian checkin', () => {
const store = { qdreader_cookie_json: JSON.stringify({ '12345': cookie }) };
const manual = runPlugin({ content: '启点签到', store: { ...store } });