@@ -360,6 +360,9 @@ function injectGitcassoScript(key: keyof typeof PAGES, html: string) {
360360 console.warn('Failed to patch sendEventToBackground function');
361361 }
362362
363+ // Enable debug mode for textarea info capture
364+ window.gitcassoDebugMode = true;
365+
363366 // Mock necessary APIs before executing
364367 window.chrome = window.chrome || {
365368 runtime: {
@@ -387,6 +390,13 @@ function injectGitcassoScript(key: keyof typeof PAGES, html: string) {
387390 timestamp: Date.now(),
388391 action: message.type
389392 });
393+
394+ // Include textarea info if available in the message
395+ if (message.textareaInfo) {
396+ trackingData.textareaInfo = message.textareaInfo;
397+ console.log('Textarea info captured:', message.textareaInfo);
398+ }
399+
390400 window.gitcassoCommentSpots.push(trackingData);
391401 console.log('CommentSpot captured via sendMessage:', trackingData);
392402 console.log('Total CommentSpots tracked:', window.gitcassoCommentSpots.length);
@@ -404,60 +414,12 @@ function injectGitcassoScript(key: keyof typeof PAGES, html: string) {
404414 // Create a global registry to track comment spots for debugging
405415 window.gitcassoCommentSpots = window.gitcassoCommentSpots || [];
406416
407- // Helper function to extract textarea info for debugging
408- function getTextareaInfo(textarea) {
409- const rect = textarea.getBoundingClientRect();
410- return {
411- id: textarea.id || '',
412- name: textarea.name || '',
413- className: textarea.className || '',
414- tagName: textarea.tagName,
415- placeholder: textarea.placeholder || '',
416- value: textarea.value ? textarea.value.substring(0, 50) + '...' : '',
417- parentElement: textarea.parentElement ? textarea.parentElement.tagName + (textarea.parentElement.className ? '.' + textarea.parentElement.className : '') : '',
418- position: {
419- top: rect.top,
420- left: rect.left,
421- width: rect.width,
422- height: rect.height
423- }
424- };
425- }
426-
427417 // Execute the patched script with error handling
428418 try {
429419 const script = document.createElement('script');
430420 script.textContent = patchedCode;
431421 document.head.appendChild(script);
432422 console.log('Content script executed successfully');
433-
434- // After the script loads, patch the TextareaRegistry if available
435- setTimeout(() => {
436- if (window.gitcassoTextareaRegistry) {
437- const originalSetEventHandlers = window.gitcassoTextareaRegistry.setEventHandlers;
438- window.gitcassoTextareaRegistry.setEventHandlers = function(onEnhanced, onDestroyed) {
439- console.log('Patching TextareaRegistry.setEventHandlers');
440- const wrappedOnEnhanced = function(spot, textarea) {
441- console.log('onEnhanced called with spot and textarea:', spot, textarea);
442- const textareaInfo = getTextareaInfo(textarea);
443- console.log('Textarea details:', textareaInfo);
444-
445- // Store enhanced info with textarea details
446- window.gitcassoCommentSpots = window.gitcassoCommentSpots || [];
447- const trackingData = Object.assign({}, spot, {
448- timestamp: Date.now(),
449- action: 'ENHANCED',
450- textareaInfo: textareaInfo
451- });
452- window.gitcassoCommentSpots.push(trackingData);
453-
454- return onEnhanced(spot, textarea);
455- };
456- return originalSetEventHandlers.call(this, wrappedOnEnhanced, onDestroyed);
457- };
458- }
459- }, 100);
460-
461423 } catch (error) {
462424 console.error('Failed to execute patched content script:', error);
463425 console.log('First 1000 chars of patched code:', patchedCode.substring(0, 1000));
0 commit comments