Skip to content

Commit d7f5d90

Browse files
committed
better error handling for gpt buttons, add link to github"
"
1 parent 22c0eec commit d7f5d90

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

src/content-script/get-user-code.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,26 @@ function getCode() {
1414
let textArray = []
1515

1616
// Add the test cases & examples
17-
textArray.push('\nHeres the description, examples, and constraints for the problem\n');
1817
const examples = document.getElementsByClassName('xFUwe')[0];
1918
if (examples && examples.children) {
19+
textArray.push('\nHeres the description, examples, and constraints for the problem\n');
2020
for (const child of examples.children) {
2121
let text = child.textContent;
2222
if (text) textArray.push(text);
2323
}
2424
}
2525

2626
// Get the function definition and users code from the code editor
27-
textArray = ["heres the function definition and the users code which might be not present or might be incorrect.\n"]
2827
const codeEditor = document.getElementsByClassName('view-line');
29-
for (const viewLine of codeEditor) {
30-
let text = viewLine.textContent;
31-
if (text) textArray.push(text);
28+
if (codeEditor) {
29+
textArray.push("heres the function definition and the users code which might be not present or might be incorrect.\n");
30+
for (const viewLine of codeEditor) {
31+
let text = viewLine.textContent;
32+
if (text) textArray.push(text);
33+
}
3234
}
33-
console.log('text array', textArray);
3435

36+
console.log('heres the text array', textArray);
3537
return textArray;
3638
}
3739

src/popup/settings.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,16 @@ <h2 class="title">Settings</h2>
3535
<span id="show-rating-icon"> </span> Show Rating
3636
</button>
3737
<div id="review">
38+
Leave us a
3839
<a target="_blank"
3940
href="https://chrome.google.com/webstore/detail/leetcode-explained/cofoinjfjcpgcjiinjhcpomcjoalijbe">
40-
Leave us a review
41+
review
42+
</a>
43+
</div>
44+
<div id="review">
45+
View the
46+
<a target="_blank" href="https://github.com/zubyj/leetcode-explained">
47+
source code
4148
</a>
4249
</div>
4350
</body>

0 commit comments

Comments
 (0)