// Content script for SecureBit Chat Extension // Injects SecureBit functionality into web pages class SecureBitContentScript { constructor() { this.isInjected = false; this.secureBitWidget = null; this.initializeContentScript(); } initializeContentScript() { // Check if already injected if (document.getElementById('securebit-widget')) { return; } // Don't auto-inject widget, wait for user action this.setupKeyboardShortcut(); // Listen for messages from background script chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { this.handleMessage(request, sender, sendResponse); return true; }); } injectSecureBit() { if (this.isInjected) return; try { // Create the SecureBit widget this.createSecureBitWidget(); // Inject the widget into the page document.body.appendChild(this.secureBitWidget); this.isInjected = true; console.log('SecureBit Chat widget injected'); } catch (error) { console.error('Failed to inject SecureBit widget:', error); } } createSecureBitWidget() { // Create the main widget container this.secureBitWidget = document.createElement('div'); this.secureBitWidget.id = 'securebit-widget'; this.secureBitWidget.className = 'securebit-widget'; // Add styles this.addWidgetStyles(); // Create widget content this.secureBitWidget.innerHTML = `