Open-source AI browser agent for Chrome and Firefox (monorepo) 🧠
JavaScript ai-agentai-agentsai-toolsbrowser-aibrowser-automationbrowser-extensionchrome-aichrome-devtoolschrome-extensionchrome-extensionsfirefox-addonfirefox-addonsfirefox-extensionfirefox-extensionsgemmagemma4minimaxoffline-aioffline-llmqwen
feat: expand Baidu Tieba interaction adapter
16Miku8a93cc50cd47
diff --git a/src/chrome/src/agent/adapters.js b/src/chrome/src/agent/adapters.jsindex 7ac5b5366..8ccd3835d 100644--- a/src/chrome/src/agent/adapters.js+++ b/src/chrome/src/agent/adapters.js@@ -16173,8 +16173,9 @@ const ADAPTERS = [category: 'general',matches: isBaiduTiebaUrl,notes: `-- Tieba thread pages use a custom Vue action bar. On the first floor, the share, reply, like, and collect actions are icon-plus-count elements rather than native buttons; use the accessibility tree or interactive-element list and prefer the named "点赞" control over screenshot coordinates.-- Reply-level likes are separate "赞" controls in each comment row. Re-read the active post or comment container after scrolling, switching "只看楼主", or changing 热门/正序/倒序; indices and visible rows can change.+- Tieba thread pages use a custom Vue action bar. The first-floor转发、点赞、收藏和更多 controls are icon-based custom elements; the comment count remains a native link. Use the accessibility tree or interactive-element list and prefer semantic controls over screenshot coordinates.+- Reply rows expose separate "赞", "回复", and "更多" controls. Re-read the active post or comment container after scrolling, switching "只看楼主", or changing 热门/正序/倒序; indices and visible rows can change.+- The reply prompt and visible "关注楼主"/"关注本吧" controls may be custom wrappers; treat them as state-changing or login-gated actions and verify the resulting UI.- "点赞", "关注", "回复", and "发帖" change account or public state. Perform them only when explicitly requested, then verify the icon/count or resulting state; a successful mouse dispatch alone is not proof.- The first-floor action bar may be below the initial viewport, while images open a viewer when clicked. Do not click nearby image coordinates or repeat a coordinate after an unexpected viewer opens; close or go back, then re-read the page.- Public pages may require Baidu sign-in. If "登录", QR verification, or "百度安全验证" appears, stop for the user and do not bypass, retry, or claim that the requested action succeeded.`,diff --git a/src/chrome/src/cdp/cdp-client.js b/src/chrome/src/cdp/cdp-client.jsindex 19777eb55..a40f32d3d 100644--- a/src/chrome/src/cdp/cdp-client.js+++ b/src/chrome/src/cdp/cdp-client.js@@ -2921,8 +2921,16 @@ export class CDPClient {['.follow-button', '关注'], ['.send-btn', '发布评论'],['.publish-btn', '发布'], ['.publish-button', '发布'],] : onHost('tieba.baidu.com') ? [+ ['.pc-pb-first-floor-interactive .action-item', '转发', '#share_pb'],['.pc-pb-first-floor-interactive .action-item', '点赞', '#agree_pb'],+ ['.pc-pb-first-floor-interactive .action-item', '收藏', '#collect'],+ ['.pc-pb-first-floor-interactive .more-action', '更多', '#ellipsis'],['.pc-pb-comments-desc .zan-container-dark', '赞', '#agree_comment'],+ ['.pc-pb-comments-desc .reply-container', '回复', '#comment_comment'],+ ['.pc-pb-comments-desc .more-action', '更多', '#ellipsis_comment'],+ ['.follow-person-btn', '关注楼主'],+ ['.follow-forum-btn', '关注本吧'],+ ['.pc-pb-reply-box', '回复'],] : [];const SELECTORS = ['a[href]', 'button', 'input:not([type="hidden"])', 'textarea', 'select',diff --git a/src/chrome/src/content/accessibility-tree.js b/src/chrome/src/content/accessibility-tree.jsindex 5c94acce8..3e137b2cf 100644--- a/src/chrome/src/content/accessibility-tree.js+++ b/src/chrome/src/content/accessibility-tree.js@@ -158,8 +158,16 @@baiduTieba: [// Match the stable action wrapper, then inspect SVG href/xlink:href via// the DOM API because namespaced attribute selectors vary by engine.+ ['.pc-pb-first-floor-interactive .action-item', '转发', '#share_pb'],['.pc-pb-first-floor-interactive .action-item', '点赞', '#agree_pb'],+ ['.pc-pb-first-floor-interactive .action-item', '收藏', '#collect'],+ ['.pc-pb-first-floor-interactive .more-action', '更多', '#ellipsis'],['.pc-pb-comments-desc .zan-container-dark', '赞', '#agree_comment'],+ ['.pc-pb-comments-desc .reply-container', '回复', '#comment_comment'],+ ['.pc-pb-comments-desc .more-action', '更多', '#ellipsis_comment'],+ ['.follow-person-btn', '关注楼主'],+ ['.follow-forum-btn', '关注本吧'],+ ['.pc-pb-reply-box', '回复'],],};diff --git a/src/firefox/src/agent/adapters.js b/src/firefox/src/agent/adapters.jsindex 5b1e679a1..a98c4003e 100644--- a/src/firefox/src/agent/adapters.js+++ b/src/firefox/src/agent/adapters.js@@ -16172,8 +16172,9 @@ const ADAPTERS = [category: 'general',matches: isBaiduTiebaUrl,notes: `-- Tieba thread pages use a custom Vue action bar. On the first floor, the share, reply, like, and collect actions are icon-plus-count elements rather than native buttons; use the accessibility tree or interactive-element list and prefer the named "点赞" control over screenshot coordinates.-- Reply-level likes are separate "赞" controls in each comment row. Re-read the active post or comment container after scrolling, switching "只看楼主", or changing 热门/正序/倒序; indices and visible rows can change.+- Tieba thread pages use a custom Vue action bar. The first-floor转发、点赞、收藏和更多 controls are icon-based custom elements; the comment count remains a native link. Use the accessibility tree or interactive-element list and prefer semantic controls over screenshot coordinates.+- Reply rows expose separate "赞", "回复", and "更多" controls. Re-read the active post or comment container after scrolling, switching "只看楼主", or changing 热门/正序/倒序; indices and visible rows can change.+- The reply prompt and visible "关注楼主"/"关注本吧" controls may be custom wrappers; treat them as state-changing or login-gated actions and verify the resulting UI.- "点赞", "关注", "回复", and "发帖" change account or public state. Perform them only when explicitly requested, then verify the icon/count or resulting state; a successful mouse dispatch alone is not proof.- The first-floor action bar may be below the initial viewport, while images open a viewer when clicked. Do not click nearby image coordinates or repeat a coordinate after an unexpected viewer opens; close or go back, then re-read the page.- Public pages may require Baidu sign-in. If "登录", QR verification, or "百度安全验证" appears, stop for the user and do not bypass, retry, or claim that the requested action succeeded.`,diff --git a/src/firefox/src/content/accessibility-tree.js b/src/firefox/src/content/accessibility-tree.jsindex 5c94acce8..3e137b2cf 100644--- a/src/firefox/src/content/accessibility-tree.js+++ b/src/firefox/src/content/accessibility-tree.js@@ -158,8 +158,16 @@baiduTieba: [// Match the stable action wrapper, then inspect SVG href/xlink:href via// the DOM API because namespaced attribute selectors vary by engine.+ ['.pc-pb-first-floor-interactive .action-item', '转发', '#share_pb'],['.pc-pb-first-floor-interactive .action-item', '点赞', '#agree_pb'],+ ['.pc-pb-first-floor-interactive .action-item', '收藏', '#collect'],+ ['.pc-pb-first-floor-interactive .more-action', '更多', '#ellipsis'],['.pc-pb-comments-desc .zan-container-dark', '赞', '#agree_comment'],+ ['.pc-pb-comments-desc .reply-container', '回复', '#comment_comment'],+ ['.pc-pb-comments-desc .more-action', '更多', '#ellipsis_comment'],+ ['.follow-person-btn', '关注楼主'],+ ['.follow-forum-btn', '关注本吧'],+ ['.pc-pb-reply-box', '回复'],],};diff --git a/test/run.js b/test/run.jsindex 6494a6f99..381eb0515 100644--- a/test/run.js+++ b/test/run.js@@ -4601,7 +4601,7 @@ test('matches Baidu search surfaces without hijacking other Baidu products', ()assert.equal(firefoxAdapter?.notes, adapter?.notes);});-test('matches Baidu Tieba and exposes custom post like controls', () => {+test('matches Baidu Tieba and exposes custom post and reply controls', () => {const trustedUrls = ['https://tieba.baidu.com/','https://tieba.baidu.com/f?kw=python',@@ -4630,7 +4630,8 @@ test('matches Baidu Tieba and exposes custom post like controls', () => {const adapter = getActiveAdapter('https://tieba.baidu.com/p/11007201094?mo_device=1');assert.match(adapter?.notes || '', /custom Vue action bar/);- assert.match(adapter?.notes || '', /named "点赞" control/);+ assert.match(adapter?.notes || '', /semantic controls/);+ assert.match(adapter?.notes || '', /转发.*点赞.*收藏/s);assert.match(adapter?.notes || '', /百度安全验证/);assert.equal(getActiveAdapterFx('https://tieba.baidu.com/p/11007201094')?.notes, adapter?.notes);@@ -4645,8 +4646,14 @@ test('matches Baidu Tieba and exposes custom post like controls', () => {const context = { window: {}, location };vm.runInNewContext(axChrome.slice(start, end), context);const api = context.window.__wbSiteInteractions;- const likeSelector = '.pc-pb-first-floor-interactive .action-item';+ const firstFloorSelector = '.pc-pb-first-floor-interactive .action-item';+ const firstFloorMoreSelector = '.pc-pb-first-floor-interactive .more-action';const replyLikeSelector = '.pc-pb-comments-desc .zan-container-dark';+ const replySelector = '.pc-pb-comments-desc .reply-container';+ const replyMoreSelector = '.pc-pb-comments-desc .more-action';+ const followPersonSelector = '.follow-person-btn';+ const followForumSelector = '.follow-forum-btn';+ const replyBoxSelector = '.pc-pb-reply-box';const fakeElement = (selector, text, iconHref) => ({innerText: text,textContent: text,@@ -4656,11 +4663,25 @@ test('matches Baidu Tieba and exposes custom post like controls', () => {: [],getAttribute: () => null,});- assert.ok(api.selectors().includes(likeSelector));+ assert.ok(api.selectors().includes(firstFloorSelector));+ assert.ok(api.selectors().includes(firstFloorMoreSelector));assert.ok(api.selectors().includes(replyLikeSelector));- assert.equal(api.describe(fakeElement(likeSelector, '98', '#agree_pb')).name, '点赞 98');+ assert.ok(api.selectors().includes(replySelector));+ assert.ok(api.selectors().includes(replyMoreSelector));+ assert.ok(api.selectors().includes(followPersonSelector));+ assert.ok(api.selectors().includes(followForumSelector));+ assert.ok(api.selectors().includes(replyBoxSelector));+ assert.equal(api.describe(fakeElement(firstFloorSelector, '转发', '#share_pb')).name, '转发');+ assert.equal(api.describe(fakeElement(firstFloorSelector, '98', '#agree_pb')).name, '点赞 98');+ assert.equal(api.describe(fakeElement(firstFloorSelector, '5', '#collect')).name, '收藏 5');+ assert.equal(api.describe(fakeElement(firstFloorMoreSelector, '', '#ellipsis')).name, '更多');assert.equal(api.describe(fakeElement(replyLikeSelector, '21', '#agree_comment')).name, '赞 21');- assert.equal(api.describe(fakeElement(likeSelector, '37', '#comment_pb')), null);+ assert.equal(api.describe(fakeElement(replySelector, '回复', '#comment_comment')).name, '回复');+ assert.equal(api.describe(fakeElement(replyMoreSelector, '', '#ellipsis_comment')).name, '更多');+ assert.equal(api.describe(fakeElement(followPersonSelector, '关注楼主')).name, '关注楼主');+ assert.equal(api.describe(fakeElement(followForumSelector, '关注本吧')).name, '关注本吧');+ assert.equal(api.describe(fakeElement(replyBoxSelector, '想说点啥?')).name, '回复 想说点啥?');+ assert.equal(api.describe(fakeElement(firstFloorSelector, '14', '#comment_pb')), null);assert.equal(api.shouldPierceShadowRoots(), false);for (const [label, rel] of [@@ -4675,7 +4696,10 @@ test('matches Baidu Tieba and exposes custom post like controls', () => {const cdp = fs.readFileSync(path.join(ROOT, 'src/chrome/src/cdp/cdp-client.js'), 'utf8');assert.match(cdp, /onHost\('tieba\.baidu\.com'\)/);+ assert.match(cdp, /share_pb/);assert.match(cdp, /agree_pb/);+ assert.match(cdp, /collect/);+ assert.match(cdp, /comment_comment/);assert.match(cdp, /agree_comment/);assert.match(cdp, /matchesAnySiteSelector\(el\)[\s\S]*matchesSiteRule\(el, rule\)/);});