Skip to content

Chrome ExtensionΒΆ

The RapidTriageME Chrome Extension is the data collection layer that captures browser events, console logs, network requests, and errors.

OverviewΒΆ

The extension operates in the browser's privileged context, using Chrome's DevTools API to capture comprehensive debugging information.

ArchitectureΒΆ

graph LR
    subgraph Chrome Browser
        WP[Web Page]
        CS[Content Script]
        BG[Background Script]
        DT[DevTools Panel]

        WP --> CS
        CS --> BG
        BG --> DT
        DT --> API[DevTools API]
    end

    DT -->|WebSocket| BC[Browser Connector :3025]

FeaturesΒΆ

πŸ” Data CaptureΒΆ

  • Console Logs - All console.* methods
  • Errors - JavaScript exceptions and runtime errors
  • Network Requests - XHR and Fetch API calls
  • DOM Events - User interactions and mutations
  • Performance Metrics - Resource timing, paint events
  • Screenshots - On-demand viewport capture

πŸŽ›οΈ DevTools PanelΒΆ

Custom panel in Chrome DevTools providing: - Connection status indicator - Real-time log viewer - Settings configuration - Server discovery - Manual screenshot trigger

πŸ”— Auto-DiscoveryΒΆ

Automatic server discovery on ports 3025-1431: 1. Checks default port (3025) 2. Scans alternate ports 3. Validates server identity 4. Establishes WebSocket connection

InstallationΒΆ

From SourceΒΆ

  1. Clone the repository:

    git clone .git
    cd rapidtriage/rapidtriage-extension
    

  2. Load in Chrome:

  3. Navigate to chrome://extensions/
  4. Enable "Developer mode"
  5. Click "Load unpacked"
  6. Select the extension directory

From Chrome Web StoreΒΆ

Coming soon!

ConfigurationΒΆ

Settings PanelΒΆ

Access via the DevTools panel:

Setting Description Default
Server Host Connector server address localhost
Server Port Connector server port 3025
Log Limit Maximum logs to store 50
String Size Limit Max string length 500
Screenshot Path Save location ~/Downloads

Manifest ConfigurationΒΆ

manifest.json key permissions:

{
  "permissions": [
    "debugger",
    "storage",
    "tabs",
    "activeTab"
  ],
  "host_permissions": [
    "http://localhost/*",
    "http://127.0.0.1/*"
  ]
}

UsageΒΆ

Basic UsageΒΆ

  1. Open any website in Chrome
  2. Open DevTools (F12)
  3. Navigate to "BrowserToolsMCP" tab
  4. Verify connection status is green
  5. Start debugging - data flows automatically

Manual ControlsΒΆ

  • Capture Screenshot - Click button in panel
  • Wipe Logs - Clear all captured data
  • Test Connection - Verify server connectivity
  • Auto-Discovery - Scan for server

API IntegrationΒΆ

Message ProtocolΒΆ

The extension communicates via WebSocket with these message types:

// Console log message
{
  type: "console-log",
  level: "info",
  message: "Application started",
  timestamp: 1704067200000
}

// Network request
{
  type: "network-request", 
  url: "https://api.example.com",
  method: "GET",
  status: 200,
  duration: 145
}

// Error message
{
  type: "console-error",
  message: "Uncaught TypeError",
  stack: "at app.js:42",
  timestamp: 1704067200000
}

WebSocket EventsΒΆ

// Connection established
ws.onopen = () => {
  console.log('Connected to server');
};

// Message received
ws.onmessage = (event) => {
  const message = JSON.parse(event.data);
  handleServerMessage(message);
};

// Connection closed
ws.onclose = () => {
  console.log('Disconnected from server');
  attemptReconnect();
};

DevelopmentΒΆ

Building from SourceΒΆ

# Install dependencies
npm install

# Build extension
npm run build

# Watch mode
npm run watch

TestingΒΆ

# Run tests
npm test

# Manual testing
1. Load extension in Chrome
2. Run test server: npm run test-server
3. Open test page: http://localhost:3000/test

DebuggingΒΆ

Enable verbose logging:

  1. Open extension background page
  2. Open console
  3. Set debug flag:
    localStorage.setItem('DEBUG', 'true');
    

PerformanceΒΆ

Optimization StrategiesΒΆ

  • Throttling - Limits message frequency
  • Batching - Groups multiple events
  • Compression - Reduces payload size
  • Filtering - Excludes noise
  • Sampling - Statistical sampling for high-volume

Resource UsageΒΆ

Typical resource consumption:

Metric Value
Memory ~10-20 MB
CPU <1% idle, 2-5% active
Network ~1-10 KB/s
Storage <1 MB

SecurityΒΆ

Permissions ModelΒΆ

  • Host Permissions - Limited to localhost
  • Content Security Policy - Strict CSP
  • Data Sanitization - XSS prevention
  • No External Requests - Local only

Data PrivacyΒΆ

  • No data leaves localhost by default
  • No analytics or tracking
  • No persistent storage of sensitive data
  • User-controlled data clearing

TroubleshootingΒΆ

Common IssuesΒΆ

Extension not loading
  • Check Developer mode is enabled
  • Verify manifest.json is valid
  • Check for console errors
Not connecting to server
  • Verify server is running on port 3025
  • Check firewall settings
  • Try manual connection test
No data captured
  • Refresh the page after loading extension
  • Check DevTools is open
  • Verify debugger is attached

Debug CommandsΒΆ

Run in extension console:

// Check connection status
chrome.runtime.sendMessage({type: 'GET_STATUS'});

// Force reconnect
chrome.runtime.sendMessage({type: 'RECONNECT'});

// Clear all data
chrome.runtime.sendMessage({type: 'CLEAR_DATA'});

API ReferenceΒΆ

Chrome Extension APIs UsedΒΆ

  • chrome.debugger - Attach to tabs
  • chrome.devtools - Create panel
  • chrome.runtime - Message passing
  • chrome.storage - Settings persistence
  • chrome.tabs - Tab management

Custom EventsΒΆ

The extension emits these events:

// Server connected
window.dispatchEvent(new CustomEvent('rapidtriage:connected'));

// Data captured
window.dispatchEvent(new CustomEvent('rapidtriage:data', {
  detail: { type: 'console-log', data: {...} }
}));

// Error occurred
window.dispatchEvent(new CustomEvent('rapidtriage:error', {
  detail: { message: 'Connection failed' }
}));

Next StepsΒΆ