@@ -672,6 +672,116 @@ and csrf token to the user object and saves the user object to the session. */
672
672
} ) ;
673
673
} ) ;
674
674
} ;
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
+
675
785
getHelpOnline = ( problem , _ , lang ) => {
676
786
getHelpEn ( problem , lang , function ( e , solution ) {
677
787
if ( e ) return ;
0 commit comments