From 147b3b1507ebcdf5912fbd4c474c9dfb35265148 Mon Sep 17 00:00:00 2001 From: Igor Soarez Date: Fri, 6 Nov 2026 03:18:21 +0000 Subject: castle-search: read Brave again, and report genuine zero-hit searches as such Brave: #results no longer exists on the live page; fall back to #main/main. It was reported as 'no results area at all', i.e. a rate limit. DuckDuckGo: its 'No results found' notice is itself a .result, so an empty search looked like broken markup. emptyMarker lets the probe say the engine itself reported no matches, and the error tells the caller to loosen the query instead of switching engines. --- castle-search/src/extract.ts | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'castle-search/src/extract.ts') diff --git a/castle-search/src/extract.ts b/castle-search/src/extract.ts index 653942b..0284bb7 100644 --- a/castle-search/src/extract.ts +++ b/castle-search/src/extract.ts @@ -65,6 +65,8 @@ export type PageProbe = { * and worth telling apart when diagnosing a zero-hit search. */ container: "found" | "none"; + /** True when the engine's own "no matches" marker is on the page. */ + empty: boolean; results: SearchResult[]; }; @@ -279,6 +281,12 @@ export const buildProbeScript = (config: ExtractionConfig): string => String.raw var challenge = null; var results = []; var container = "none"; + var empty = false; + try { + empty = !!(CFG.emptyMarker && document.querySelector(CFG.emptyMarker)); + } catch (e) { + empty = false; + } try { challenge = detectChallenge(); } catch (e) { @@ -298,6 +306,7 @@ export const buildProbeScript = (config: ExtractionConfig): string => String.raw readyState: document.readyState, challenge: challenge, container: container, + empty: empty, results: results, }; })()`; -- cgit v1.2.3