Skip to content

US站一些报错 #170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## version 2.13.4

- US站一些报错


## version 2.13.3

- 修改README.md
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vscode-leetcode-problem-rating",
"displayName": "LeetCode",
"description": "LeetCode 官方插件增强, 代码开源, 增加 LeetCode 题目难度分, 给个star吧, 球球了",
"version": "2.13.3",
"version": "2.13.4",
"author": "ccagml",
"publisher": "ccagml",
"license": "MIT",
Expand Down
110 changes: 110 additions & 0 deletions src/rpc/actionChain/chainNode/leetcode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,116 @@ and csrf token to the user object and saves the user object to the session. */
});
});
};

/* A function that is used to get the rating of the problems. */
getRatingOnline = (cb) => {
const _request = request.defaults({ timeout: 2000, jar: true });
_request("https://zerotrac.github.io/leetcode_problem_rating/data.json", function (error: any, _, body: any) {
// console.log(error);
// console.log(info);
cb(error, body);
});
};

/* A function that gets the question of the day from leetcode. */
getQuestionOfToday = (cb) => {
const opts = makeOpts(configUtils.sys.urls.graphql);
opts.headers.Origin = configUtils.sys.urls.base;
opts.headers.Referer = "https://leetcode.com/";

opts.json = true;
opts.body = {
operationName: "questionOfToday",
variables: {},
query: [
"query questionOfToday {",
" todayRecord {",
" date",
" userStatus",
" question {",
" titleSlug",
" questionId",
" questionFrontendId",
// ' content',
// ' stats',
// ' likes',
// ' dislikes',
// ' codeDefinition',
// ' sampleTestCase',
// ' enableRunCode',
// ' metaData',
// ' translatedContent',
" __typename",
" }",
" __typename",
" }",
"}",
].join("\n"),
};

// request.post(opts, function (e, resp, body) {
// e = checkError(e, resp, 200);
// if (e) return cb(e);
// let result: any = {};
// result.titleSlug = body.data.todayRecord[0].question.titleSlug;
// result.questionId = body.data.todayRecord[0].question.questionId;
// result.fid = body.data.todayRecord[0].question.questionFrontendId;
// result.date = body.data.todayRecord[0].data;
// result.userStatus = body.data.todayRecord[0].userStatus;
// return cb(null, result);
// });
cb(null, {})
};

/* A function that is used to get the user contest ranking information. */
getUserContestP = (username, cb) => {
const opts = makeOpts(configUtils.sys.urls.noj_go);
opts.headers.Origin = configUtils.sys.urls.base;
opts.headers.Referer = configUtils.sys.urls.u.replace("$username", username);

opts.json = true;
opts.body = {
variables: {
userSlug: username,
},
query: [
" query userContestRankingInfo($userSlug: String!) {",
" userContestRanking(userSlug: $userSlug) {",
" attendedContestsCount",
" rating",
" globalRanking",
" localRanking",
" globalTotalParticipants",
" localTotalParticipants",
" topPercentage",
" }",
// ' userContestRankingHistory(userSlug: $userSlug) {',
// ' attended',
// ' totalProblems',
// ' trendingDirection',
// ' finishTimeInSeconds',
// ' rating',
// ' score',
// ' ranking',
// ' contest {',
// ' title',
// ' titleCn',
// ' startTime',
// ' }',
// ' }',
" }",
].join("\n"),
};

// request.post(opts, function (e, resp, body) {
// e = checkError(e, resp, 200);
// if (e) return cb(e);

// return cb(null, body.data);
// });
cb(null, {})
};

getHelpOnline = (problem, _, lang) => {
getHelpEn(problem, lang, function (e, solution) {
if (e) return;
Expand Down