v3.6.6: search extraction parses both nestings (Bing a-in-h2, Google h3-in-a) so native web_search returns sources

This commit is contained in:
2026-11-08 23:35:23 +03:30
parent cb6c077541
commit 0cb2daa402
2 changed files with 14 additions and 12 deletions
+13 -11
View File
@@ -1370,22 +1370,24 @@ const FETCH_EXTRACT = `(async () => {
const SEARCH_EXTRACT = `(() => { const SEARCH_EXTRACT = `(() => {
const clean = (s) => String(s || '').replace(/\\s+/g, ' ').trim(); const clean = (s) => String(s || '').replace(/\\s+/g, ' ').trim();
const out = []; const seen = new Set(); const out = []; const seen = new Set();
// Engine-agnostic organic parse: a result headline is a heading inside a const selfUrl = (u) => /^https?:\\/\\/(?:www\\.)?(?:bing|google|duckduckgo)\\./i.test(u);
// link on Google and Bing alike — layout class names drift, this doesn't. // Organic result headlines come in both directions now: heading inside the
for (const a of document.querySelectorAll('a[href]')) { // link (Google: a > h3) AND link inside the heading (Bing: h2 > a). Match
const heading = a.querySelector('h2, h3'); // both — engine class names drift, the heading/link nesting does not.
if (!heading) continue; for (const node of document.querySelectorAll('h2 a, h3 a, a h2, a h3')) {
let url = a.href; if (out.length >= 20) break;
if (url.startsWith('/url?')) { const m = url.match(/[?&]url=([^&]+)/); if (m) { try { url = decodeURIComponent(m[1]); } catch {} } } const link = node.matches('a') ? node : node.closest('a');
if (!/^https?:/i.test(url) || seen.has(url)) continue; if (!link) continue;
const title = clean(heading.innerText); let url = link.href;
if (/^\\/(url|link)\\?/.test(url)) { const m = url.match(/[?&](?:url|q)=([^&]+)/); if (m) { try { url = decodeURIComponent(m[1]); } catch {} } }
if (!/^https?:/i.test(url) || seen.has(url) || selfUrl(url)) continue;
const title = clean(link.innerText);
if (!title || title.length < 4) continue; if (!title || title.length < 4) continue;
const box = a.closest('li,div.g,div.tF2Cxc,li.b_algo') || a.parentElement; const box = link.closest('li,div.g,div.tF2Cxc,li.b_algo,div.b_title,div[class*=result]') || link.parentElement;
let snippet = box ? clean(box.innerText) : ''; let snippet = box ? clean(box.innerText) : '';
if (snippet.startsWith(title)) snippet = snippet.slice(title.length).trim(); if (snippet.startsWith(title)) snippet = snippet.slice(title.length).trim();
seen.add(url); seen.add(url);
out.push({ url, title: title.slice(0, 200), ...(snippet ? { snippet: snippet.slice(0, 400) } : {}) }); out.push({ url, title: title.slice(0, 200), ...(snippet ? { snippet: snippet.slice(0, 400) } : {}) });
if (out.length >= 20) break;
} }
return { sources: out, page: { url: location.href, title: clean(document.title) } }; return { sources: out, page: { url: location.href, title: clean(document.title) } };
})()`; })()`;
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@local/edge-kit-easy", "name": "@local/edge-kit-easy",
"version": "3.6.5", "version": "3.6.6",
"private": true, "private": true,
"type": "module", "type": "module",
"description": "Edge Kit Browser — human-style browsing for agents in Edge, Chrome, or Firefox: see, click, type, video understanding, gameplay; live-attach-first over CDP/BiDi with a native settings page and the native web seam", "description": "Edge Kit Browser — human-style browsing for agents in Edge, Chrome, or Firefox: see, click, type, video understanding, gameplay; live-attach-first over CDP/BiDi with a native settings page and the native web seam",