searchfetch 3.3.3 → 3.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,13 +1,13 @@
1
1
  # SearchFetch (MCP Server)
2
2
 
3
- A fault-tolerant, stealth-enabled Model Context Protocol (MCP) server for web searching and content fetching. Built for AI Agents (Cursor, Claude Code, OpenCode), it uses a stealth browser engine to fetch pages, dynamically handles SPAs/React, and converts bloat into token-optimized Markdown.
3
+ A fault-tolerant, stealth-enabled Model Context Protocol (MCP) server for web searching and content fetching. Built for AI Agents (Cursor, Claude Code, OpenCode), it uses a browser to render pages and converts their content into Markdown.
4
4
 
5
5
  ## Features
6
6
 
7
- - **Stealth Engine:** Powered by CloakBrowser C++ patches + `humanize` logic. The browser renders and moves like a real user, reducing bot-detection scores.
8
- - **Fault Tolerance:** Auto-healing browser sessions, grace-period timeouts for SPAs, and network-level blocking of tracking scripts and media.
7
+ - **Browser rendering:** CloakBrowser runs Chromium with humanized interactions. Sites can still require authentication or present challenges.
8
+ - **Fault tolerance:** Reconnects disconnected browsers, retries network failures and HTTP 429 once, and blocks template-selected resource types. HTTP errors are reported before waiting for rendering.
9
9
  - **Token-Optimized Output:** Strips base64 images, SVGs, scripts, and inline styles from the DOM _before_ Markdown conversion.
10
- - **Dual Runtime:** Natively supports zero-install execution via both Python (`uvx`) and Node.js (`npx`).
10
+ - **Dual runtime:** Run through Python (`uvx`, Python 3.10+) or Node.js (`npx`, Node 24+). First use downloads dependencies and a browser binary.
11
11
  - **Template-Driven Extraction:** Structured extraction via shared JSON templates (GitHub, npm, PyPI, crates.io, docs pages, Docker Hub, and more). Supports custom inline templates.
12
12
 
13
13
  ---
@@ -63,7 +63,7 @@ Search the web through the template pipeline. DuckDuckGo and Google are built-in
63
63
  | ------------- | ------------ | -------------- | ---------------------------------------------------------------------------------------------- |
64
64
  | `query` | string | _required_ | The search query string. |
65
65
  | `engine` | string | `"duckduckgo"` | `"duckduckgo"`, `"google"`, or a custom search template name. |
66
- | `max_results` | number | `10` | Maximum number of results to return. |
66
+ | `max_results` | number | `10` | Positive integer limit on extracted results. |
67
67
  | `region` | string/null | `null` | Region/language code (e.g. `"us-en"`, `"de-de"`). DDG maps directly; Google maps to `gl`/`hl`. |
68
68
  | `safe_search` | boolean/null | `null` | Enable safe search. `null` uses the template default. |
69
69
  | `block_media` | boolean | `true` | Block images, media, and fonts at the network layer. |
@@ -76,11 +76,11 @@ Fetch a page with the stealth browser and extract structured Markdown using a te
76
76
  | ------------- | ------- | ---------- | ----------------------------------------------------- |
77
77
  | `url` | string | _required_ | Full URL (must start with `http`/`https`). |
78
78
  | `template` | string | `"auto"` | `"auto"`, a built-in name, or inline JSON template. |
79
- | `start_index` | number | `0` | Character offset for pagination. |
80
- | `max_length` | number | `10000` | Maximum characters per request. |
79
+ | `start_index` | number | `0` | Nonnegative integer offset in Unicode code points. |
80
+ | `max_length` | number | `10000` | Positive integer limit in Unicode code points. |
81
81
  | `block_media` | boolean | `true` | Block images, videos, and fonts at the network layer. |
82
82
 
83
- Template extraction supports `text`, `markdown`, `attribute`, and `html` formats; nested children; repeated sections; URL-decoding transforms; per-template cookies; and per-template resource blocking.
83
+ Template extraction supports `text`, `markdown`, `attribute`, and `html` formats; child fields within a section; repeated sections; URL-decoding transforms; per-template cookies; and per-template resource blocking.
84
84
 
85
85
  Built-in templates live in `templates/*.json` and are shared by the Node.js and Python implementations.
86
86
 
@@ -97,8 +97,8 @@ Built-in templates live in `templates/*.json` and are shared by the Node.js and
97
97
 
98
98
  ```bash
99
99
  # Install dependencies
100
- npm install
101
- pip install -e ".[dev]"
100
+ npm ci
101
+ uv sync --locked --extra dev
102
102
 
103
103
  # Run tests
104
104
  npm test # runs all tests (JS + Python)
@@ -123,4 +123,20 @@ npm run inspector-py # test with MCP Inspector (Python)
123
123
 
124
124
  ## Architecture
125
125
 
126
- This repository uses a flat dual-manifest structure (`package.json` and `pyproject.toml` in the root). Both runtimes (`index.js` for Node, `server.py` for Python) share the same `templates/*.json` files and maintain feature parity.
126
+ Both MCP servers expose `websearch` and `webfetch` over standard input/output:
127
+
128
+ 1. Validate tool inputs and resolve a built-in or inline JSON template.
129
+ 2. Reuse one browser, creating an isolated browser context for each fetch attempt.
130
+ 3. Apply template cookies and resource blocking, navigate, check HTTP status, and allow up to five seconds for network activity to settle.
131
+ 4. Remove configured elements, extract section fields, apply transforms, and compose Markdown. Page templates may first try a raw Markdown source URL.
132
+ 5. Paginate page output using Unicode code points. Search requests can fall back from Google to DuckDuckGo HTML and then Lite; output names any fallback engine.
133
+
134
+ `index.js` and `server.py` contain the runtime-specific browser and MCP integration. `lib/` and `selectors_utils.py` hold focused formatting and selector helpers. Both runtimes read the same `templates/*.json`; Python wheels bundle these as `searchfetch_templates` resources. Shared fixtures in `tests/fixtures/` exercise extraction behavior in both runtimes.
135
+
136
+ Selectors separated by top-level commas are ordered fallbacks. Commas inside CSS functions or attributes are preserved; an empty fallback selects the current element. Child extraction searches descendants and enclosing elements, without borrowing fields from neighboring results. Missing required fields and malformed selectors report errors.
137
+
138
+ ## Verification and limits
139
+
140
+ `npm test`, `npm run lint`, and `npm run format:check` check both runtimes. `npm run e2e` runs real browser requests against local HTTP fixtures, exercises every built-in template, and checks the installed npm executable and Python wheel. Public search-engine availability and changing third-party page layouts require separate live checks. A page that continues rendering beyond the bounded wait may return partial content.
141
+
142
+ `package-lock.json` and `uv.lock` record dependency resolution.
package/index.js CHANGED
@@ -10,6 +10,8 @@ import { z } from "zod";
10
10
  import { launch, ensureBinary } from "cloakbrowser";
11
11
  import * as cheerio from "cheerio";
12
12
  import TurndownService from "turndown";
13
+ import { splitSelectors } from "./lib/selectors.js";
14
+ import { paginate } from "./lib/output.js";
13
15
 
14
16
  // === BROWSER MANAGER =====================================================
15
17
  class BrowserManager {
@@ -34,13 +36,10 @@ class BrowserManager {
34
36
  .then((browser) => {
35
37
  this.browser = browser;
36
38
  this.browser.on("disconnected", () => {
37
- this.browser = null;
39
+ if (this.browser === browser) this.browser = null;
38
40
  });
39
41
  return browser;
40
42
  })
41
- .catch((err) => {
42
- throw err;
43
- })
44
43
  .finally(() => {
45
44
  this.launchPromise = null;
46
45
  });
@@ -49,10 +48,9 @@ class BrowserManager {
49
48
  }
50
49
 
51
50
  async close() {
52
- if (this.browser) {
53
- await this.browser.close();
54
- this.browser = null;
55
- }
51
+ const browser = await (this.launchPromise ?? this.browser);
52
+ this.browser = null;
53
+ if (browser) await browser.close();
56
54
  }
57
55
  }
58
56
 
@@ -114,6 +112,24 @@ function loadBuiltinTemplates() {
114
112
 
115
113
  const BUILTIN_TEMPLATES = loadBuiltinTemplates();
116
114
 
115
+ function parseInlineTemplate(value) {
116
+ const template = JSON.parse(value);
117
+ if (
118
+ !template ||
119
+ typeof template !== "object" ||
120
+ Array.isArray(template) ||
121
+ !Array.isArray(template.sections)
122
+ ) {
123
+ throw new Error("Inline template must be an object with a sections array.");
124
+ }
125
+ template.name ??= "custom";
126
+ for (const section of template.sections) {
127
+ if (!section || typeof section.name !== "string")
128
+ throw new Error("Every section must have a name.");
129
+ }
130
+ return template;
131
+ }
132
+
117
133
  // === TEMPLATE LOOKUP =====================================================
118
134
  const TEMPLATE_MAP = new Map();
119
135
  for (const t of BUILTIN_TEMPLATES) {
@@ -148,48 +164,27 @@ function detectTemplateByUrl(url) {
148
164
 
149
165
  // === URL TEMPLATE RESOLUTION =============================================
150
166
 
167
+ function validateUrl(value) {
168
+ const url = new URL(value);
169
+ if (!["http:", "https:"].includes(url.protocol) || !url.hostname)
170
+ throw new Error("URL must use HTTP or HTTPS and include a hostname");
171
+ return value;
172
+ }
173
+
151
174
  function resolveUrlTemplate(template, providedParams) {
152
- const urlParams = template.url_params || {};
153
- let url = template.url_template;
154
- if (!url) return null;
155
-
156
- let match;
157
- const re = /\{(\w+)\}/g;
158
- while ((match = re.exec(url)) !== null) {
159
- const name = match[1];
160
- const def = urlParams[name] || {};
161
-
162
- let value;
163
- if (
164
- name in providedParams &&
165
- providedParams[name] !== null &&
166
- providedParams[name] !== undefined
167
- ) {
168
- value = String(providedParams[name]);
169
- } else if (def.default !== undefined) {
170
- value = String(def.default);
171
- } else if (def.required) {
175
+ if (!template.url_template) throw new Error(`Template '${template.name}' has no url_template.`);
176
+ return template.url_template.replace(/\{(\w+)\}/g, (_, name) => {
177
+ const def = template.url_params?.[name] ?? {};
178
+ let value = Object.hasOwn(providedParams, name) ? providedParams[name] : undefined;
179
+ value ??= def.default;
180
+ if (value == null && def.required) {
172
181
  throw new Error(
173
182
  `Required URL parameter '${name}' not provided for template '${template.name}'.`,
174
183
  );
175
- } else {
176
- value = "";
177
- }
178
-
179
- if (def.encode === "url") {
180
- value = encodeURIComponent(value);
181
184
  }
182
-
183
- url = url.replace(match[0], value);
184
- }
185
-
186
- // Remove any remaining unreplaced placeholders
187
- url = url
188
- .replace(/\{\w+\}/g, "")
189
- .replace(/&{2,}/g, "&")
190
- .replace(/\?&/, "?");
191
-
192
- return url;
185
+ value = String(value ?? "");
186
+ return def.encode === "url" ? encodeURIComponent(value) : value;
187
+ });
193
188
  }
194
189
 
195
190
  // === SEARCH PARAM MAPPING ================================================
@@ -216,8 +211,8 @@ function mapSearchParams(engine, query, region, safeSearch) {
216
211
  } else if (resolved === "google-search") {
217
212
  if (region !== null && region !== undefined) {
218
213
  const parts = region.split("-");
219
- params.hl = parts[0];
220
- params.gl = parts.length > 1 ? parts[1] : parts[0];
214
+ params.gl = parts[0];
215
+ if (parts.length > 1) params.hl = parts[1];
221
216
  }
222
217
  }
223
218
 
@@ -247,7 +242,7 @@ function parseRetryAfterMs(value) {
247
242
  }
248
243
 
249
244
  function makeHttpStatusError(status, url, retryAfterMs = null) {
250
- const err = new Error(`Access denied: HTTP ${status} when fetching ${url}`);
245
+ const err = new Error(`HTTP ${status} when fetching ${url}`);
251
246
  err.httpStatus = status;
252
247
  err.retryAfterMs = retryAfterMs;
253
248
  return err;
@@ -258,10 +253,8 @@ function isAccessDenied($) {
258
253
  const bodyText = ($("body").text() || "").replace(/\s+/g, " ").trim().toLowerCase();
259
254
 
260
255
  const titleDenyPatterns = [
261
- "captcha",
262
256
  "are you a robot",
263
257
  "access denied",
264
- "blocked",
265
258
  "forbidden",
266
259
  "unusual traffic",
267
260
  "sorry, you have been blocked",
@@ -269,7 +262,6 @@ function isAccessDenied($) {
269
262
  "one more step",
270
263
  "security check",
271
264
  "ddos protection",
272
- "cloudflare",
273
265
  ];
274
266
 
275
267
  if (titleDenyPatterns.some((pattern) => title.includes(pattern))) return true;
@@ -292,6 +284,7 @@ function isAccessDenied($) {
292
284
  }
293
285
 
294
286
  async function fetchHtml(url, template, blockMedia) {
287
+ validateUrl(url);
295
288
  const browser = await browserManager.getBrowser();
296
289
  const context = await browser.newContext();
297
290
 
@@ -315,37 +308,27 @@ async function fetchHtml(url, template, blockMedia) {
315
308
  await page.route("**/*", (route) => {
316
309
  const type = route.request().resourceType();
317
310
  if (blockedTypes.includes(type)) {
318
- route.abort();
311
+ return route.abort();
319
312
  } else {
320
- route.continue();
313
+ return route.continue();
321
314
  }
322
315
  });
323
316
  }
324
317
  }
325
318
 
326
- let response;
327
- try {
328
- response = await page.goto(url, {
329
- waitUntil: "networkidle",
330
- timeout: 15000,
331
- });
332
- } catch (_navError) {
333
- // Allow partial rendering on timeout only
334
- if (!_navError.message?.includes("timeout") && !_navError.message?.includes("Timeout")) {
335
- throw _navError;
336
- }
337
- }
338
-
339
- // Check HTTP status for access failures
340
- if (response) {
319
+ const response = await page.goto(url, { waitUntil: "domcontentloaded", timeout: 15000 });
320
+ if (response && response.status() >= 400) {
341
321
  const status = response.status();
342
- if ([401, 403, 429].includes(status)) {
343
- throw makeHttpStatusError(
344
- status,
345
- url,
346
- status === 429 ? parseRetryAfterMs(response.headers()["retry-after"]) : null,
347
- );
348
- }
322
+ throw makeHttpStatusError(
323
+ status,
324
+ url,
325
+ status === 429 ? parseRetryAfterMs(response.headers()["retry-after"]) : null,
326
+ );
327
+ }
328
+ try {
329
+ await page.waitForLoadState("networkidle", { timeout: 5000 });
330
+ } catch (err) {
331
+ if (err.name !== "TimeoutError") throw err;
349
332
  }
350
333
 
351
334
  const pageContent = await page.content();
@@ -380,7 +363,10 @@ async function fetchHtmlWithRetry(url, template, blockMedia) {
380
363
  }
381
364
  if (
382
365
  attempt < FETCH_MAX_ATTEMPTS - 1 &&
383
- (err.message.includes("net::") ||
366
+ (err.name === "TimeoutError" ||
367
+ err.message.includes("browser has been closed") ||
368
+ err.message.includes("Target closed") ||
369
+ err.message.includes("net::") ||
384
370
  err.message.includes("ERR_") ||
385
371
  err.message.includes("Navigation failed") ||
386
372
  err.message.includes("navigating"))
@@ -423,12 +409,16 @@ function stripSourceMarkdown(content) {
423
409
 
424
410
  function resolveSourceUrl(sourceTemplate, url) {
425
411
  if (sourceTemplate === "{url}.md") {
426
- return `${url.replace(/\/+$/, "")}.md`;
412
+ const parsed = new URL(url);
413
+ parsed.pathname = `${parsed.pathname.replace(/\/+$/, "")}.md`;
414
+ parsed.hash = "";
415
+ return parsed.href;
427
416
  }
428
417
  return sourceTemplate.replace("{url}", url);
429
418
  }
430
419
 
431
420
  async function fetchSourceMarkdown(sourceUrl, template, blockMedia) {
421
+ validateUrl(sourceUrl);
432
422
  const browser = await browserManager.getBrowser();
433
423
  const context = await browser.newContext();
434
424
 
@@ -447,8 +437,8 @@ async function fetchSourceMarkdown(sourceUrl, template, blockMedia) {
447
437
  if (blockedTypes.length > 0) {
448
438
  await page.route("**/*", (route) => {
449
439
  const type = route.request().resourceType();
450
- if (blockedTypes.includes(type)) route.abort();
451
- else route.continue();
440
+ if (blockedTypes.includes(type)) return route.abort();
441
+ else return route.continue();
452
442
  });
453
443
  }
454
444
  }
@@ -463,16 +453,11 @@ async function fetchSourceMarkdown(sourceUrl, template, blockMedia) {
463
453
  return null;
464
454
  }
465
455
 
466
- if (response && response.status() >= 400) return null;
467
-
468
- let text;
469
- try {
470
- text = await page.evaluate(
471
- "() => document.body?.innerText || document.body?.textContent || ''",
472
- );
473
- } catch (_) {
474
- text = await page.content();
475
- }
456
+ if (!response || response.status() >= 400) return null;
457
+ const contentType = (response.headers()["content-type"] ?? "").toLowerCase();
458
+ if (contentType.includes("text/html") || contentType.includes("application/xhtml+xml"))
459
+ return null;
460
+ let text = await response.text();
476
461
 
477
462
  if (!text || typeof text !== "string") return null;
478
463
 
@@ -502,10 +487,7 @@ const DEFAULT_REMOVE_SELECTORS = [
502
487
  ];
503
488
 
504
489
  function applyRemove($, template) {
505
- const removeSelectors =
506
- template && template.remove && template.remove.length > 0
507
- ? template.remove
508
- : DEFAULT_REMOVE_SELECTORS;
490
+ const removeSelectors = template?.remove ?? DEFAULT_REMOVE_SELECTORS;
509
491
 
510
492
  for (const selector of removeSelectors) {
511
493
  try {
@@ -528,77 +510,26 @@ function applyRemove($, template) {
528
510
 
529
511
  // === EXTRACTION ENGINE ===================================================
530
512
 
531
- /**
532
- * Find elements matching selector, scoped to $parent.
533
- * Search order: descendants → closest ancestor → ancestor subtrees (up to 4 levels).
534
- */
513
+ /** Search descendants and the enclosing element, never neighboring result subtrees. */
535
514
  function findScoped($parent, selector) {
536
- if (!selector || selector.trim() === "") {
537
- return $parent;
538
- }
539
-
540
- // 1. Descendants
541
- let result = $parent.find(selector);
542
- if (result.length > 0) return result;
543
-
544
- // 2. Closest ancestor matching selector
545
- result = $parent.closest(selector);
546
- if (result.length > 0) return result;
547
-
548
- // 3. Ancestor subtrees (up to 4 levels up)
549
- let ancestor = $parent.parent();
550
- for (let i = 0; i < 4 && ancestor.length > 0; i++) {
551
- result = ancestor.find(selector);
552
- if (result.length > 0) return result;
553
- ancestor = ancestor.parent();
554
- }
555
-
556
- return $parent.find("__nonexistent__");
515
+ if (!selector?.trim()) return $parent;
516
+ const descendants = $parent.find(selector);
517
+ return descendants.length ? descendants : $parent.closest(selector);
557
518
  }
558
519
 
559
- /**
560
- * Try comma-separated selectors in order; first match wins.
561
- */
562
520
  function findFirstMatch($parent, selectorStr) {
563
- if (!selectorStr || selectorStr.trim() === "") {
564
- return $parent;
565
- }
566
-
567
- const selectors = selectorStr
568
- .split(",")
569
- .map((s) => s.trim())
570
- .filter(Boolean);
571
-
572
- for (const sel of selectors) {
573
- const matches = findScoped($parent, sel);
574
- if (matches.length > 0) return matches;
521
+ for (const selector of splitSelectors(selectorStr)) {
522
+ const matches = findScoped($parent, selector);
523
+ if (matches.length) return matches;
575
524
  }
576
-
577
- return $parent.find("__nonexistent__");
525
+ return $parent.slice(0, 0);
578
526
  }
579
527
 
580
- /**
581
- * Resolve top-level elements for a section (document-wide with fallback).
582
- */
583
528
  function resolveTopElements($, selectorStr) {
584
- if (!selectorStr || selectorStr.trim() === "") {
585
- return $("body");
586
- }
587
-
588
- const selectors = selectorStr
589
- .split(",")
590
- .map((s) => s.trim())
591
- .filter(Boolean);
592
-
593
- for (const sel of selectors) {
594
- try {
595
- const matches = $(sel);
596
- if (matches.length > 0) return matches;
597
- } catch (_) {
598
- // Skip invalid selectors
599
- }
529
+ for (const selector of splitSelectors(selectorStr)) {
530
+ const matches = selector ? $(selector) : $("body");
531
+ if (matches.length) return matches;
600
532
  }
601
-
602
533
  return $();
603
534
  }
604
535
 
@@ -632,7 +563,7 @@ function applyTransform(value, transform, origin) {
632
563
  const queryString = result.split("?")[1] || "";
633
564
  const params = new URLSearchParams(queryString);
634
565
  const uddg = params.get("uddg");
635
- if (uddg) result = decodeURIComponent(uddg);
566
+ if (uddg) result = uddg;
636
567
  } catch (_) {
637
568
  // Leave as-is
638
569
  }
@@ -648,7 +579,7 @@ function applyTransform(value, transform, origin) {
648
579
  break;
649
580
 
650
581
  case "resolve_href":
651
- if (origin && result.startsWith("/") && !result.startsWith("//")) {
582
+ if (origin) {
652
583
  try {
653
584
  result = new URL(result, origin).href;
654
585
  } catch (_) {
@@ -735,19 +666,19 @@ function extractSection($, section, context) {
735
666
 
736
667
  // Determine limit
737
668
  let limit = elements.length;
738
- if (section.multiple && section.max_items) {
669
+ if (section.multiple && section.max_items != null) {
739
670
  limit = Math.min(limit, section.max_items);
740
671
  }
741
672
  // Override max_items with max_results for first multiple+children section
742
673
  if (
743
674
  context.isWebsearch &&
744
- context.maxResultsOverride &&
675
+ context.maxResultsOverride != null &&
745
676
  !context._maxResultsConsumed &&
746
677
  section.multiple &&
747
678
  section.children &&
748
679
  section.children.length > 0
749
680
  ) {
750
- limit = Math.min(limit, context.maxResultsOverride);
681
+ limit = Math.min(elements.length, context.maxResultsOverride);
751
682
  context._maxResultsConsumed = true;
752
683
  }
753
684
 
@@ -808,20 +739,8 @@ function extractTemplate($, template, context) {
808
739
  const results = [];
809
740
 
810
741
  for (const section of template.sections) {
811
- try {
812
- const result = extractSection($, section, context);
813
- if (result !== null) {
814
- results.push(result);
815
- }
816
- } catch (err) {
817
- // Required-section errors must surface to the user.
818
- if (err.message && err.message.includes("Required section")) {
819
- throw err;
820
- }
821
- // Non-required extraction failures: selector mismatches or format
822
- // processing issues. Broad templates legitimately don't match every
823
- // section on every page — skip and continue.
824
- }
742
+ const result = extractSection($, section, context);
743
+ if (result !== null) results.push(result);
825
744
  }
826
745
 
827
746
  return results;
@@ -829,13 +748,15 @@ function extractTemplate($, template, context) {
829
748
 
830
749
  // === COMPOSITION: WEBFETCH ===============================================
831
750
 
832
- function isCommentStyle(result) {
833
- if (!result.items || result.items.length === 0) return false;
834
- const first = result.items[0];
835
- const keys = Object.keys(first).map((k) => k.toLowerCase());
751
+ function isCommentStyle(items) {
752
+ if (!items || items.length === 0) return false;
753
+ // Ignore empty fields so Python's empty-string placeholders decide identically.
754
+ const keys = Object.entries(items[0])
755
+ .filter(([, value]) => String(value ?? "").trim())
756
+ .map(([key]) => key.toLowerCase());
836
757
  return (
837
- (keys.includes("author") && (keys.includes("comment") || keys.includes("body"))) ||
838
- (keys.includes("user") && (keys.includes("comment") || keys.includes("body")))
758
+ (keys.includes("author") || keys.includes("user")) &&
759
+ (keys.includes("comment") || keys.includes("body"))
839
760
  );
840
761
  }
841
762
 
@@ -850,7 +771,7 @@ function composeSections(extracted, template, startIndex, maxLength) {
850
771
  }
851
772
  } else if (result.type === "list") {
852
773
  if (result.items && result.items.length > 0) {
853
- const listText = result.items.map((item) => `- ${item}`).join("\n");
774
+ const listText = result.items.map((item) => `- ${String(item).trim()}`).join("\n");
854
775
  parts.push(`## ${result.section.name}\n\n${listText}`);
855
776
  }
856
777
  } else if (result.type === "children") {
@@ -863,12 +784,15 @@ function composeSections(extracted, template, startIndex, maxLength) {
863
784
  }
864
785
  } else if (result.type === "children-multiple") {
865
786
  if (result.items && result.items.length > 0) {
866
- if (isCommentStyle(result)) {
787
+ if (isCommentStyle(result.items)) {
867
788
  const commentParts = [];
868
789
  for (const item of result.items) {
869
- const author = item["Author"] || item["author"] || item["User"] || item["user"] || "";
870
- const comment =
871
- item["Comment"] || item["Body"] || item["comment"] || item["body"] || "";
790
+ const author = String(
791
+ item["Author"] || item["author"] || item["User"] || item["user"] || "",
792
+ ).trim();
793
+ const comment = String(
794
+ item["Comment"] || item["Body"] || item["comment"] || item["body"] || "",
795
+ ).trim();
872
796
  if (author) {
873
797
  commentParts.push(`**${author}:**\n\n${comment}`);
874
798
  } else if (comment) {
@@ -901,18 +825,7 @@ function composeSections(extracted, template, startIndex, maxLength) {
901
825
  return "(No content extracted from this page.)";
902
826
  }
903
827
 
904
- const full = parts.join("\n\n---\n\n");
905
- const totalLength = full.length;
906
- const paginated = full.substring(startIndex, startIndex + maxLength);
907
-
908
- const templateName = template ? template.name : "auto";
909
- let metadata = `\n\n---\n[webfetch: template="${templateName}", showing characters ${startIndex} to ${startIndex + paginated.length} of ${totalLength} total.`;
910
- if (startIndex + maxLength < totalLength) {
911
- metadata += ` Use start_index=${startIndex + maxLength} to read more.`;
912
- }
913
- metadata += `]`;
914
-
915
- return paginated + metadata;
828
+ return paginate(parts.join("\n\n---\n\n"), template?.name ?? "auto", startIndex, maxLength);
916
829
  }
917
830
 
918
831
  // === COMPOSITION: WEBSEARCH ==============================================
@@ -931,7 +844,7 @@ function composeSearchResults(extracted) {
931
844
 
932
845
  for (let i = 0; i < items.length; i++) {
933
846
  const item = items[i];
934
- const num = i + 1;
847
+ const num = parts.length + 1;
935
848
 
936
849
  const title = item["Title"] || item["title"] || Object.values(item)[0] || "";
937
850
  const url = item["URL"] || item["url"] || item["Url"] || "";
@@ -939,14 +852,17 @@ function composeSearchResults(extracted) {
939
852
 
940
853
  // Filter out non-http URLs and google internal links
941
854
  let cleanUrl = url;
942
- if (cleanUrl && !cleanUrl.startsWith("http")) {
943
- cleanUrl = ""; // Skip internal/non-web URLs
944
- }
945
- if (
946
- cleanUrl &&
947
- (cleanUrl.includes("google.com/search") || cleanUrl.includes("support.google.com"))
948
- ) {
949
- cleanUrl = ""; // Skip google internal links
855
+ try {
856
+ const parsed = new URL(cleanUrl);
857
+ if (
858
+ !["http:", "https:"].includes(parsed.protocol) ||
859
+ parsed.hostname === "support.google.com" ||
860
+ (["google.com", "www.google.com"].includes(parsed.hostname) &&
861
+ parsed.pathname === "/search")
862
+ )
863
+ cleanUrl = "";
864
+ } catch {
865
+ cleanUrl = "";
950
866
  }
951
867
 
952
868
  if (!title) continue;
@@ -980,16 +896,7 @@ function genericFallback($, startIndex, maxLength) {
980
896
  return "(No content extracted from this page.)";
981
897
  }
982
898
 
983
- const totalLength = markdown.length;
984
- const paginated = markdown.substring(startIndex, startIndex + maxLength);
985
-
986
- let metadata = `\n\n---\n[webfetch: template="auto (fallback)", showing characters ${startIndex} to ${startIndex + paginated.length} of ${totalLength} total.`;
987
- if (startIndex + maxLength < totalLength) {
988
- metadata += ` Use start_index=${startIndex + maxLength} to read more.`;
989
- }
990
- metadata += `]`;
991
-
992
- return paginated + metadata;
899
+ return paginate(markdown, "auto (fallback)", startIndex, maxLength);
993
900
  }
994
901
 
995
902
  // === SEARCH TEMPLATE RESOLUTION ==========================================
@@ -1000,7 +907,7 @@ function resolveSearchTemplate(engine, query, region, safeSearch) {
1000
907
  let template;
1001
908
  if (templateName.startsWith("{")) {
1002
909
  try {
1003
- template = JSON.parse(templateName);
910
+ template = parseInlineTemplate(templateName);
1004
911
  } catch (e) {
1005
912
  throw new Error(`Invalid inline JSON template: ${e.message}`);
1006
913
  }
@@ -1015,9 +922,11 @@ function resolveSearchTemplate(engine, query, region, safeSearch) {
1015
922
  const params = mapSearchParams(engine, query, region, safeSearch);
1016
923
  let url = resolveUrlTemplate(template, params);
1017
924
 
1018
- // Google safe_search: append safe=active to URL
1019
- if ((engine === "google" || templateName === "google-search") && safeSearch === true) {
1020
- url += "&safe=active";
925
+ // Set both explicit states; null preserves the template default.
926
+ if (templateName === "google-search" && safeSearch != null) {
927
+ const parsed = new URL(url);
928
+ parsed.searchParams.set("safe", safeSearch ? "active" : "off");
929
+ url = parsed.href;
1021
930
  }
1022
931
 
1023
932
  return { template, url };
@@ -1071,7 +980,7 @@ function resolveSearchCandidates(engine, query, region, safeSearch) {
1071
980
 
1072
981
  // === MCP SERVER & TOOLS ==================================================
1073
982
 
1074
- const server = new McpServer({ name: "searchfetch", version: "3.3.3" });
983
+ const server = new McpServer({ name: "searchfetch", version: "3.3.4" });
1075
984
 
1076
985
  // --- websearch tool ---
1077
986
 
@@ -1082,7 +991,7 @@ server.registerTool(
1082
991
  description:
1083
992
  "Search the web using DuckDuckGo or Google. Returns a clean list of titles, URLs, and snippets. Excellent for researching general knowledge, news, and finding URLs.",
1084
993
  inputSchema: z.object({
1085
- query: z.string().describe("The search query string."),
994
+ query: z.string().trim().min(1).describe("The search query string."),
1086
995
  engine: z
1087
996
  .string()
1088
997
  .default("duckduckgo")
@@ -1105,6 +1014,8 @@ server.registerTool(
1105
1014
  ),
1106
1015
  max_results: z
1107
1016
  .number()
1017
+ .int()
1018
+ .positive()
1108
1019
  .default(10)
1109
1020
  .describe("Maximum number of search results to return. Default is 10."),
1110
1021
  block_media: z
@@ -1128,7 +1039,7 @@ server.registerTool(
1128
1039
  const $ = cheerio.load(html);
1129
1040
  applyRemove($, candidate.template);
1130
1041
  extracted = extractTemplate($, candidate.template, {
1131
- origin: new URL(candidate.url).origin,
1042
+ origin: candidate.url,
1132
1043
  isWebsearch: true,
1133
1044
  maxResultsOverride: max_results,
1134
1045
  _maxResultsConsumed: false,
@@ -1174,6 +1085,11 @@ server.registerTool(
1174
1085
  inputSchema: z.object({
1175
1086
  url: z
1176
1087
  .string()
1088
+ .url()
1089
+ .refine(
1090
+ (value) => ["http:", "https:"].includes(new URL(value).protocol),
1091
+ "URL must use HTTP or HTTPS",
1092
+ )
1177
1093
  .describe("The full URL of the webpage to fetch (must start with http/https)."),
1178
1094
  template: z
1179
1095
  .string()
@@ -1185,9 +1101,16 @@ server.registerTool(
1185
1101
  "docker-hub, docs-rs, docs-page), 'raw' for minimal-filtering full-page output, " +
1186
1102
  "or inline JSON.",
1187
1103
  ),
1188
- start_index: z.number().default(0).describe("Character offset for pagination. Default: 0."),
1104
+ start_index: z
1105
+ .number()
1106
+ .int()
1107
+ .nonnegative()
1108
+ .default(0)
1109
+ .describe("Character offset for pagination. Default: 0."),
1189
1110
  max_length: z
1190
1111
  .number()
1112
+ .int()
1113
+ .positive()
1191
1114
  .default(10000)
1192
1115
  .describe("Maximum characters to return per request. Default is 10000."),
1193
1116
  block_media: z
@@ -1205,7 +1128,7 @@ server.registerTool(
1205
1128
 
1206
1129
  if (templateParam.startsWith("{")) {
1207
1130
  try {
1208
- template = JSON.parse(templateParam);
1131
+ template = parseInlineTemplate(templateParam);
1209
1132
  } catch (e) {
1210
1133
  throw new Error(`Invalid inline JSON template: ${e.message}`);
1211
1134
  }
@@ -1223,16 +1146,11 @@ server.registerTool(
1223
1146
  }
1224
1147
 
1225
1148
  if (sourceMd !== null) {
1226
- const totalLength = sourceMd.length;
1227
- const paginated = sourceMd.substring(start_index, start_index + max_length);
1228
- let metadata =
1229
- `\n\n---\n[webfetch: template="${template ? template.name : "auto"}" (source markdown), ` +
1230
- `showing characters ${start_index} to ${start_index + paginated.length} of ${totalLength} total.`;
1231
- if (start_index + max_length < totalLength) {
1232
- metadata += ` Use start_index=${start_index + max_length} to read more.`;
1233
- }
1234
- metadata += "]";
1235
- return { content: [{ type: "text", text: paginated + metadata }] };
1149
+ return {
1150
+ content: [
1151
+ { type: "text", text: paginate(sourceMd, template.name, start_index, max_length) },
1152
+ ],
1153
+ };
1236
1154
  }
1237
1155
 
1238
1156
  // 3. Fetch
@@ -1244,7 +1162,7 @@ server.registerTool(
1244
1162
  if (template) {
1245
1163
  applyRemove($, template);
1246
1164
 
1247
- const pageOrigin = new URL(url).origin;
1165
+ const pageOrigin = url;
1248
1166
  const context = {
1249
1167
  origin: pageOrigin,
1250
1168
  isWebsearch: false,
@@ -1270,6 +1188,9 @@ server.registerTool(
1270
1188
  // === EXPORTS (for testing without starting server) =========================
1271
1189
 
1272
1190
  export {
1191
+ BrowserManager,
1192
+ applyRemove,
1193
+ server,
1273
1194
  loadBuiltinTemplates,
1274
1195
  getTemplateByName,
1275
1196
  detectTemplateByUrl,
@@ -1333,10 +1254,14 @@ async function main() {
1333
1254
  process.on("SIGTERM", cleanup);
1334
1255
 
1335
1256
  const restoreStdout = redirectStartupOutputToStderr();
1336
- await ensureBinary();
1337
- restoreStdout();
1257
+ try {
1258
+ await ensureBinary();
1259
+ } finally {
1260
+ restoreStdout();
1261
+ }
1338
1262
  const transport = new StdioServerTransport();
1339
1263
  await server.connect(transport);
1264
+ process.stdin.once("end", cleanup);
1340
1265
  }
1341
1266
 
1342
1267
  // Guard: only start server when run directly (including via npm bin symlink),
@@ -1344,7 +1269,8 @@ async function main() {
1344
1269
  // symlinks resolve to the module file correctly.
1345
1270
  const isMain = isMainModule();
1346
1271
  if (isMain) {
1347
- main().catch((_err) => {
1272
+ main().catch((err) => {
1273
+ console.error(err);
1348
1274
  process.exit(1);
1349
1275
  });
1350
1276
  }
package/lib/output.js ADDED
@@ -0,0 +1,9 @@
1
+ /** Paginate Unicode code points so offsets agree with Python and never split a surrogate pair. */
2
+ export function paginate(text, templateName, startIndex, maxLength) {
3
+ const characters = Array.from(text);
4
+ const start = Math.min(startIndex, characters.length);
5
+ const page = characters.slice(start, start + maxLength);
6
+ const end = start + page.length;
7
+ const next = end < characters.length ? ` Use start_index=${end} to read more.` : "";
8
+ return `${page.join("")}\n\n---\n[webfetch: template="${templateName}", showing characters ${start} to ${end} of ${characters.length} total.${next}]`;
9
+ }
@@ -0,0 +1,27 @@
1
+ /** Split fallback selectors without breaking CSS functions, attributes, or escapes. */
2
+ export function splitSelectors(value = "") {
3
+ const selectors = [];
4
+ let start = 0;
5
+ let depth = 0;
6
+ let quote = null;
7
+ for (let i = 0; i < value.length; i++) {
8
+ const char = value[i];
9
+ if (char === "\\") {
10
+ i++;
11
+ continue;
12
+ }
13
+ if (quote) {
14
+ if (char === quote) quote = null;
15
+ continue;
16
+ }
17
+ if (char === '"' || char === "'") quote = char;
18
+ else if (char === "(" || char === "[") depth++;
19
+ else if (char === ")" || char === "]") depth--;
20
+ else if (char === "," && depth === 0) {
21
+ selectors.push(value.slice(start, i).trim());
22
+ start = i + 1;
23
+ }
24
+ }
25
+ selectors.push(value.slice(start).trim());
26
+ return selectors;
27
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "searchfetch",
3
- "version": "3.3.3",
3
+ "version": "3.3.4",
4
4
  "description": "Fault-tolerant MCP Server for Stealth Web Search and Fetching",
5
5
  "type": "module",
6
6
  "bin": {
@@ -8,7 +8,8 @@
8
8
  },
9
9
  "files": [
10
10
  "index.js",
11
- "templates/"
11
+ "templates/",
12
+ "lib/"
12
13
  ],
13
14
  "publishConfig": {
14
15
  "access": "public"
@@ -23,12 +24,12 @@
23
24
  "inspector-py": "npx @modelcontextprotocol/inspector uv run python ./server.py",
24
25
  "test": "npm run test:js && npm run test:py",
25
26
  "test:js": "node --test \"*.test.js\"",
26
- "test:py": "uv run --extra dev pytest test_*.py -v",
27
+ "test:py": "uv run --locked --extra dev pytest -q",
27
28
  "lint": "npm run lint:js && npm run lint:py",
28
- "lint:js": "npx eslint \"*.js\" \"scripts/*.mjs\"",
29
- "lint:py": "uv run --extra dev ruff check server.py scripts/*.py test_*.py",
30
- "format": "npx prettier --write \"*.js\" \"scripts/*.mjs\" \"*.json\" \"*.md\" && uv run --extra dev ruff format server.py scripts/*.py test_*.py",
31
- "format:check": "npx prettier --check \"*.js\" \"scripts/*.mjs\" \"*.json\" \"*.md\" && uv run --extra dev ruff format --check server.py scripts/*.py test_*.py",
29
+ "lint:js": "eslint . --max-warnings=0",
30
+ "lint:py": "uv run --locked --extra dev ruff check .",
31
+ "format": "prettier --write \"*.js\" \"lib/*.js\" \"scripts/*.mjs\" \"*.json\" \"templates/*.json\" \"*.md\" && uv run --locked --extra dev ruff format .",
32
+ "format:check": "prettier --check \"*.js\" \"lib/*.js\" \"scripts/*.mjs\" \"*.json\" \"templates/*.json\" \"*.md\" && uv run --locked --extra dev ruff format --check .",
32
33
  "e2e": "npm run e2e:node && npm run e2e:py",
33
34
  "e2e:node": "node scripts/e2e-node.mjs",
34
35
  "e2e:py": "uv run python scripts/e2e-python.py"
@@ -36,16 +37,16 @@
36
37
  "dependencies": {
37
38
  "@modelcontextprotocol/sdk": "^1.30.0",
38
39
  "cheerio": "^1.2.0",
39
- "cloakbrowser": "^0.5.5",
40
- "playwright-core": "^1.62.1",
40
+ "cloakbrowser": "^0.5.10",
41
+ "playwright-core": "^1.63.0",
41
42
  "turndown": "^7.2.4",
42
- "zod": "^4.4.3"
43
- },
44
- "overrides": {
45
- "encoding-sniffer": "1.0.2"
43
+ "zod": "^4.6.5"
46
44
  },
47
45
  "devDependencies": {
48
- "eslint": "^10.8.0",
46
+ "eslint": "^10.10.0",
49
47
  "prettier": "^3.9.6"
48
+ },
49
+ "engines": {
50
+ "node": ">=24.0.0"
50
51
  }
51
52
  }
@@ -0,0 +1 @@
1
+ """Built-in extraction templates distributed with SearchFetch."""
@@ -6,13 +6,7 @@
6
6
  "^https?://crates\\.io/crates/[^/]+/?$",
7
7
  "^https?://crates\\.io/crates/[^/]+/[^/]+/?$"
8
8
  ],
9
- "remove": [
10
- "script",
11
- "style",
12
- "svg",
13
- "nav",
14
- "footer"
15
- ],
9
+ "remove": ["script", "style", "svg", "nav", "footer"],
16
10
  "sections": [
17
11
  {
18
12
  "name": "Crate",
@@ -2,9 +2,7 @@
2
2
  "name": "devto",
3
3
  "description": "DEV Community article — title, author, and content",
4
4
  "order": 20,
5
- "url_patterns": [
6
- "^https?://dev\\.to/[^/]+/[^/]+"
7
- ],
5
+ "url_patterns": ["^https?://dev\\.to/[^/]+/[^/]+"],
8
6
  "remove": [
9
7
  "script",
10
8
  "style",
@@ -2,9 +2,7 @@
2
2
  "name": "duckduckgo-search",
3
3
  "description": "DuckDuckGo HTML search results",
4
4
  "order": 8,
5
- "url_patterns": [
6
- "^https?://html\\.duckduckgo\\.com/html/\\?"
7
- ],
5
+ "url_patterns": ["^https?://html\\.duckduckgo\\.com/html/\\?"],
8
6
  "url_template": "https://html.duckduckgo.com/html/?q={query}&kl={kl}&kp={kp}",
9
7
  "url_params": {
10
8
  "query": {
@@ -23,20 +21,8 @@
23
21
  "description": "Safe search: '-1' moderate, '1' strict, '-2' off"
24
22
  }
25
23
  },
26
- "block_resources": [
27
- "image",
28
- "media",
29
- "font",
30
- "stylesheet"
31
- ],
32
- "remove": [
33
- "script",
34
- "style",
35
- "svg",
36
- "img",
37
- "nav",
38
- "footer"
39
- ],
24
+ "block_resources": ["image", "media", "font", "stylesheet"],
25
+ "remove": ["script", "style", "svg", "img", "nav", "footer"],
40
26
  "sections": [
41
27
  {
42
28
  "name": "Results",
@@ -6,13 +6,7 @@
6
6
  "^https?://github\\.com/[^/]+/[^/]+/issues/\\d+/?$",
7
7
  "^https?://github\\.com/[^/]+/[^/]+/pull/\\d+/?$"
8
8
  ],
9
- "remove": [
10
- "script",
11
- "style",
12
- "svg",
13
- ".octicon",
14
- ".anchor"
15
- ],
9
+ "remove": ["script", "style", "svg", ".octicon", ".anchor"],
16
10
  "sections": [
17
11
  {
18
12
  "name": "Title",
@@ -2,16 +2,8 @@
2
2
  "name": "github-repo",
3
3
  "description": "GitHub repository root — file listing and README",
4
4
  "order": 1,
5
- "url_patterns": [
6
- "^https?://github\\.com/[^/]+/[^/]+/?$"
7
- ],
8
- "remove": [
9
- "script",
10
- "style",
11
- "svg",
12
- ".octicon",
13
- ".anchor"
14
- ],
5
+ "url_patterns": ["^https?://github\\.com/[^/]+/[^/]+/?$"],
6
+ "remove": ["script", "style", "svg", ".octicon", ".anchor"],
15
7
  "sections": [
16
8
  {
17
9
  "name": "Description",
@@ -2,9 +2,7 @@
2
2
  "name": "google-search",
3
3
  "description": "Google web search results",
4
4
  "order": 7,
5
- "url_patterns": [
6
- "^https?://(www\\.)?google\\.[^/]+/search\\?"
7
- ],
5
+ "url_patterns": ["^https?://(www\\.)?google\\.[^/]+/search\\?"],
8
6
  "url_template": "https://www.google.com/search?udm=14&q={query}&hl={hl}&gl={gl}",
9
7
  "url_params": {
10
8
  "query": {
@@ -31,20 +29,8 @@
31
29
  "path": "/"
32
30
  }
33
31
  ],
34
- "block_resources": [
35
- "image",
36
- "media",
37
- "font",
38
- "stylesheet"
39
- ],
40
- "remove": [
41
- "script",
42
- "style",
43
- "svg",
44
- "img",
45
- "nav",
46
- "footer"
47
- ],
32
+ "block_resources": ["image", "media", "font", "stylesheet"],
33
+ "remove": ["script", "style", "svg", "img", "nav", "footer"],
48
34
  "sections": [
49
35
  {
50
36
  "name": "Results",
@@ -54,7 +40,7 @@
54
40
  "children": [
55
41
  {
56
42
  "name": "Title",
57
- "selector": "h3, " ,
43
+ "selector": "h3, ",
58
44
  "format": "text"
59
45
  },
60
46
  {
@@ -2,9 +2,7 @@
2
2
  "name": "javadoc",
3
3
  "description": "Java SE API documentation — class/method details",
4
4
  "order": 8.5,
5
- "url_patterns": [
6
- "^https?://docs\\.oracle\\.com/.*/docs/api/.*"
7
- ],
5
+ "url_patterns": ["^https?://docs\\.oracle\\.com/.*/docs/api/.*"],
8
6
  "remove": [
9
7
  "script",
10
8
  "style",
@@ -2,9 +2,7 @@
2
2
  "name": "mdn-web-docs",
3
3
  "description": "MDN Web Docs article — title and main content",
4
4
  "order": 15,
5
- "url_patterns": [
6
- "^https?://developer\\.mozilla\\.org/.*"
7
- ],
5
+ "url_patterns": ["^https?://developer\\.mozilla\\.org/.*"],
8
6
  "remove": [
9
7
  "script",
10
8
  "style",
@@ -2,16 +2,8 @@
2
2
  "name": "npm-package",
3
3
  "description": "npm package page — metadata and README",
4
4
  "order": 3,
5
- "url_patterns": [
6
- "^https?://(www\\.)?npmjs\\.com/package/[^/]+/?$"
7
- ],
8
- "remove": [
9
- "script",
10
- "style",
11
- "svg",
12
- "nav",
13
- "footer"
14
- ],
5
+ "url_patterns": ["^https?://(www\\.)?npmjs\\.com/package/[^/]+/?$"],
6
+ "remove": ["script", "style", "svg", "nav", "footer"],
15
7
  "sections": [
16
8
  {
17
9
  "name": "Package",
@@ -6,13 +6,7 @@
6
6
  "^https?://pypi\\.org/project/[^/]+/?$",
7
7
  "^https?://pypi\\.org/project/[^/]+/[^/]+/?$"
8
8
  ],
9
- "remove": [
10
- "script",
11
- "style",
12
- "svg",
13
- "nav",
14
- "footer"
15
- ],
9
+ "remove": ["script", "style", "svg", "nav", "footer"],
16
10
  "sections": [
17
11
  {
18
12
  "name": "Package",
@@ -2,9 +2,7 @@
2
2
  "name": "reddit",
3
3
  "description": "Reddit post — title, content, and comments",
4
4
  "order": 13,
5
- "url_patterns": [
6
- "^https?://(?:www\\.|old\\.)?reddit\\.com/r/[^/]+/comments/[^/]+"
7
- ],
5
+ "url_patterns": ["^https?://(?:www\\.|old\\.)?reddit\\.com/r/[^/]+/comments/[^/]+"],
8
6
  "remove": [
9
7
  "script",
10
8
  "style",
@@ -2,9 +2,7 @@
2
2
  "name": "wikipedia",
3
3
  "description": "Wikipedia article — title and main content",
4
4
  "order": 11,
5
- "url_patterns": [
6
- "^https?://[a-z]{2,4}\\.wikipedia\\.org/wiki/[^:]+$"
7
- ],
5
+ "url_patterns": ["^https?://[a-z]{2,4}\\.wikipedia\\.org/wiki/[^:]+$"],
8
6
  "remove": [
9
7
  "script",
10
8
  "style",
@@ -2,9 +2,7 @@
2
2
  "name": "youtube",
3
3
  "description": "YouTube video — title, channel, description",
4
4
  "order": 30,
5
- "url_patterns": [
6
- "^https?://(?:www\\.)?(?:youtube\\.com/watch\\?v=|youtu\\.be/).+"
7
- ],
5
+ "url_patterns": ["^https?://(?:www\\.)?(?:youtube\\.com/watch\\?v=|youtu\\.be/).+"],
8
6
  "remove": [
9
7
  "script",
10
8
  "style",