Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions clis/doubao/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,13 @@ function getTurnsScript() {
// 2026-05 Doubao DOM refactor: no more receive-message / bg-g-receive-msg-bubble
// markers on assistant turns. Wrappers are now [class*="inner-item-"] /
// [class*="top-item-"] and the only reliable assistant signal is the
// .flow-markdown-body content container WITHOUT any send-bubble marker.
// .flow-markdown-body / .md-box-root content container WITHOUT any
// send-bubble marker.
if (
(root.matches('[class*="inner-item-"], [class*="top-item-"]')
|| root.closest('[class*="inner-item-"], [class*="top-item-"]'))
&& (root.matches('.flow-markdown-body') || root.querySelector('.flow-markdown-body'))
&& (root.matches('.flow-markdown-body, .md-box-root, [class*="md-box-root"]')
|| root.querySelector('.flow-markdown-body, .md-box-root, [class*="md-box-root"]'))
&& !root.matches('[class*="bg-g-send-msg-bubble"]')
&& !root.querySelector('[class*="bg-g-send-msg-bubble"]')
) {
Expand All @@ -189,6 +191,8 @@ function getTurnsScript() {
'[class*="bg-g-send-msg-bubble"]',
'[class*="bg-g-receive-msg-bubble"]',
'.flow-markdown-body',
'.md-box-root',
'[class*="md-box-root"]',
'[class*="bubble"]',
];
const messageImageSelector = messageTextSelectors.map((s) => s + ' img').join(', ');
Expand Down Expand Up @@ -232,7 +236,7 @@ function getTurnsScript() {
return text ? text + '\\n' + imageLines.join('\\n') : imageLines.join('\\n');
};

const messageList = document.querySelector('[class*="message-list-S2Fv2S"], .container-PvPoAn, .scroll-view-OEiNXD, [data-testid="message-list"]');
const messageList = document.querySelector('[class*="message-list-"], .container-PvPoAn, .scroll-view-OEiNXD, [data-testid="message-list"]');
if (!messageList) return [];

const itemSelectors = [
Expand Down
29 changes: 28 additions & 1 deletion clis/doubao/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ describe('doubao receive strategy', () => {

it('keeps both the new skin selectors and the older structural fallbacks in the turns script', () => {
const turnsScript = __test__.getTurnsScript();
expect(turnsScript).toContain('[class*="message-list-S2Fv2S"]');
expect(turnsScript).toContain('[class*="message-list-"]');
expect(turnsScript).toContain('.container-PvPoAn');
expect(turnsScript).toContain('[data-testid="message-list"]');
expect(turnsScript).toContain('[class*="bg-g-receive-msg-bubble"]');
Expand All @@ -191,6 +191,7 @@ describe('doubao receive strategy', () => {
// bg-g-receive-msg-bubble markup. Only signal is .flow-markdown-body content
// container without send-bubble.
expect(turnsScript).toContain('.flow-markdown-body');
expect(turnsScript).toContain('.md-box-root');
});

it('extracts clean assistant turns from the 2026-05 wrapper DOM without using whole-page chrome', () => {
Expand Down Expand Up @@ -218,6 +219,32 @@ describe('doubao receive strategy', () => {
]);
});

it('extracts turns from the current hashed message list and markdown box DOM', () => {
const turns = runTurnsScript(`
<main>
<aside>历史对话</aside>
<section class="message-list-zLoNs1 opacity-100">
<div class="top-item-bAlX0F"></div>
<div class="inner-item-BjaxFt">
<div data-message-id="46370507058831106" class="flex-row flex w-full justify-end">
<div class="bg-g-send-msg-bubble-bg">请联网查找太原红星天铂</div>
</div>
</div>
<div class="inner-item-BjaxFt">
<div data-message-id="46370507058842882" class="relative flex-row flex w-full">
<div class="container-qX9Csx md-box-root"><h3>太原红星天铂公开信息整理</h3><p>项目位于南内环东街与东中环交汇处东北角。</p></div>
</div>
</div>
</section>
</main>
`);

expect(turns).toEqual([
{ Role: 'User', Text: '请联网查找太原红星天铂' },
{ Role: 'Assistant', Text: '太原红星天铂公开信息整理项目位于南内环东街与东中环交汇处东北角。' },
]);
});

it('extends transcript-noise cleanup for the current zh-CN chrome copy', () => {
const transcriptScript = __test__.getTranscriptLinesScript();
expect(transcriptScript).toContain('请仔细甄别');
Expand Down