Skip to content

Commit

Permalink
Merge pull request #22 from kirakira2021/reverse-exam-bug-fix
Browse files Browse the repository at this point in the history
fix code:429 when exam; 修复上一个合并引入的答题code:429报错
  • Loading branch information
kirakira2021 authored Dec 23, 2021
2 parents 4c83651 + bbab295 commit bfec081
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
5 changes: 4 additions & 1 deletion techxuexi-js/version_info.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"techxuexi_js_version": "v20211221",
"techxuexi_js_version": "v20211223",
"notice": "...",
"techxuexi_js_update_log": [{
"version": "v20211015",
Expand All @@ -13,5 +13,8 @@
},{
"version": "v20211221",
"info": "增加倒序答题配置"
},{
"version": "v20211223",
"info": "修复上一个合并引入的code:429错误"
}]
}
25 changes: 15 additions & 10 deletions 不学习何以强国.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name 不学习何以强国-beta
// @namespace http://tampermonkey.net/
// @version 20211221
// @version 20211223
// @description 问题反馈位置: https://github.com/TechXueXi/techxuexi-js/issues 。读文章,看视频,做习题。
// @author techxuexi ,荷包蛋。
// @match https://www.xuexi.cn
Expand Down Expand Up @@ -358,8 +358,16 @@ function doExamPractice() {
});
}

//fix code = 429
async function waitingDependStartTime(startTime){
let remainms = Date.now() - startTime;
if (remainms < ratelimitms) {
await waitingTime(ratelimitms - remainms + 1000)
}
}
//初始化专项答题总页数属性
async function InitExamPaperAttr() {
let startTime = Date.now();
var data = await getExamPaperByPageNo(1); // 默认从第一页获取全部页属性
if (data) {
// 初始化总页码
Expand All @@ -369,6 +377,7 @@ async function InitExamPaperAttr() {
examPaperPageNo = examPaperTotalPageCount;
}
}
await waitingDependStartTime(startTime);
}

//获取指定页数的专项答题列表
Expand Down Expand Up @@ -435,16 +444,13 @@ async function findExamPaper() {
} else {
continueFind = false;
}

//fix code = 429
let remainms = Date.now() - startTime;
if (remainms < ratelimitms) {
await waitingTime(ratelimitms - remainms + 1000)
}
await waitingDependStartTime(startTime);
})
}
return examPaperId;
}

//做专项答题
function doExamPaper() {
return new Promise(function (resolve) {
Expand All @@ -469,6 +475,7 @@ function doExamPaper() {

//初始化每周答题总页数属性
async function InitExamWeeklyAttr() {
let startTime = Date.now();
var data = await getExamWeeklyByPageNo(1); // 默认从第一页获取全部页属性
if (data) {
// 初始化总页码
Expand All @@ -478,6 +485,7 @@ async function InitExamWeeklyAttr() {
examWeeklyPageNo = examWeeklyTotalPageCount;
}
}
await waitingDependStartTime(startTime);
}

//获取指定页数的每周答题列表
Expand Down Expand Up @@ -555,10 +563,7 @@ async function findExamWeekly() {
}

//fix code = 429
let remainms = Date.now() - startTime;
if (remainms < ratelimitms) {
await waitingTime(ratelimitms - remainms + 1000)
}
await waitingDependStartTime(startTime);
})
}
return examWeeklyId;
Expand Down

0 comments on commit bfec081

Please sign in to comment.