koishi-plugin-xlon 1.0.1 → 1.0.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.
- package/lib/index.js +18 -8
- package/package.json +37 -37
package/lib/index.js
CHANGED
|
@@ -442,17 +442,27 @@ __name(buildVxApiUrl, "buildVxApiUrl");
|
|
|
442
442
|
async function screenshotTweetArticle(page, selector = 'article[data-testid="tweet"]') {
|
|
443
443
|
const element = await page.waitForSelector(selector, { timeout: 15e3 });
|
|
444
444
|
if (!element) throw new Error("未能找到推文容器");
|
|
445
|
-
await page.waitForFunction(
|
|
445
|
+
const mediaLoadResult = await page.waitForFunction(
|
|
446
446
|
(sel) => {
|
|
447
|
-
const
|
|
448
|
-
if (!
|
|
449
|
-
const imgs = Array.from(
|
|
450
|
-
|
|
447
|
+
const article = document.querySelector(sel);
|
|
448
|
+
if (!article) return false;
|
|
449
|
+
const imgs = Array.from(article.querySelectorAll("img"));
|
|
450
|
+
const imgsLoaded = imgs.every((img) => img.complete && img.naturalWidth > 0);
|
|
451
|
+
const videos = Array.from(article.querySelectorAll("video"));
|
|
452
|
+
const videosLoaded = videos.every((video) => video.readyState >= 2);
|
|
453
|
+
return imgsLoaded && videosLoaded;
|
|
451
454
|
},
|
|
452
|
-
{ timeout:
|
|
455
|
+
{ timeout: 2e4 },
|
|
456
|
+
// 增加到 20 秒
|
|
453
457
|
selector
|
|
454
|
-
).catch(() => {
|
|
458
|
+
).catch((err) => {
|
|
459
|
+
logger6.warn(`媒体加载超时: ${err.message}`);
|
|
460
|
+
return null;
|
|
455
461
|
});
|
|
462
|
+
if (!mediaLoadResult) {
|
|
463
|
+
logger6.warn("部分媒体可能未完全加载,额外等待 2 秒");
|
|
464
|
+
await page.evaluate(() => new Promise((resolve) => setTimeout(resolve, 2e3)));
|
|
465
|
+
}
|
|
456
466
|
await page.evaluate(() => {
|
|
457
467
|
const column = document.querySelector('div[data-testid="primaryColumn"]');
|
|
458
468
|
if (!column) return;
|
|
@@ -630,7 +640,7 @@ var XFetcher = class {
|
|
|
630
640
|
else req.continue();
|
|
631
641
|
});
|
|
632
642
|
await preparePage(page, this.config.cookies);
|
|
633
|
-
await page.goto(tweetUrl, { waitUntil: "
|
|
643
|
+
await page.goto(tweetUrl, { waitUntil: "networkidle2", timeout: 6e4 });
|
|
634
644
|
await page.waitForSelector("article", { timeout: 3e4 });
|
|
635
645
|
protectedAccount = await page.evaluate(() => {
|
|
636
646
|
return !!(document.querySelector('[data-testid="icon-lock"]') || document.querySelector('[aria-label*="rotect"]') || document.querySelector('[aria-label*="保护"]') || document.querySelector('[aria-label*="保護"]'));
|
package/package.json
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
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
|
-
"peerDependencies": {
|
|
31
|
-
"koishi": "^4.18.10"
|
|
32
|
-
},
|
|
33
|
-
"devDependencies": {
|
|
34
|
-
"koishi-plugin-puppeteer": "^3.9.0",
|
|
35
|
-
"typescript": "^5.9.3"
|
|
36
|
-
},
|
|
37
|
-
"dependencies": {
|
|
38
|
-
"yml-register": "^1.2.5"
|
|
2
|
+
"name": "koishi-plugin-xlon",
|
|
3
|
+
"description": "x subscriber",
|
|
4
|
+
"version": "1.0.2",
|
|
5
|
+
"contributors": [
|
|
6
|
+
"Logthm <logthm@outlook.com>"
|
|
7
|
+
],
|
|
8
|
+
"main": "lib/index.js",
|
|
9
|
+
"typings": "lib/index.d.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"lib",
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"keywords": [
|
|
16
|
+
"chatbot",
|
|
17
|
+
"koishi",
|
|
18
|
+
"plugin"
|
|
19
|
+
],
|
|
20
|
+
"koishi": {
|
|
21
|
+
"service": {
|
|
22
|
+
"required": [
|
|
23
|
+
"database"
|
|
24
|
+
],
|
|
25
|
+
"optional": [
|
|
26
|
+
"puppeteer"
|
|
27
|
+
]
|
|
39
28
|
}
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"koishi": "^4.18.11"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"koishi-plugin-puppeteer": "^3.9.0",
|
|
35
|
+
"typescript": "^5.9.3"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"yml-register": "^1.2.5"
|
|
39
|
+
}
|
|
40
40
|
}
|