brave-real-browser-mcp-server 2.10.0 ā 2.11.0
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.
|
@@ -387,12 +387,20 @@ export async function handleNetworkRecordingFinder(args) {
|
|
|
387
387
|
const page = getCurrentPage();
|
|
388
388
|
const duration = args.duration || 10000;
|
|
389
389
|
const filterType = args.filterType || 'video'; // video, audio, media
|
|
390
|
+
const navigateTo = args.navigateTo; // Optional URL to navigate to
|
|
391
|
+
const verbose = args.verbose !== false; // Default true for detailed logging
|
|
390
392
|
const recordings = [];
|
|
393
|
+
let totalResponses = 0;
|
|
394
|
+
let matchedResponses = 0;
|
|
391
395
|
const responseHandler = async (response) => {
|
|
392
396
|
try {
|
|
397
|
+
totalResponses++;
|
|
393
398
|
const url = response.url();
|
|
394
399
|
const contentType = response.headers()['content-type'] || '';
|
|
395
400
|
const resourceType = response.request().resourceType();
|
|
401
|
+
if (verbose && totalResponses % 10 === 0) {
|
|
402
|
+
console.log(`[Network Recording] Processed ${totalResponses} responses, ${matchedResponses} matched`);
|
|
403
|
+
}
|
|
396
404
|
let shouldRecord = false;
|
|
397
405
|
if (filterType === 'video' && (contentType.includes('video') || resourceType === 'media')) {
|
|
398
406
|
shouldRecord = true;
|
|
@@ -404,6 +412,10 @@ export async function handleNetworkRecordingFinder(args) {
|
|
|
404
412
|
shouldRecord = true;
|
|
405
413
|
}
|
|
406
414
|
if (shouldRecord) {
|
|
415
|
+
matchedResponses++;
|
|
416
|
+
if (verbose) {
|
|
417
|
+
console.log(`[Network Recording] ā
Matched ${filterType}: ${url.substring(0, 100)}`);
|
|
418
|
+
}
|
|
407
419
|
try {
|
|
408
420
|
const buffer = await response.buffer();
|
|
409
421
|
recordings.push({
|
|
@@ -428,21 +440,33 @@ export async function handleNetworkRecordingFinder(args) {
|
|
|
428
440
|
// Ignore individual response errors
|
|
429
441
|
}
|
|
430
442
|
};
|
|
443
|
+
console.log(`[Network Recording] š¬ Starting monitoring for ${filterType} (${duration}ms)${navigateTo ? ` + navigating to ${navigateTo}` : ''}`);
|
|
431
444
|
page.on('response', responseHandler);
|
|
445
|
+
// If navigateTo is provided, navigate first, then wait
|
|
446
|
+
if (navigateTo) {
|
|
447
|
+
try {
|
|
448
|
+
await page.goto(navigateTo, { waitUntil: 'networkidle2', timeout: 30000 });
|
|
449
|
+
console.log(`[Network Recording] ā
Navigation complete, continuing monitoring...`);
|
|
450
|
+
}
|
|
451
|
+
catch (e) {
|
|
452
|
+
console.log(`[Network Recording] ā ļø Navigation error (continuing anyway): ${e}`);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
432
455
|
await sleep(duration);
|
|
433
456
|
page.off('response', responseHandler);
|
|
457
|
+
console.log(`[Network Recording] š Monitoring stopped. Total: ${totalResponses}, Matched: ${matchedResponses}, Recorded: ${recordings.length}`);
|
|
434
458
|
if (recordings.length === 0) {
|
|
435
459
|
return {
|
|
436
460
|
content: [{
|
|
437
461
|
type: 'text',
|
|
438
|
-
text: `ā¹ļø No ${filterType} recordings found
|
|
462
|
+
text: `ā¹ļø No ${filterType} recordings found\n\nš Statistics:\n ⢠Total responses checked: ${totalResponses}\n ⢠Matched ${filterType} responses: ${matchedResponses}\n ⢠Duration: ${duration}ms\n ⢠Navigation: ${navigateTo || 'None'}\n\nš” Suggestions:\n ${navigateTo ? '⢠Try longer duration if page loads slowly\n ⢠Check if page actually has video/media content' : '⢠Use navigateTo parameter to capture requests during page load\n ⢠Example: {"navigateTo": "https://example.com", "duration": 15000}'}\n ⢠Consider 'advanced_video_extraction' for analyzing loaded content`,
|
|
439
463
|
}],
|
|
440
464
|
};
|
|
441
465
|
}
|
|
442
466
|
return {
|
|
443
467
|
content: [{
|
|
444
468
|
type: 'text',
|
|
445
|
-
text: `ā
Network Recordings Found: ${recordings.length}\n\n${JSON.stringify(recordings, null, 2)}`,
|
|
469
|
+
text: `ā
Network Recordings Found: ${recordings.length}\n\nš Statistics:\n ⢠Total responses: ${totalResponses}\n ⢠Matched: ${matchedResponses}\n ⢠Recorded: ${recordings.length}\n\n${JSON.stringify(recordings, null, 2)}`,
|
|
446
470
|
}],
|
|
447
471
|
};
|
|
448
472
|
}
|
|
@@ -476,18 +500,24 @@ export async function handleNetworkRecordingExtractors(args) {
|
|
|
476
500
|
}
|
|
477
501
|
const page = getCurrentPage();
|
|
478
502
|
const duration = args.duration || 10000;
|
|
503
|
+
const navigateTo = args.navigateTo; // Optional URL to navigate to
|
|
504
|
+
const verbose = args.verbose !== false; // Default true
|
|
479
505
|
const extractedData = {
|
|
480
506
|
videos: [],
|
|
481
507
|
audio: [],
|
|
482
508
|
manifests: [],
|
|
483
509
|
apis: [],
|
|
484
510
|
};
|
|
511
|
+
let totalResponses = 0;
|
|
485
512
|
const responseHandler = async (response) => {
|
|
513
|
+
totalResponses++;
|
|
486
514
|
const url = response.url();
|
|
487
515
|
const contentType = response.headers()['content-type'] || '';
|
|
488
516
|
try {
|
|
489
517
|
// Video files
|
|
490
518
|
if (contentType.includes('video') || url.includes('.mp4') || url.includes('.webm')) {
|
|
519
|
+
if (verbose)
|
|
520
|
+
console.log(`[Extractor] š„ Video found: ${url.substring(0, 80)}`);
|
|
491
521
|
extractedData.videos.push({
|
|
492
522
|
url,
|
|
493
523
|
contentType,
|
|
@@ -496,6 +526,8 @@ export async function handleNetworkRecordingExtractors(args) {
|
|
|
496
526
|
}
|
|
497
527
|
// Audio files
|
|
498
528
|
if (contentType.includes('audio') || url.includes('.mp3') || url.includes('.m4a')) {
|
|
529
|
+
if (verbose)
|
|
530
|
+
console.log(`[Extractor] šµ Audio found: ${url.substring(0, 80)}`);
|
|
499
531
|
extractedData.audio.push({
|
|
500
532
|
url,
|
|
501
533
|
contentType,
|
|
@@ -503,6 +535,8 @@ export async function handleNetworkRecordingExtractors(args) {
|
|
|
503
535
|
}
|
|
504
536
|
// Manifest files (HLS, DASH)
|
|
505
537
|
if (url.includes('.m3u8') || url.includes('.mpd')) {
|
|
538
|
+
if (verbose)
|
|
539
|
+
console.log(`[Extractor] š Manifest found: ${url.substring(0, 80)}`);
|
|
506
540
|
const text = await response.text();
|
|
507
541
|
extractedData.manifests.push({
|
|
508
542
|
url,
|
|
@@ -512,6 +546,8 @@ export async function handleNetworkRecordingExtractors(args) {
|
|
|
512
546
|
}
|
|
513
547
|
// API responses with video data
|
|
514
548
|
if (contentType.includes('json') && (url.includes('video') || url.includes('media'))) {
|
|
549
|
+
if (verbose)
|
|
550
|
+
console.log(`[Extractor] š” API found: ${url.substring(0, 80)}`);
|
|
515
551
|
const json = await response.json();
|
|
516
552
|
extractedData.apis.push({
|
|
517
553
|
url,
|
|
@@ -523,23 +559,35 @@ export async function handleNetworkRecordingExtractors(args) {
|
|
|
523
559
|
// Response not available
|
|
524
560
|
}
|
|
525
561
|
};
|
|
562
|
+
console.log(`[Extractor] š¬ Starting extraction (${duration}ms)${navigateTo ? ` + navigating to ${navigateTo}` : ''}`);
|
|
526
563
|
page.on('response', responseHandler);
|
|
564
|
+
// If navigateTo is provided, navigate first, then wait
|
|
565
|
+
if (navigateTo) {
|
|
566
|
+
try {
|
|
567
|
+
await page.goto(navigateTo, { waitUntil: 'networkidle2', timeout: 30000 });
|
|
568
|
+
console.log(`[Extractor] ā
Navigation complete, continuing extraction...`);
|
|
569
|
+
}
|
|
570
|
+
catch (e) {
|
|
571
|
+
console.log(`[Extractor] ā ļø Navigation error (continuing): ${e}`);
|
|
572
|
+
}
|
|
573
|
+
}
|
|
527
574
|
await sleep(duration);
|
|
528
575
|
page.off('response', responseHandler);
|
|
529
576
|
const totalFound = extractedData.videos.length + extractedData.audio.length +
|
|
530
577
|
extractedData.manifests.length + extractedData.apis.length;
|
|
578
|
+
console.log(`[Extractor] š Extraction complete. Total responses: ${totalResponses}, Extracted: ${totalFound}`);
|
|
531
579
|
if (totalFound === 0) {
|
|
532
580
|
return {
|
|
533
581
|
content: [{
|
|
534
582
|
type: 'text',
|
|
535
|
-
text: `ā¹ļø No media content extracted
|
|
583
|
+
text: `ā¹ļø No media content extracted\n\nš Statistics:\n ⢠Total responses checked: ${totalResponses}\n ⢠Duration: ${duration}ms\n ⢠Navigation: ${navigateTo || 'None'}\n\nš” Suggestions:\n ${navigateTo ? '⢠Try longer duration (15000-20000ms)\n ⢠Verify page actually contains video/media' : '⢠Add navigateTo parameter: {"navigateTo": "https://example.com", "duration": 15000}'}\n ⢠Use 'advanced_video_extraction' for analyzing loaded content\n ⢠Check browser console logs for detailed monitoring`,
|
|
536
584
|
}],
|
|
537
585
|
};
|
|
538
586
|
}
|
|
539
587
|
return {
|
|
540
588
|
content: [{
|
|
541
589
|
type: 'text',
|
|
542
|
-
text: `ā
Network Recording Extraction Complete\n\
|
|
590
|
+
text: `ā
Network Recording Extraction Complete\n\nš Results:\n ⢠Videos: ${extractedData.videos.length}\n ⢠Audio: ${extractedData.audio.length}\n ⢠Manifests: ${extractedData.manifests.length}\n ⢠APIs: ${extractedData.apis.length}\n ⢠Total responses: ${totalResponses}\n\n${JSON.stringify(extractedData, null, 2)}`,
|
|
543
591
|
}],
|
|
544
592
|
};
|
|
545
593
|
}
|