@@ -5,10 +5,14 @@ const mdTemplate = `
5
5
\`\`\`{{lang}}
6
6
{{code}}
7
7
\`\`\`
8
+ ##Note
9
+ \`\`\`
10
+ {{question_note}}
11
+ \`\`\`
8
12
` ;
9
13
const header = '' ;
10
14
const footer = '' ;
11
- const waitTime = 200 ;
15
+ const waitTime = 300 ;
12
16
const onlyFetchFirstPage = false ;
13
17
// config end
14
18
@@ -34,6 +38,27 @@ async function getSubmission(page) {
34
38
} ) ;
35
39
}
36
40
41
+ async function getNoteForQuestion ( questionSlug ) {
42
+ var url = `/graphql` ;
43
+ return new Promise ( ( resolve , reject ) => {
44
+ $ . ajax ( {
45
+ url : url ,
46
+ type : "POST" ,
47
+ contentType : "application/json" ,
48
+ data : JSON . stringify ( {
49
+ query : "query questionNote($titleSlug: String!) {\n question(titleSlug: $titleSlug) {\n questionId\n note\n }\n}\n" ,
50
+ variables : { "titleSlug" : questionSlug }
51
+ } ) ,
52
+ success : function ( data ) {
53
+ resolve ( data ) ;
54
+ } ,
55
+ error : function ( ) {
56
+ resolve ( 'failed' ) ;
57
+ } ,
58
+ } ) ;
59
+ } ) ;
60
+ }
61
+
37
62
async function getSolution ( url ) {
38
63
return new Promise ( ( resolve ) => {
39
64
$ . ajax ( {
@@ -90,12 +115,20 @@ for (let i = 0; i < accepts.length; i++) {
90
115
codeObj = eval ( content . slice ( start , end ) ) ;
91
116
console . log ( codeObj ) ;
92
117
118
+ let note_content = await getNoteForQuestion ( item . titleSlug ) ;
119
+ while ( response == 'failed' ) {
120
+ await pause ( waitTime ) ;
121
+ note_content = await getNoteForQuestion ( item . titleSlug ) ;
122
+ }
123
+ let question_note = response . data . question . note ;
124
+
93
125
solutions . push ( {
94
126
title : item . title ,
95
127
code : codeObj . submissionCode ,
96
128
url : `https://leetcode.com${ codeObj . editCodeUrl } description/` ,
97
129
questionId : codeObj . questionId ,
98
130
lang : item . lang ,
131
+ question_note : question_note
99
132
} ) ;
100
133
}
101
134
solutions . sort ( ( a , b ) => parseInt ( a . questionId ) - parseInt ( b . questionId ) )
0 commit comments