Skip to content

Commit 87b4f8e

Browse files
committed
Some progress.
1 parent dd4e5dc commit 87b4f8e

File tree

1 file changed

+32
-33
lines changed

1 file changed

+32
-33
lines changed

browser-extension/tests/har-view.ts

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ function injectGitcassoScript(key: keyof typeof PAGES, html: string) {
316316
console.log('Patching window.location to simulate original URL...');
317317
318318
// Use history.pushState to change the pathname
319-
window.history.pushState({}, '', '${urlParts.pathname}');
319+
window.history.pushState({}, '', '` + urlParts.pathname + `');
320320
321321
console.log('Location patched:', {
322322
hostname: window.location.hostname,
@@ -333,9 +333,10 @@ function injectGitcassoScript(key: keyof typeof PAGES, html: string) {
333333
334334
// Replace the problematic webextension-polyfill error check
335335
const patchedCode = code.replace(
336-
/throw new Error\\("This script should only be loaded in a browser extension\\."/g,
337-
'console.warn("Webextension-polyfill check bypassed for HAR testing"'
336+
'throw new Error("This script should only be loaded in a browser extension.")',
337+
'console.warn("Webextension-polyfill check bypassed for HAR testing")'
338338
);
339+
339340
// Mock necessary APIs before executing
340341
window.chrome = window.chrome || {
341342
runtime: {
@@ -346,11 +347,12 @@ function injectGitcassoScript(key: keyof typeof PAGES, html: string) {
346347
}
347348
};
348349
window.browser = window.chrome;
350+
349351
// Execute the patched script
350352
const script = document.createElement('script');
351353
script.textContent = patchedCode;
352354
document.head.appendChild(script);
353-
console.log('Gitcasso content script loaded with location patching for:', '${urlParts.href}');
355+
console.log('Gitcasso content script loaded with location patching for:', '` + urlParts.href + `');
354356
})
355357
.catch(error => {
356358
console.error('Failed to load and patch content script:', error);
@@ -443,24 +445,23 @@ function injectGitcassoScript(key: keyof typeof PAGES, html: string) {
443445
// Create CommentSpot display
444446
const commentSpotDisplay = document.createElement('div');
445447
commentSpotDisplay.id = 'gitcasso-comment-spots';
446-
commentSpotDisplay.style.cssText = \`
447-
position: fixed;
448-
top: 80px;
449-
right: 20px;
450-
width: 300px;
451-
max-height: 400px;
452-
background: rgba(255, 255, 255, 0.95);
453-
border: 1px solid #ddd;
454-
border-radius: 8px;
455-
padding: 15px;
456-
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
457-
font-size: 11px;
458-
line-height: 1.4;
459-
overflow-y: auto;
460-
z-index: 999998;
461-
box-shadow: 0 4px 12px rgba(0,0,0,0.2);
462-
backdrop-filter: blur(10px);
463-
\`;
448+
commentSpotDisplay.style.cssText =
449+
'position: fixed;' +
450+
'top: 80px;' +
451+
'right: 20px;' +
452+
'width: 300px;' +
453+
'max-height: 400px;' +
454+
'background: rgba(255, 255, 255, 0.95);' +
455+
'border: 1px solid #ddd;' +
456+
'border-radius: 8px;' +
457+
'padding: 15px;' +
458+
'font-family: Monaco, Menlo, Ubuntu Mono, monospace;' +
459+
'font-size: 11px;' +
460+
'line-height: 1.4;' +
461+
'overflow-y: auto;' +
462+
'z-index: 999998;' +
463+
'box-shadow: 0 4px 12px rgba(0,0,0,0.2);' +
464+
'backdrop-filter: blur(10px);';
464465
465466
// Simplified display formatting
466467
const styles = {
@@ -493,14 +494,12 @@ function injectGitcassoScript(key: keyof typeof PAGES, html: string) {
493494
}
494495
};
495496
496-
return \`
497-
<div style="\${styles.spotContainer}">
498-
<div style="\${styles.spotTitle}">Spot \${index + 1}:</div>
499-
<pre style="\${styles.jsonPre}">\${JSON.stringify(spot, null, 2)}</pre>
500-
<div style="\${styles.textareaHeader}">Textarea Info:</div>
501-
<pre style="\${styles.textareaPre}">\${JSON.stringify(textareaInfo, null, 2)}</pre>
502-
</div>
503-
\`;
497+
return '<div style="' + styles.spotContainer + '">' +
498+
'<div style="' + styles.spotTitle + '">Spot ' + (index + 1) + ':</div>' +
499+
'<pre style="' + styles.jsonPre + '">' + JSON.stringify(spot, null, 2) + '</pre>' +
500+
'<div style="' + styles.textareaHeader + '">Textarea Info:</div>' +
501+
'<pre style="' + styles.textareaPre + '">' + JSON.stringify(textareaInfo, null, 2) + '</pre>' +
502+
'</div>';
504503
}
505504
506505
function updateCommentSpotDisplay() {
@@ -510,9 +509,9 @@ function injectGitcassoScript(key: keyof typeof PAGES, html: string) {
510509
console.log('All textareas on page:', document.querySelectorAll('textarea').length);
511510
512511
const content = enhanced.length > 0
513-
? \`<div style="\${styles.header}">CommentSpots (\${enhanced.length}):</div>
514-
\${enhanced.map(formatSpot).join('')}\`
515-
: \`<div style="\${styles.empty}">No CommentSpots detected yet...<br><small>Textareas found: \${document.querySelectorAll('textarea').length}</small></div>\`;
512+
? '<div style="' + styles.header + '">CommentSpots (' + enhanced.length + '):</div>' +
513+
enhanced.map(formatSpot).join('')
514+
: '<div style="' + styles.empty + '">No CommentSpots detected yet...<br><small>Textareas found: ' + document.querySelectorAll('textarea').length + '</small></div>';
516515
517516
commentSpotDisplay.innerHTML = content;
518517
}

0 commit comments

Comments
 (0)