brave-real-browser-mcp-server 2.15.5 → 2.15.7

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.
@@ -1,49 +0,0 @@
1
- // Data Processing & Transformation Handlers
2
- // Text cleaning, validation, formatting utilities
3
- // @ts-nocheck
4
- import { withErrorHandling } from '../system-utils.js';
5
- /**
6
- * HTML tags intelligently remove करता है
7
- */
8
- export async function handleHTMLToText(args) {
9
- return await withErrorHandling(async () => {
10
- const html = args.html;
11
- const preserveLinks = args.preserveLinks || false;
12
- const preserveFormatting = args.preserveFormatting || false;
13
- // Simple HTML to text conversion (can be enhanced with turndown)
14
- let text = html;
15
- // Preserve links if requested
16
- if (preserveLinks) {
17
- text = text.replace(/<a[^>]*href="([^"]*)"[^>]*>(.*?)<\/a>/gi, '$2 ($1)');
18
- }
19
- // Preserve basic formatting
20
- if (preserveFormatting) {
21
- text = text.replace(/<br\s*\/?>/gi, '\n');
22
- text = text.replace(/<\/p>/gi, '\n\n');
23
- text = text.replace(/<li>/gi, '• ');
24
- text = text.replace(/<\/li>/gi, '\n');
25
- }
26
- // Remove all other HTML tags
27
- text = text.replace(/<[^>]*>/g, '');
28
- // Decode HTML entities
29
- text = text
30
- .replace(/&nbsp;/g, ' ')
31
- .replace(/&amp;/g, '&')
32
- .replace(/&lt;/g, '<')
33
- .replace(/&gt;/g, '>')
34
- .replace(/&quot;/g, '"')
35
- .replace(/&#39;/g, "'");
36
- // Clean up whitespace
37
- text = text.replace(/\n\s*\n/g, '\n\n');
38
- text = text.trim();
39
- return {
40
- content: [
41
- {
42
- type: 'text',
43
- text: `✅ HTML converted to text\n\n${text}`,
44
- },
45
- ],
46
- };
47
- }, 'Failed to convert HTML to text');
48
- }
49
- // Duplicate Remover Arguments
@@ -1,115 +0,0 @@
1
- // Pagination & Navigation Tools
2
- // Auto pagination, infinite scroll, multi-page scraping, sitemap parser
3
- // @ts-nocheck
4
- import { getCurrentPage } from '../browser-manager.js';
5
- import { validateWorkflow } from '../workflow-validation.js';
6
- import { withErrorHandling, sleep } from '../system-utils.js';
7
- /**
8
- * Multiple pages से data collect और merge करता है
9
- */
10
- export async function handleMultiPageScraper(args) {
11
- return await withErrorHandling(async () => {
12
- validateWorkflow('multi_page_scraper', {
13
- requireBrowser: true,
14
- requirePage: true,
15
- });
16
- const page = getCurrentPage();
17
- const urls = args.urls;
18
- const dataSelector = args.dataSelector;
19
- const waitBetweenPages = args.waitBetweenPages || 1000;
20
- const allData = [];
21
- for (let i = 0; i < urls.length; i++) {
22
- const url = urls[i];
23
- try {
24
- await page.goto(url, { waitUntil: 'domcontentloaded' });
25
- await sleep(waitBetweenPages);
26
- const pageData = await page.evaluate((selector) => {
27
- const elements = document.querySelectorAll(selector);
28
- return Array.from(elements).map((el) => ({
29
- text: el.textContent?.trim() || '',
30
- html: el.innerHTML,
31
- }));
32
- }, dataSelector);
33
- allData.push({
34
- url,
35
- pageIndex: i,
36
- itemCount: pageData.length,
37
- data: pageData,
38
- });
39
- }
40
- catch (error) {
41
- allData.push({
42
- url,
43
- pageIndex: i,
44
- error: error instanceof Error ? error.message : String(error),
45
- });
46
- }
47
- }
48
- return {
49
- content: [
50
- {
51
- type: 'text',
52
- text: `✅ Scraped ${urls.length} pages\n\n${JSON.stringify(allData, null, 2)}`,
53
- },
54
- ],
55
- };
56
- }, 'Failed to scrape multiple pages');
57
- }
58
- /**
59
- * Site structure follow करके pages scrape करता है
60
- */
61
- export async function handleBreadcrumbNavigator(args) {
62
- return await withErrorHandling(async () => {
63
- validateWorkflow('breadcrumb_navigator', {
64
- requireBrowser: true,
65
- requirePage: true,
66
- });
67
- const page = getCurrentPage();
68
- const breadcrumbSelector = args.breadcrumbSelector || '.breadcrumb, nav[aria-label="breadcrumb"], .breadcrumbs';
69
- const followLinks = args.followLinks || false;
70
- const breadcrumbData = await page.evaluate((selector) => {
71
- const breadcrumbs = document.querySelectorAll(selector);
72
- const results = [];
73
- breadcrumbs.forEach((breadcrumb) => {
74
- const links = breadcrumb.querySelectorAll('a');
75
- const items = [];
76
- links.forEach((link, index) => {
77
- items.push({
78
- text: link.textContent?.trim() || '',
79
- href: link.href,
80
- level: index,
81
- });
82
- });
83
- if (items.length > 0) {
84
- results.push({
85
- path: items.map((i) => i.text).join(' > '),
86
- links: items,
87
- });
88
- }
89
- });
90
- return results;
91
- }, breadcrumbSelector);
92
- if (breadcrumbData.length === 0) {
93
- return {
94
- content: [
95
- {
96
- type: 'text',
97
- text: '❌ No breadcrumbs found on page',
98
- },
99
- ],
100
- };
101
- }
102
- let additionalData = '';
103
- if (followLinks && breadcrumbData[0]?.links) {
104
- additionalData = `\n\n📌 To scrape breadcrumb pages, use multi_page_scraper with URLs: ${JSON.stringify(breadcrumbData[0].links.map((l) => l.href))}`;
105
- }
106
- return {
107
- content: [
108
- {
109
- type: 'text',
110
- text: `✅ Found ${breadcrumbData.length} breadcrumb trail(s)\n\n${JSON.stringify(breadcrumbData, null, 2)}${additionalData}`,
111
- },
112
- ],
113
- };
114
- }, 'Failed to navigate breadcrumbs');
115
- }