yz-yuki-plugin 2.0.9-0 → 2.0.9-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -34,7 +34,8 @@ class WeiboWebDataFetcher {
|
|
|
34
34
|
'Host': 'm.weibo.cn',
|
|
35
35
|
'X-XSRF-TOKEN': `${X_XSRF_TOKEN}`,
|
|
36
36
|
'Referer': `https://m.weibo.cn/u/${uid}`
|
|
37
|
-
})
|
|
37
|
+
}),
|
|
38
|
+
responseType: 'json'
|
|
38
39
|
});
|
|
39
40
|
// (3) 获取请求完成后的 Cookie 状态
|
|
40
41
|
const updatedCookies = await new Promise((resolve, reject) => {
|
|
@@ -83,7 +84,8 @@ class WeiboWebDataFetcher {
|
|
|
83
84
|
headers: lodash.merge(WeiboApi.WEIBO_HEADERS, {
|
|
84
85
|
'X-XSRF-TOKEN': `${X_XSRF_TOKEN}`,
|
|
85
86
|
'Referer': 'https://m.weibo.cn/search?'
|
|
86
|
-
})
|
|
87
|
+
}),
|
|
88
|
+
responseType: 'json'
|
|
87
89
|
});
|
|
88
90
|
// (3) 获取请求完成后的 Cookie 状态
|
|
89
91
|
const updatedCookies = await new Promise((resolve, reject) => {
|
|
@@ -135,7 +137,8 @@ class WeiboWebDataFetcher {
|
|
|
135
137
|
'Host': 'm.weibo.cn',
|
|
136
138
|
'X-XSRF-TOKEN': `${X_XSRF_TOKEN}`,
|
|
137
139
|
'referer': `https://m.weibo.cn/u/${uid}`
|
|
138
|
-
})
|
|
140
|
+
}),
|
|
141
|
+
responseType: 'json'
|
|
139
142
|
});
|
|
140
143
|
const { ok, data, msg } = response?.data;
|
|
141
144
|
if (!ok && msg !== '这里还没有内容') {
|
|
@@ -162,7 +165,7 @@ class WeiboWebDataFetcher {
|
|
|
162
165
|
await WeiboCookieManager.saveCookiesToRedis(jar); // 更新同步到 Redis
|
|
163
166
|
}
|
|
164
167
|
}
|
|
165
|
-
return data
|
|
168
|
+
return data?.cards.filter(WeiboQuery.filterCardTypeCustom);
|
|
166
169
|
}
|
|
167
170
|
catch (error) {
|
|
168
171
|
logger?.mark('微博推送:Error fetching sub list:', error);
|
|
@@ -153,54 +153,12 @@ class WeiboRiskCookie {
|
|
|
153
153
|
}
|
|
154
154
|
// 简单 fingerprint(可按需增强)
|
|
155
155
|
static buildSimpleFingerprint() {
|
|
156
|
-
const randFracInt = (base, min = 0.6, max = 1) => {
|
|
157
|
-
const v = min + Math.random() * (max - min); // 0.6-1
|
|
158
|
-
return Math.floor(base * v); // 换成 Math.round(...) 或 Math.ceil(...) 根据需要
|
|
159
|
-
};
|
|
160
156
|
return JSON.stringify({
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
'4': { s: -1, v: '' },
|
|
167
|
-
'5': { s: 1, v: 33 },
|
|
168
|
-
'6': { s: -1, v: '' },
|
|
169
|
-
'7': { s: 1, v: [['zh-CN'], ['zh-CN']] },
|
|
170
|
-
'8': { s: 1, v: true },
|
|
171
|
-
'9': { s: 1, v: 'default' },
|
|
172
|
-
'10': { s: 1, v: true },
|
|
173
|
-
'11': { s: 1, v: 5 },
|
|
174
|
-
'12': { s: -1, e: '' },
|
|
175
|
-
'13': { s: 1, v: '20030107' },
|
|
176
|
-
'14': { s: -1, e: '' },
|
|
177
|
-
'15': { s: 1, v: `${WeiboApi.USER_AGENT}` },
|
|
178
|
-
'16': { s: 1, v: { vendor: 'WebKit', renderer: 'WebKit WebGL' } },
|
|
179
|
-
'17': { s: -1, v: '' },
|
|
180
|
-
'18': {
|
|
181
|
-
s: 1,
|
|
182
|
-
v: { ow: randFracInt(2235, 0.6, 1), oh: randFracInt(1210, 0.6, 1), iw: randFracInt(589, 0.6, 1), ih: randFracInt(1089, 0.6, 1) }
|
|
183
|
-
},
|
|
184
|
-
'19': { s: 1, v: 'chrome' },
|
|
185
|
-
'20': { s: 1, v: 'webkit' },
|
|
186
|
-
'21': { s: 1, v: false },
|
|
187
|
-
'22': { s: 1, v: true },
|
|
188
|
-
'23': {
|
|
189
|
-
s: 1,
|
|
190
|
-
v: { ots: false, mtp: 0, mmtp: -1 }
|
|
191
|
-
}
|
|
192
|
-
},
|
|
193
|
-
bh: {
|
|
194
|
-
mt: [],
|
|
195
|
-
kt: {
|
|
196
|
-
down: 0,
|
|
197
|
-
up: 0
|
|
198
|
-
}
|
|
199
|
-
},
|
|
200
|
-
meta: {
|
|
201
|
-
isTraceKeyboard: false,
|
|
202
|
-
isTraceMouse: false
|
|
203
|
-
}
|
|
157
|
+
ua: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)',
|
|
158
|
+
platform: 'Win32',
|
|
159
|
+
screen: '1920x1080x24',
|
|
160
|
+
fonts: ['Arial', 'SimSun'],
|
|
161
|
+
plugins: []
|
|
204
162
|
});
|
|
205
163
|
}
|
|
206
164
|
// UMD 公钥 DER bytes(来自 1.2.1.umd.js 的 Uint8Array)
|
|
@@ -464,7 +422,7 @@ class WeiboRiskCookie {
|
|
|
464
422
|
const metaKey = `${key}:meta`;
|
|
465
423
|
const metaRaw = await Redis.get(metaKey);
|
|
466
424
|
const ttl = await Redis.ttl(key);
|
|
467
|
-
if (ttl > 0) {
|
|
425
|
+
if ((ttl && ttl > 0) || ttl === -1) {
|
|
468
426
|
await Redis.set(newKey, value, { EX: ttl });
|
|
469
427
|
if (metaRaw)
|
|
470
428
|
await Redis.set(`${newKey}:meta`, metaRaw, { EX: ttl });
|
|
@@ -561,13 +519,16 @@ class WeiboRiskCookie {
|
|
|
561
519
|
// 计算 TTL(秒)
|
|
562
520
|
let ttl = 0;
|
|
563
521
|
const ttlInMs = cookie.TTL ? cookie.TTL() : 0; // TTL 返回毫秒,可能不存在
|
|
564
|
-
if (ttlInMs > 0) {
|
|
522
|
+
if (ttlInMs && ttlInMs > 0 && isFinite(ttlInMs)) {
|
|
565
523
|
ttl = Math.floor(ttlInMs / 1000);
|
|
566
524
|
}
|
|
567
|
-
else if (ttlInMs === 0) {
|
|
525
|
+
else if (ttlInMs === 0 || !isFinite(ttlInMs)) {
|
|
568
526
|
// 已过期,跳过
|
|
569
527
|
continue;
|
|
570
528
|
}
|
|
529
|
+
else {
|
|
530
|
+
ttl = -1;
|
|
531
|
+
}
|
|
571
532
|
// 构造元数据
|
|
572
533
|
const meta = JSON.stringify({
|
|
573
534
|
path: cookie.path,
|
|
@@ -576,13 +537,13 @@ class WeiboRiskCookie {
|
|
|
576
537
|
});
|
|
577
538
|
// 写入 Redis(使用 TTL 时一并写 meta)
|
|
578
539
|
try {
|
|
579
|
-
if (ttl && ttl > 0) {
|
|
540
|
+
if ((ttl && ttl > 0) || ttl === -1) {
|
|
580
541
|
await Redis.set(redisKey, cookie.value, { EX: ttl });
|
|
581
542
|
await Redis.set(`${redisKey}:meta`, meta, { EX: ttl });
|
|
582
543
|
}
|
|
583
544
|
else {
|
|
584
|
-
await Redis.set(redisKey, cookie.value);
|
|
585
|
-
await Redis.set(`${redisKey}:meta`, meta);
|
|
545
|
+
await Redis.set(redisKey, cookie.value, { EX: -1 });
|
|
546
|
+
await Redis.set(`${redisKey}:meta`, meta, { EX: -1 });
|
|
586
547
|
}
|
|
587
548
|
}
|
|
588
549
|
catch (error) {
|