Skip to content

Commit 97929e5

Browse files
committed
Improve the har display to look more like our unit tests.
1 parent 00805ed commit 97929e5

File tree

1 file changed

+23
-39
lines changed

1 file changed

+23
-39
lines changed

browser-extension/tests/har-view.ts

Lines changed: 23 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ function injectGitcassoScript(key: keyof typeof PAGES, html: string) {
437437
'position: fixed;' +
438438
'top: 80px;' +
439439
'right: 20px;' +
440-
'width: 300px;' +
440+
'width: 400px;' +
441441
'max-height: 400px;' +
442442
'background: rgba(255, 255, 255, 0.95);' +
443443
'border: 1px solid #ddd;' +
@@ -463,46 +463,30 @@ function injectGitcassoScript(key: keyof typeof PAGES, html: string) {
463463
empty: 'color: #666; font-style: italic;'
464464
};
465465
466-
function formatSpot(enhanced, index) {
467-
const { textarea, spot } = enhanced;
468-
const rect = textarea.getBoundingClientRect();
469-
const textareaInfo = {
470-
id: textarea.id || '',
471-
name: textarea.name || '',
472-
className: textarea.className || '',
473-
tagName: textarea.tagName,
474-
placeholder: textarea.placeholder || '',
475-
value: textarea.value ? textarea.value.substring(0, 50) + '...' : '',
476-
parentElement: textarea.parentElement ? textarea.parentElement.tagName + (textarea.parentElement.className ? '.' + textarea.parentElement.className : '') : '',
477-
position: {
478-
top: rect.top,
479-
left: rect.left,
480-
width: rect.width,
481-
height: rect.height
482-
}
483-
};
484-
485-
return '<div style="' + styles.spotContainer + '">' +
486-
'<div style="' + styles.spotTitle + '">Spot ' + (index + 1) + ':</div>' +
487-
'<pre style="' + styles.jsonPre + '">' + JSON.stringify(spot, null, 2) + '</pre>' +
488-
'<div style="' + styles.textareaHeader + '">Textarea Info:</div>' +
489-
'<pre style="' + styles.textareaPre + '">' + JSON.stringify(textareaInfo, null, 2) + '</pre>' +
490-
'</div>';
491-
}
492-
493466
function updateCommentSpotDisplay() {
494-
const enhanced = window.gitcassoTextareaRegistry ? window.gitcassoTextareaRegistry.getAllEnhanced() : [];
495-
496-
console.log('Enhanced textareas:', enhanced.length);
497-
console.log('All textareas on page:', document.querySelectorAll('textarea').length);
498-
499-
const content = enhanced.length > 0
500-
? '<div style="' + styles.header + '">CommentSpots (' + enhanced.length + '):</div>' +
501-
'<div style="font-size: 10px; color: #666; margin-bottom: 8px; word-break: break-all;">URL: ${urlParts.href}</div>' +
502-
enhanced.map(formatSpot).join('')
503-
: '<div style="' + styles.empty + '">No CommentSpots detected yet...<br><small>Textareas found: ' + document.querySelectorAll('textarea').length + '</small><br><small>URL: ${urlParts.href}</small></div>';
467+
const textareas = document.querySelectorAll('textarea');
468+
const spotsFound = [];
469+
470+
for (const textarea of textareas) {
471+
const forValue = 'id=' + textarea.id + ' name=' + textarea.name + ' className=' + textarea.className;
472+
const enhancedItem = window.gitcassoTextareaRegistry ? window.gitcassoTextareaRegistry.get(textarea) : undefined;
473+
if (enhancedItem) {
474+
spotsFound.push({
475+
for: forValue,
476+
spot: enhancedItem.spot,
477+
title: enhancedItem.enhancer.tableTitle(enhancedItem.spot),
478+
});
479+
} else {
480+
spotsFound.push({
481+
for: forValue,
482+
spot: 'NO_SPOT',
483+
});
484+
}
485+
}
504486
505-
commentSpotDisplay.innerHTML = content;
487+
console.log('Enhanced textareas:', spotsFound.filter(s => s.spot !== 'NO_SPOT').length);
488+
console.log('All textareas on page:', textareas.length);
489+
commentSpotDisplay.innerHTML = '<div style="' + styles.header + '"><pre>${urlParts.href}\\n' + JSON.stringify(spotsFound, null, 2) + '</pre></div>';
506490
}
507491
508492
// Initial update

0 commit comments

Comments
 (0)