Skip to content

Commit b5be1db

Browse files
committed
Added copy logic
1 parent cba33c7 commit b5be1db

File tree

3 files changed

+55
-1
lines changed

3 files changed

+55
-1
lines changed

extension/popup.css

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
body {
22
font-family: 'Segoe UI', sans-serif;
3-
margin: 0;
3+
margin: 6px;
44
padding: 20px;
55
width: 320px;
66
height: auto;
@@ -37,6 +37,38 @@ h3 {
3737
transform: scale(1.01);
3838
}
3939

40+
#copyContainer {
41+
position: relative;
42+
height: 0;
43+
margin-top: 50px;
44+
margin-right: -8px;
45+
}
46+
47+
#copyBtn {
48+
position: absolute;
49+
right: 10px;
50+
bottom: 10px;
51+
background: rgba(255, 255, 255, 0.08);
52+
color: #FFA726;
53+
border: none;
54+
border-radius: 10px;
55+
width: 64px;
56+
height: 32px;
57+
display: flex;
58+
align-items: center;
59+
justify-content: center;
60+
cursor: pointer;
61+
backdrop-filter: blur(5px);
62+
transition: background 0.2s ease-in-out;
63+
font-size: 12px;
64+
}
65+
66+
#copyBtn:hover {
67+
background: rgba(157, 105, 28, 0.2);
68+
transform: scale(1.01);
69+
}
70+
71+
4072

4173
ul {
4274
padding-left: 20px;

extension/popup.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@
1212
<h3>Need Help with LeetCode?</h3>
1313
<button id="getHelp">Get Step-by-Step Help</button>
1414

15+
<!-- <div id="copyContainer"> -->
16+
<div id="copyContainer" style="display: none; position: relative;">
17+
<button id="copyBtn" title="Copy steps">
18+
Copy
19+
</button>
20+
</div>
21+
22+
1523
<!-- Loader Spinner -->
1624
<div id="loader" style="display: none; text-align: center;">
1725
<div class="spinner"></div>

extension/popup.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,20 @@ document.getElementById("getHelp").addEventListener("click", async () => {
3636
const div = document.createElement("div");
3737
div.innerHTML = marked.parse(step); // Render markdown
3838
output.appendChild(div);
39+
40+
document.getElementById("copyContainer").style.display = "block";
41+
42+
// Copy text logic
43+
document.getElementById("copyBtn").onclick = () => {
44+
const textToCopy = data.steps.join('\n\n');
45+
navigator.clipboard.writeText(textToCopy).then(() => {
46+
document.getElementById("copyBtn").innerText = "✅";
47+
setTimeout(() => {
48+
document.getElementById("copyBtn").innerText = "Copy";
49+
}, 1500);
50+
})
51+
};
52+
3953
});
4054
} else {
4155
output.innerHTML = "<p>No steps found.</p>";

0 commit comments

Comments
 (0)