Skip to content

Commit

Permalink
notes not available in explore: fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Bibek Shrestha committed Aug 10, 2021
1 parent 2a741f1 commit 30883f7
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions scripts/leetcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,9 @@ document.addEventListener('click', (event) => {
the note should be opened atleast once for this to work
this is because the dom is populated after data is fetched by opening the note */
function getNotesIfAny() {
// there are no notes on expore
if(document.URL.startsWith("https://leetcode.com/explore/")) return "";

notes = '';
notesdiv = document
.getElementsByClassName('notewrap__eHkN')[0]
Expand All @@ -493,7 +496,7 @@ function getNotesIfAny() {
if (notesdiv.childNodes[i].childNodes.length == 0) continue;
text = notesdiv.childNodes[i].childNodes[0].innerText;
if (text) {
notes = `${notes}\n${text.trim()}`;
notes = `${notes}\n${text.trim()}`.trim();
}
}
}
Expand Down Expand Up @@ -552,20 +555,23 @@ const loader = setInterval(() => {
});

/* get the notes and upload it */
setTimeout(function () {
notes = getNotesIfAny();
if (notes != undefined && notes.length != 0) {
console.log('Create Notes');
// means we can upload the notes too
uploadGit(
btoa(unescape(encodeURIComponent(notes))),
problemName,
'NOTES.txt',
createNotesMsg,
'upload',
);
}
}, 500);
/* only upload notes if there is any */
notes = getNotesIfAny();
if (notes.length > 0) {
setTimeout(function () {
if (notes != undefined && notes.length != 0) {
console.log('Create Notes');
// means we can upload the notes too
uploadGit(
btoa(unescape(encodeURIComponent(notes))),
problemName,
'NOTES.txt',
createNotesMsg,
'upload',
);
}
}, 500);
}

/* Upload code to Git */
setTimeout(function () {
Expand Down

0 comments on commit 30883f7

Please sign in to comment.