Skip to content

Commit 09b5f42

Browse files
authored
Merge pull request #170 from ccagml/main
US站一些报错
2 parents 7afb9f2 + 78e19ff commit 09b5f42

File tree

4 files changed

+118
-3
lines changed

4 files changed

+118
-3
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## version 2.13.4
2+
3+
- US站一些报错
4+
5+
16
## version 2.13.3
27

38
- 修改README.md

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vscode-leetcode-problem-rating",
33
"displayName": "LeetCode",
44
"description": "LeetCode 官方插件增强, 代码开源, 增加 LeetCode 题目难度分, 给个star吧, 球球了",
5-
"version": "2.13.3",
5+
"version": "2.13.4",
66
"author": "ccagml",
77
"publisher": "ccagml",
88
"license": "MIT",

src/rpc/actionChain/chainNode/leetcode.ts

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,116 @@ and csrf token to the user object and saves the user object to the session. */
672672
});
673673
});
674674
};
675+
676+
/* A function that is used to get the rating of the problems. */
677+
getRatingOnline = (cb) => {
678+
const _request = request.defaults({ timeout: 2000, jar: true });
679+
_request("https://zerotrac.github.io/leetcode_problem_rating/data.json", function (error: any, _, body: any) {
680+
// console.log(error);
681+
// console.log(info);
682+
cb(error, body);
683+
});
684+
};
685+
686+
/* A function that gets the question of the day from leetcode. */
687+
getQuestionOfToday = (cb) => {
688+
const opts = makeOpts(configUtils.sys.urls.graphql);
689+
opts.headers.Origin = configUtils.sys.urls.base;
690+
opts.headers.Referer = "https://leetcode.com/";
691+
692+
opts.json = true;
693+
opts.body = {
694+
operationName: "questionOfToday",
695+
variables: {},
696+
query: [
697+
"query questionOfToday {",
698+
" todayRecord {",
699+
" date",
700+
" userStatus",
701+
" question {",
702+
" titleSlug",
703+
" questionId",
704+
" questionFrontendId",
705+
// ' content',
706+
// ' stats',
707+
// ' likes',
708+
// ' dislikes',
709+
// ' codeDefinition',
710+
// ' sampleTestCase',
711+
// ' enableRunCode',
712+
// ' metaData',
713+
// ' translatedContent',
714+
" __typename",
715+
" }",
716+
" __typename",
717+
" }",
718+
"}",
719+
].join("\n"),
720+
};
721+
722+
// request.post(opts, function (e, resp, body) {
723+
// e = checkError(e, resp, 200);
724+
// if (e) return cb(e);
725+
// let result: any = {};
726+
// result.titleSlug = body.data.todayRecord[0].question.titleSlug;
727+
// result.questionId = body.data.todayRecord[0].question.questionId;
728+
// result.fid = body.data.todayRecord[0].question.questionFrontendId;
729+
// result.date = body.data.todayRecord[0].data;
730+
// result.userStatus = body.data.todayRecord[0].userStatus;
731+
// return cb(null, result);
732+
// });
733+
cb(null, {})
734+
};
735+
736+
/* A function that is used to get the user contest ranking information. */
737+
getUserContestP = (username, cb) => {
738+
const opts = makeOpts(configUtils.sys.urls.noj_go);
739+
opts.headers.Origin = configUtils.sys.urls.base;
740+
opts.headers.Referer = configUtils.sys.urls.u.replace("$username", username);
741+
742+
opts.json = true;
743+
opts.body = {
744+
variables: {
745+
userSlug: username,
746+
},
747+
query: [
748+
" query userContestRankingInfo($userSlug: String!) {",
749+
" userContestRanking(userSlug: $userSlug) {",
750+
" attendedContestsCount",
751+
" rating",
752+
" globalRanking",
753+
" localRanking",
754+
" globalTotalParticipants",
755+
" localTotalParticipants",
756+
" topPercentage",
757+
" }",
758+
// ' userContestRankingHistory(userSlug: $userSlug) {',
759+
// ' attended',
760+
// ' totalProblems',
761+
// ' trendingDirection',
762+
// ' finishTimeInSeconds',
763+
// ' rating',
764+
// ' score',
765+
// ' ranking',
766+
// ' contest {',
767+
// ' title',
768+
// ' titleCn',
769+
// ' startTime',
770+
// ' }',
771+
// ' }',
772+
" }",
773+
].join("\n"),
774+
};
775+
776+
// request.post(opts, function (e, resp, body) {
777+
// e = checkError(e, resp, 200);
778+
// if (e) return cb(e);
779+
780+
// return cb(null, body.data);
781+
// });
782+
cb(null, {})
783+
};
784+
675785
getHelpOnline = (problem, _, lang) => {
676786
getHelpEn(problem, lang, function (e, solution) {
677787
if (e) return;

0 commit comments

Comments
 (0)