Skip to content

Commit bfec081

Browse files
authored
Merge pull request #22 from kirakira2021/reverse-exam-bug-fix
fix code:429 when exam; 修复上一个合并引入的答题code:429报错
2 parents 4c83651 + bbab295 commit bfec081

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

techxuexi-js/version_info.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"techxuexi_js_version": "v20211221",
2+
"techxuexi_js_version": "v20211223",
33
"notice": "...",
44
"techxuexi_js_update_log": [{
55
"version": "v20211015",
@@ -13,5 +13,8 @@
1313
},{
1414
"version": "v20211221",
1515
"info": "增加倒序答题配置"
16+
},{
17+
"version": "v20211223",
18+
"info": "修复上一个合并引入的code:429错误"
1619
}]
1720
}

不学习何以强国.js

+15-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
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
//初始化专项答题总页数属性
362369
async 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
//做专项答题
449455
function doExamPaper() {
450456
return new Promise(function (resolve) {
@@ -469,6 +475,7 @@ function doExamPaper() {
469475

470476
//初始化每周答题总页数属性
471477
async 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

Comments
 (0)