brave-real-browser-mcp-server 2.41.7 → 2.41.8

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.
@@ -27,11 +27,11 @@ const colors = {
27
27
  };
28
28
 
29
29
  const log = {
30
- info: (msg) => console.log(`${colors.blue}[ocr-captcha]${colors.reset} ${msg}`),
31
- success: (msg) => console.log(`${colors.green}[ocr-captcha]${colors.reset} ✅ ${msg}`),
32
- warn: (msg) => console.log(`${colors.yellow}[ocr-captcha]${colors.reset} ⚠️ ${msg}`),
33
- error: (msg) => console.log(`${colors.red}[ocr-captcha]${colors.reset} ❌ ${msg}`),
34
- debug: (msg) => console.log(`${colors.cyan}[ocr-captcha]${colors.reset} 🔍 ${msg}`)
30
+ info: (msg) => console.error(`${colors.blue}[ocr-captcha]${colors.reset} ${msg}`),
31
+ success: (msg) => console.error(`${colors.green}[ocr-captcha]${colors.reset} ✅ ${msg}`),
32
+ warn: (msg) => console.error(`${colors.yellow}[ocr-captcha]${colors.reset} ⚠️ ${msg}`),
33
+ error: (msg) => console.error(`${colors.red}[ocr-captcha]${colors.reset} ❌ ${msg}`),
34
+ debug: (msg) => console.error(`${colors.cyan}[ocr-captcha]${colors.reset} 🔍 ${msg}`)
35
35
  };
36
36
 
37
37
  // Common captcha character substitutions for correction
@@ -81,28 +81,28 @@ const PREPROCESS_CONFIGS = [
81
81
  */
82
82
  async function preprocessImageAdvanced(page, selector, config = {}) {
83
83
  const { threshold = 128, invert = false, removeLines = true } = config;
84
-
84
+
85
85
  return await page.evaluate(({ sel, threshold, invert, removeLines }) => {
86
86
  const img = document.querySelector(sel);
87
87
  if (!img) return null;
88
88
 
89
89
  const canvas = document.createElement('canvas');
90
90
  const ctx = canvas.getContext('2d');
91
-
91
+
92
92
  // Use natural dimensions for better quality
93
93
  const width = img.naturalWidth || img.width || 200;
94
94
  const height = img.naturalHeight || img.height || 50;
95
-
95
+
96
96
  canvas.width = width;
97
97
  canvas.height = height;
98
-
98
+
99
99
  // Draw original image
100
100
  ctx.drawImage(img, 0, 0, width, height);
101
-
101
+
102
102
  // Get image data
103
103
  const imageData = ctx.getImageData(0, 0, width, height);
104
104
  const data = imageData.data;
105
-
105
+
106
106
  // Step 1: Convert to grayscale
107
107
  for (let i = 0; i < data.length; i += 4) {
108
108
  const gray = 0.299 * data[i] + 0.587 * data[i + 1] + 0.114 * data[i + 2];
@@ -110,7 +110,7 @@ async function preprocessImageAdvanced(page, selector, config = {}) {
110
110
  data[i + 1] = gray;
111
111
  data[i + 2] = gray;
112
112
  }
113
-
113
+
114
114
  // Step 2: Remove diagonal lines (common in captchas)
115
115
  if (removeLines) {
116
116
  // Detect and remove thin lines
@@ -118,7 +118,7 @@ async function preprocessImageAdvanced(page, selector, config = {}) {
118
118
  for (let x = 1; x < width - 1; x++) {
119
119
  const idx = (y * width + x) * 4;
120
120
  const pixel = data[idx];
121
-
121
+
122
122
  // Check if this is a dark pixel
123
123
  if (pixel < threshold) {
124
124
  // Get surrounding pixels
@@ -126,14 +126,14 @@ async function preprocessImageAdvanced(page, selector, config = {}) {
126
126
  const bottom = data[((y + 1) * width + x) * 4];
127
127
  const left = data[(y * width + (x - 1)) * 4];
128
128
  const right = data[(y * width + (x + 1)) * 4];
129
-
129
+
130
130
  // Count dark neighbors
131
131
  let darkNeighbors = 0;
132
132
  if (top < threshold) darkNeighbors++;
133
133
  if (bottom < threshold) darkNeighbors++;
134
134
  if (left < threshold) darkNeighbors++;
135
135
  if (right < threshold) darkNeighbors++;
136
-
136
+
137
137
  // If isolated or thin line (≤2 dark neighbors), might be noise
138
138
  if (darkNeighbors <= 1) {
139
139
  // Make it white (remove noise)
@@ -145,22 +145,22 @@ async function preprocessImageAdvanced(page, selector, config = {}) {
145
145
  }
146
146
  }
147
147
  }
148
-
148
+
149
149
  // Step 3: Apply threshold (binarization)
150
150
  for (let i = 0; i < data.length; i += 4) {
151
151
  const gray = data[i];
152
152
  let bw = gray > threshold ? 255 : 0;
153
-
153
+
154
154
  // Invert if needed
155
155
  if (invert) bw = 255 - bw;
156
-
156
+
157
157
  data[i] = bw;
158
158
  data[i + 1] = bw;
159
159
  data[i + 2] = bw;
160
160
  }
161
-
161
+
162
162
  ctx.putImageData(imageData, 0, 0);
163
-
163
+
164
164
  return canvas.toDataURL('image/png');
165
165
  }, { sel: selector, threshold, invert, removeLines });
166
166
  }
@@ -178,7 +178,7 @@ async function getCaptchaImage(page, selector, preprocess = true, preprocessConf
178
178
  return processed;
179
179
  }
180
180
  }
181
-
181
+
182
182
  // Fallback: Screenshot of element
183
183
  const element = await page.$(selector);
184
184
  if (element) {
@@ -211,7 +211,7 @@ async function getCaptchaImage(page, selector, preprocess = true, preprocessConf
211
211
  */
212
212
  async function recognizeText(imageData, config = {}) {
213
213
  const worker = await Tesseract.createWorker(config.lang || 'eng');
214
-
214
+
215
215
  try {
216
216
  await worker.setParameters({
217
217
  tessedit_char_whitelist: config.tessedit_char_whitelist || DEFAULT_OCR_CONFIG.tessedit_char_whitelist,
@@ -219,12 +219,12 @@ async function recognizeText(imageData, config = {}) {
219
219
  });
220
220
 
221
221
  const { data } = await worker.recognize(imageData);
222
-
222
+
223
223
  // Clean up recognized text
224
224
  let text = data.text
225
225
  .replace(/\s+/g, '') // Remove whitespace
226
226
  .replace(/[^a-zA-Z0-9]/g, ''); // Keep only alphanumeric
227
-
227
+
228
228
  return {
229
229
  text,
230
230
  confidence: data.confidence,
@@ -259,17 +259,17 @@ async function solveTextCaptcha(page, selector, options = {}) {
259
259
 
260
260
  for (const preprocessConfig of configsToTry) {
261
261
  log.debug(`Trying preprocess config: ${preprocessConfig.name}`);
262
-
262
+
263
263
  // Get preprocessed image
264
264
  const imageData = await getCaptchaImage(page, selector, true, preprocessConfig);
265
-
265
+
266
266
  if (!imageData) {
267
267
  continue;
268
268
  }
269
269
 
270
270
  // Try different PSM modes
271
271
  const psmModes = ['7', '8', '13', '6']; // 7=single line, 8=word, 13=raw, 6=block
272
-
272
+
273
273
  for (let i = 0; i < Math.min(retries, psmModes.length); i++) {
274
274
  const config = {
275
275
  ...DEFAULT_OCR_CONFIG,
@@ -373,7 +373,7 @@ async function solveCaptchaAndFill(page, captchaSelector, inputSelector, options
373
373
 
374
374
  let attempts = 0;
375
375
  let lastResult = null;
376
-
376
+
377
377
  log.info(`Starting captcha solve with ${maxRefreshAttempts} max attempts`);
378
378
 
379
379
  while (attempts < maxRefreshAttempts) {
@@ -391,7 +391,7 @@ async function solveCaptchaAndFill(page, captchaSelector, inputSelector, options
391
391
  confidence: minConfidence,
392
392
  tryAllPreprocess: attempts <= 2, // Only try all configs on first 2 attempts
393
393
  });
394
-
394
+
395
395
  lastResult = result;
396
396
 
397
397
  // Check if we got a usable result
@@ -448,7 +448,7 @@ async function solveCaptchaAndFill(page, captchaSelector, inputSelector, options
448
448
  try {
449
449
  await page.click(submitSelector);
450
450
  await new Promise(r => setTimeout(r, 2000));
451
-
451
+
452
452
  // Check if captcha was wrong
453
453
  const stillOnPage = await page.$(captchaSelector);
454
454
  const errorVisible = await page.evaluate(() => {
@@ -491,7 +491,7 @@ async function solveCaptchaAndFill(page, captchaSelector, inputSelector, options
491
491
  */
492
492
  async function solveCaptchaFromUrl(imageUrl, options = {}) {
493
493
  log.info(`Solving captcha from URL: ${imageUrl}`);
494
-
494
+
495
495
  try {
496
496
  const result = await recognizeText(imageUrl, {
497
497
  ...DEFAULT_OCR_CONFIG,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brave-real-browser-mcp-server",
3
- "version": "2.41.7",
3
+ "version": "2.41.8",
4
4
  "description": "MCP Server for Brave Real Browser - Puppeteer with Brave Browser, Stealth Mode, Ad Blocker, and Turnstile Auto-Solver for undetectable web automation.",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/esm/index.mjs",
@@ -74,7 +74,7 @@
74
74
  "license": "ISC",
75
75
  "dependencies": {
76
76
  "@modelcontextprotocol/sdk": "^1.25.3",
77
- "brave-real-puppeteer-core": "^24.37.1-brave.6",
77
+ "brave-real-puppeteer-core": "^24.37.1-brave.7",
78
78
  "ghost-cursor": "^1.4.2",
79
79
  "puppeteer-extra": "^3.3.6",
80
80
  "puppeteer-extra-plugin-stealth": "^2.11.2",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brave-real-blocker",
3
- "version": "1.17.7",
3
+ "version": "1.17.8",
4
4
  "description": "Advanced uBlock Origin management and stealth features for Brave Real Browser",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -64,7 +64,7 @@
64
64
  "@types/adm-zip": "^0.5.5",
65
65
  "@types/fs-extra": "^11.0.4",
66
66
  "@types/node": "^20.0.0",
67
- "brave-real-puppeteer-core": "^24.37.1-brave.6",
67
+ "brave-real-puppeteer-core": "^24.37.1-brave.7",
68
68
  "mocha": "^10.4.0",
69
69
  "puppeteer-core": ">=24.0.0",
70
70
  "sinon": "^17.0.1",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brave-real-launcher",
3
- "version": "1.23.7",
3
+ "version": "1.23.8",
4
4
  "description": "Launch Brave Browser with ease from node. Based on chrome-launcher with Brave-specific support.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -54,7 +54,7 @@
54
54
  "typescript": "^5.0.0"
55
55
  },
56
56
  "dependencies": {
57
- "brave-real-blocker": "^1.17.7",
57
+ "brave-real-blocker": "^1.17.8",
58
58
  "escape-string-regexp": "^5.0.0",
59
59
  "is-wsl": "^3.1.0",
60
60
  "which": "^6.0.0"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brave-real-playwright-core",
3
- "version": "1.59.7",
3
+ "version": "1.59.8",
4
4
  "description": "Brave-optimized Playwright Core (v1.57.0) with comprehensive stealth patches and error stack sanitization",
5
5
  "keywords": [
6
6
  "playwright",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brave-real-puppeteer-core",
3
- "version": "24.37.1-brave.6",
3
+ "version": "24.37.1-brave.7",
4
4
  "description": "🦁 Brave Real-World Optimized Puppeteer & Playwright Core with 1-5ms ultra-fast timing, 50+ professional stealth features, intelligent browser auto-detection, and 100% bot detection bypass. Features cross-platform Brave browser integration, comprehensive anti-detection, and breakthrough performance improvements.",
5
5
  "keywords": [
6
6
  "automation",
@@ -134,7 +134,7 @@
134
134
  "test-version": "node ./scripts/test-version-management.js"
135
135
  },
136
136
  "dependencies": {
137
- "brave-real-launcher": "^1.23.7",
137
+ "brave-real-launcher": "^1.23.8",
138
138
  "get-east-asian-width": "^1.4.0",
139
139
  "yargs": "^18.0.0"
140
140
  },