yiyan-browser-agent 1.7.2 → 1.7.3
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/package.json +1 -1
- package/src/browser.js +11 -7
package/package.json
CHANGED
package/src/browser.js
CHANGED
|
@@ -444,11 +444,15 @@ class YiyanBrowser {
|
|
|
444
444
|
return result.trim();
|
|
445
445
|
}
|
|
446
446
|
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
447
|
+
// ── 优先:仅从 answer_text_id 提取内容 ──
|
|
448
|
+
const answerEl = document.querySelector('#answer_text_id');
|
|
449
|
+
if (answerEl) {
|
|
450
|
+
const t = getFullText(answerEl);
|
|
451
|
+
if (t.length > 0) return t;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
// ── 备用:其他选择器(仅当 answer_text_id 不存在时)──
|
|
455
|
+
const backupSelectors = [
|
|
452
456
|
'[class*="answer"]',
|
|
453
457
|
'[class*="response"]',
|
|
454
458
|
'[class*="message"][class*="content"]',
|
|
@@ -462,12 +466,12 @@ class YiyanBrowser {
|
|
|
462
466
|
'[class*="message-content"]:last-child',
|
|
463
467
|
];
|
|
464
468
|
|
|
465
|
-
for (const sel of
|
|
469
|
+
for (const sel of backupSelectors) {
|
|
466
470
|
try {
|
|
467
471
|
const els = document.querySelectorAll(sel);
|
|
468
472
|
if (els.length > 0) {
|
|
469
473
|
const t = getFullText(els[els.length - 1]);
|
|
470
|
-
if (t.length >
|
|
474
|
+
if (t.length > 5) return t;
|
|
471
475
|
}
|
|
472
476
|
} catch {}
|
|
473
477
|
}
|