diff --git a/index.js b/index.js index aea2219..a708141 100644 --- a/index.js +++ b/index.js @@ -1370,22 +1370,24 @@ const FETCH_EXTRACT = `(async () => { const SEARCH_EXTRACT = `(() => { const clean = (s) => String(s || '').replace(/\\s+/g, ' ').trim(); const out = []; const seen = new Set(); - // Engine-agnostic organic parse: a result headline is a heading inside a - // link on Google and Bing alike — layout class names drift, this doesn't. - for (const a of document.querySelectorAll('a[href]')) { - const heading = a.querySelector('h2, h3'); - if (!heading) continue; - let url = a.href; - if (url.startsWith('/url?')) { const m = url.match(/[?&]url=([^&]+)/); if (m) { try { url = decodeURIComponent(m[1]); } catch {} } } - if (!/^https?:/i.test(url) || seen.has(url)) continue; - const title = clean(heading.innerText); + const selfUrl = (u) => /^https?:\\/\\/(?:www\\.)?(?:bing|google|duckduckgo)\\./i.test(u); + // Organic result headlines come in both directions now: heading inside the + // link (Google: a > h3) AND link inside the heading (Bing: h2 > a). Match + // both — engine class names drift, the heading/link nesting does not. + for (const node of document.querySelectorAll('h2 a, h3 a, a h2, a h3')) { + if (out.length >= 20) break; + const link = node.matches('a') ? node : node.closest('a'); + if (!link) continue; + 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; - 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) : ''; if (snippet.startsWith(title)) snippet = snippet.slice(title.length).trim(); seen.add(url); 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) } }; })()`; diff --git a/package.json b/package.json index efebdb6..1b84acd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@local/edge-kit-easy", - "version": "3.6.5", + "version": "3.6.6", "private": true, "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",