Skip to content

Commit b1fd6bb

Browse files
committed
feat: get js code
1 parent dbdb255 commit b1fd6bb

File tree

2 files changed

+3
-13
lines changed

2 files changed

+3
-13
lines changed

common/question/getJSCode.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ const document = window.document
2828
const code = document.querySelector('#code')
2929

3030
fetch("https://leetcode.cn/graphql/", getCodeDetailJson(todayQuestionEnName)).then((res => res.json())).then(res => {
31-
questionCodeDetail = res.data.question.envInfo;
32-
code.innerHTML = JSON.stringify(questionCodeDetail, null, 2)
31+
const questionCodeDetail = res.data.question.codeSnippets.filter(item => item.lang === "JavaScript");
32+
const jsCode = questionCodeDetail[0].code
33+
code.innerHTML = JSON.stringify(jsCode, null, 2)
3334
fs.writeFileSync('./index.html', root.serialize())
3435
open('./index.html')
3536
})

index.html

-11
This file was deleted.

0 commit comments

Comments
 (0)