@@ -403,13 +403,61 @@ function injectGitcassoScript(key: keyof typeof PAGES, html: string) {
403403
404404 // Create a global registry to track comment spots for debugging
405405 window.gitcassoCommentSpots = window.gitcassoCommentSpots || [];
406-
406+
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+
407427 // Execute the patched script with error handling
408428 try {
409429 const script = document.createElement('script');
410430 script.textContent = patchedCode;
411431 document.head.appendChild(script);
412432 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+
413461 } catch (error) {
414462 console.error('Failed to execute patched content script:', error);
415463 console.log('First 1000 chars of patched code:', patchedCode.substring(0, 1000));
@@ -538,9 +586,31 @@ function injectGitcassoScript(key: keyof typeof PAGES, html: string) {
538586 console.log('Spots for display:', spots);
539587 console.log('All textareas on page:', document.querySelectorAll('textarea').length);
540588
541- const content = spots.length > 0
542- ? \`<div style="font-weight: bold; margin-bottom: 8px; color: #333;">CommentSpots (\${spots.length}):</div><pre style="margin: 0; white-space: pre-wrap;">\${JSON.stringify(spots, null, 2)}</pre>\`
543- : '<div style="color: #666; font-style: italic;">No CommentSpots detected yet...<br><small>Textareas found: ' + document.querySelectorAll('textarea').length + '</small></div>';
589+ let content = '';
590+ if (spots.length > 0) {
591+ content = \`<div style="font-weight: bold; margin-bottom: 8px; color: #333;">CommentSpots (\${spots.length}):</div>\`;
592+
593+ spots.forEach((spot, index) => {
594+ const hasTextareaInfo = spot.textareaInfo;
595+ const spotData = Object.assign({}, spot);
596+ delete spotData.textareaInfo; // Remove from main display
597+
598+ content += \`<div style="margin-bottom: 12px; padding: 8px; border: 1px solid #eee; border-radius: 4px;">\`;
599+ content += \`<div style="font-weight: bold; color: #555;">Spot \${index + 1}:</div>\`;
600+ content += \`<pre style="margin: 4px 0; font-size: 10px;">\${JSON.stringify(spotData, null, 2)}</pre>\`;
601+
602+ if (hasTextareaInfo) {
603+ content += \`<div style="font-weight: bold; color: #007acc; margin-top: 8px;">Textarea Info:</div>\`;
604+ content += \`<pre style="margin: 4px 0; font-size: 10px; color: #666;">\${JSON.stringify(spot.textareaInfo, null, 2)}</pre>\`;
605+ } else {
606+ content += \`<div style="color: #999; font-style: italic; margin-top: 4px;">No textarea info captured</div>\`;
607+ }
608+
609+ content += \`</div>\`;
610+ });
611+ } else {
612+ content = '<div style="color: #666; font-style: italic;">No CommentSpots detected yet...<br><small>Textareas found: ' + document.querySelectorAll('textarea').length + '</small></div>';
613+ }
544614
545615 commentSpotDisplay.innerHTML = content;
546616 }
0 commit comments