11// ==UserScript==
22// @name 不学习何以强国-beta
33// @namespace http://tampermonkey.net/
4- // @version 20211221
4+ // @version 20211223
55// @description 问题反馈位置: https://github.com/TechXueXi/techxuexi-js/issues 。读文章,看视频,做习题。
66// @author techxuexi ,荷包蛋。
77// @match https://www.xuexi.cn
@@ -358,8 +358,16 @@ function doExamPractice() {
358358 } ) ;
359359}
360360
361+ //fix code = 429
362+ async function waitingDependStartTime ( startTime ) {
363+ let remainms = Date . now ( ) - startTime ;
364+ if ( remainms < ratelimitms ) {
365+ await waitingTime ( ratelimitms - remainms + 1000 )
366+ }
367+ }
361368//初始化专项答题总页数属性
362369async function InitExamPaperAttr ( ) {
370+ let startTime = Date . now ( ) ;
363371 var data = await getExamPaperByPageNo ( 1 ) ; // 默认从第一页获取全部页属性
364372 if ( data ) {
365373 // 初始化总页码
@@ -369,6 +377,7 @@ async function InitExamPaperAttr() {
369377 examPaperPageNo = examPaperTotalPageCount ;
370378 }
371379 }
380+ await waitingDependStartTime ( startTime ) ;
372381}
373382
374383//获取指定页数的专项答题列表
@@ -435,16 +444,13 @@ async function findExamPaper() {
435444 } else {
436445 continueFind = false ;
437446 }
438-
439447 //fix code = 429
440- let remainms = Date . now ( ) - startTime ;
441- if ( remainms < ratelimitms ) {
442- await waitingTime ( ratelimitms - remainms + 1000 )
443- }
448+ await waitingDependStartTime ( startTime ) ;
444449 } )
445450 }
446451 return examPaperId ;
447452}
453+
448454//做专项答题
449455function doExamPaper ( ) {
450456 return new Promise ( function ( resolve ) {
@@ -469,6 +475,7 @@ function doExamPaper() {
469475
470476//初始化每周答题总页数属性
471477async function InitExamWeeklyAttr ( ) {
478+ let startTime = Date . now ( ) ;
472479 var data = await getExamWeeklyByPageNo ( 1 ) ; // 默认从第一页获取全部页属性
473480 if ( data ) {
474481 // 初始化总页码
@@ -478,6 +485,7 @@ async function InitExamWeeklyAttr() {
478485 examWeeklyPageNo = examWeeklyTotalPageCount ;
479486 }
480487 }
488+ await waitingDependStartTime ( startTime ) ;
481489}
482490
483491//获取指定页数的每周答题列表
@@ -555,10 +563,7 @@ async function findExamWeekly() {
555563 }
556564
557565 //fix code = 429
558- let remainms = Date . now ( ) - startTime ;
559- if ( remainms < ratelimitms ) {
560- await waitingTime ( ratelimitms - remainms + 1000 )
561- }
566+ await waitingDependStartTime ( startTime ) ;
562567 } )
563568 }
564569 return examWeeklyId ;
0 commit comments