Files
core d708c8b58c Initial commit: Browser Pilot - Agentic Browser Control Extension
- Side Panel with Chat UI, Quick Actions, Dev Tools
- 22 browser automation tools (DOM, JS, screenshots, navigation)
- MCP server (zero-dep, Node 18+) for external AI clients
- Supports OpenRouter, Ollama, Anthropic, OpenAI, custom endpoints
- Chrome/Brave MV3 extension with content script console capture
2026-07-28 11:04:37 +02:00

35 lines
1.2 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Browser Pilot Content Script
* Captures console logs and provides DOM utilities.
*/
(function() {
'use strict';
if (window.__bpInjected) return;
window.__bpInjected = true;
// Console capture
const orig = { log: console.log, warn: console.warn, error: console.error, info: console.info };
function hook(level) {
return function(...args) {
try {
chrome.runtime.sendMessage({
type: 'CONSOLE_LOG', level,
text: args.map(a => { try { return typeof a === 'object' ? JSON.stringify(a) : String(a); } catch { return String(a); } }).join(' ')
});
} catch {}
orig[level].apply(console, args);
};
}
console.log = hook('log');
console.warn = hook('warn');
console.error = hook('error');
console.info = hook('info');
window.addEventListener('error', e => {
try { chrome.runtime.sendMessage({ type: 'CONSOLE_LOG', level: 'error', text: `${e.message} @ ${e.filename}:${e.lineno}` }); } catch {}
});
window.addEventListener('unhandledrejection', e => {
try { chrome.runtime.sendMessage({ type: 'CONSOLE_LOG', level: 'error', text: 'Unhandled: ' + e.reason }); } catch {}
});
})();