const html2canvas = require('html2canvas'); class FeedbackCapture { constructor() { this.initializeOverlay(); this.attachMessageListener(); } initializeOverlay() { this.overlay = document.createElement('div'); this.overlay.id = 'jira-feedback-overlay'; this.overlay.style.display = 'none'; document.body.appendChild(this.overlay); } attachMessageListener() { chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { if (request.action === 'captureScreenshot') { this.handleScreenshotCapture(sendResponse); return true; // Keep the message channel open for async response } }); } async handleScreenshotCapture(sendResponse) { try { // Create a temporary canvas with the same dimensions as the viewport const canvas = await html2canvas(document.documentElement, { useCORS: true, scale: window.devicePixelRatio || 1, logging: false, allowTaint: true, backgroundColor: null, foreignObjectRendering: true, removeContainer: true }); const screenshot = canvas.toDataURL('image/png'); sendResponse({ success: true, screenshot }); } catch (error) { console.error('Error capturing screenshot:', error); sendResponse({ success: false, error: error.message }); } } } // Initialize the feedback capture functionality new FeedbackCapture();