@@ -484,6 +484,9 @@ document.addEventListener('click', (event) => {
484
484
the note should be opened atleast once for this to work
485
485
this is because the dom is populated after data is fetched by opening the note */
486
486
function getNotesIfAny ( ) {
487
+ // there are no notes on expore
488
+ if ( document . URL . startsWith ( "https://leetcode.com/explore/" ) ) return "" ;
489
+
487
490
notes = '' ;
488
491
notesdiv = document
489
492
. getElementsByClassName ( 'notewrap__eHkN' ) [ 0 ]
@@ -493,7 +496,7 @@ function getNotesIfAny() {
493
496
if ( notesdiv . childNodes [ i ] . childNodes . length == 0 ) continue ;
494
497
text = notesdiv . childNodes [ i ] . childNodes [ 0 ] . innerText ;
495
498
if ( text ) {
496
- notes = `${ notes } \n${ text . trim ( ) } ` ;
499
+ notes = `${ notes } \n${ text . trim ( ) } ` . trim ( ) ;
497
500
}
498
501
}
499
502
}
@@ -552,20 +555,23 @@ const loader = setInterval(() => {
552
555
} ) ;
553
556
554
557
/* get the notes and upload it */
555
- setTimeout ( function ( ) {
556
- notes = getNotesIfAny ( ) ;
557
- if ( notes != undefined && notes . length != 0 ) {
558
- console . log ( 'Create Notes' ) ;
559
- // means we can upload the notes too
560
- uploadGit (
561
- btoa ( unescape ( encodeURIComponent ( notes ) ) ) ,
562
- problemName ,
563
- 'NOTES.txt' ,
564
- createNotesMsg ,
565
- 'upload' ,
566
- ) ;
567
- }
568
- } , 500 ) ;
558
+ /* only upload notes if there is any */
559
+ notes = getNotesIfAny ( ) ;
560
+ if ( notes . length > 0 ) {
561
+ setTimeout ( function ( ) {
562
+ if ( notes != undefined && notes . length != 0 ) {
563
+ console . log ( 'Create Notes' ) ;
564
+ // means we can upload the notes too
565
+ uploadGit (
566
+ btoa ( unescape ( encodeURIComponent ( notes ) ) ) ,
567
+ problemName ,
568
+ 'NOTES.txt' ,
569
+ createNotesMsg ,
570
+ 'upload' ,
571
+ ) ;
572
+ }
573
+ } , 500 ) ;
574
+ }
569
575
570
576
/* Upload code to Git */
571
577
setTimeout ( function ( ) {
0 commit comments