Skip to content

replace gpt with openrouter, users can add api key in settings #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Apr 4, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix: check icon not showing when copy btn clicked
  • Loading branch information
zubyj committed Apr 4, 2025
commit ef6087b4cb22b0f4d60b31d0cc0f601a45c616e5
6 changes: 4 additions & 2 deletions src/popup/popup.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ body {
background-color: var(--background-color);
font-size: calc(var(--font-size-base) * var(--scale-factor));
font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Oxygen, Ubuntu, sans-serif;
padding: 0 calc(20px * var(--scale-factor));
padding: calc(25px * var(--scale-factor)) calc(20px * var(--scale-factor));
width: calc(400px * var(--scale-factor));
margin: 0;
line-height: 1.5;
Expand Down Expand Up @@ -298,9 +298,10 @@ pre[class*="language-"] {
}

#clear-code-btn {
margin-left: calc(10px * var(--scale-factor));
margin-left: calc(5px * var(--scale-factor));
}


/* Settings */
#settings-icon {
width: calc(24px * var(--scale-factor));
Expand All @@ -326,6 +327,7 @@ pre[class*="language-"] {

#settings-menu {
text-align: center;
padding: calc(15px * var(--scale-factor)) 0;
}

.video-container {
Expand Down
23 changes: 23 additions & 0 deletions src/popup/popup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Add code to highlight response after it's displayed
document.addEventListener('DOMContentLoaded', function() {
// Function to make the response visible and highlighted
function watchForResponseContent() {
const responseElement = document.getElementById('analyze-code-response');
if (responseElement) {
// Create a MutationObserver to detect when content is added
const observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
// Make sure the element is visible by removing the 'hidden' class
responseElement.classList.remove('hidden');
}
});
});

// Start observing the response element
observer.observe(responseElement, { childList: true, subtree: true });
}
}

watchForResponseContent();
});
14 changes: 11 additions & 3 deletions src/popup/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,17 @@ function initCopyButton(): void {
const copyButton = elements['copyCodeBtn'];
if (!copyButton) return;
copyButton.onclick = async () => {
setInfoMessage('Copied Code', 3000);
// change icon to check-icon.png
copyButton
setInfoMessage('Copied Code', 1000);
// Change icon to check-icon.png
const copyButtonImg = copyButton.querySelector('img');
if (copyButtonImg) {
copyButtonImg.src = '../assets/images/check-icon.png';
// After 1 second, change the icon back to the copy icon
setTimeout(() => {
copyButtonImg.src = '../assets/images/copy-icon.png';
}, 1000);
}

if (fixCodeResponse && fixCodeResponse.textContent) {
await navigator.clipboard.writeText(fixCodeResponse.textContent);
}
Expand Down