Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Commit

Permalink
修复培训专题课程不正常工作,需要手动点击加载更多的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
snchengqi committed Mar 13, 2024
1 parent 5cbdc2c commit b25ae48
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Course Robot中文译为课程机器人,是用于辅助学习“知学云”

以Chrome浏览器为例安装Course Robot扩展程序,其它浏览器大同小异。

1. 获取course-robot扩展程序安装包,Edge浏览器可在[微软应用商店](https://microsoftedge.microsoft.com/addons/detail/course-robot/iccmcglahjfomdcjgegidnjhjnajbfpo?hl=zh-CN)获取,其它浏览器下载[zip压缩包](https://gitee.com/snchengqi/course-robot/releases/download/1.3.0/course-robot.zip)
1. 获取course-robot扩展程序安装包,Edge浏览器可在[微软应用商店](https://microsoftedge.microsoft.com/addons/detail/course-robot/iccmcglahjfomdcjgegidnjhjnajbfpo?hl=zh-CN)获取,其它浏览器下载[zip压缩包](https://gitee.com/snchengqi/course-robot/releases/download/1.4.0/course-robot.zip)

2. 浏览器【设置-隐私和安全-网站设置-弹出式窗口和重定向-允许发送弹出式窗口并使用重定向列表】,添加https://kc.zhixueyun.com (如果公司知识中心三级域名不是kc.zhixueyun.com,则自行查看添加,或者设置默认允许网站可以发送弹出式窗口并使用重定向)

Expand Down
Binary file modified course-robot.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "course-robot",
"version": "1.3.0",
"version": "1.4.0",
"description": "The Course Robot For ZhiXueYun",
"private": true,
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "Course Robot",
"version": "1.3.0",
"version": "1.4.0",
"description": "The Course Robot For ZhiXueYun",
"author": "qi.cheng",
"icons": {
Expand Down
2 changes: 1 addition & 1 deletion size-plugin.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/core/special.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {config} from '../util/config.js'
import {waitUtil} from '../util/common.js'
import {waitUtil, doUntil} from '../util/common.js'

const urlSubjectPattren = `^${config.baseUrlPattern}/#/study/subject/detail/[^]*$`
const urlTrainNewPattren = `^${config.baseUrlPattern}/#/train-new/[^]*$`
Expand Down Expand Up @@ -97,7 +97,7 @@ class TrainNewSpecial extends Special {
const condition = () => this.findActivityDoms()[this.activityIndex].lastElementChild.firstElementChild.lastElementChild !== '展开'
await waitUtil(condition)
}
await waitUtil(() => {
await doUntil(() => {
const noMore = this.findActivityDoms()[this.activityIndex].getElementsByClassName('no-more')
return noMore && noMore.length > 0
}, () => {
Expand Down
18 changes: 18 additions & 0 deletions src/util/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,22 @@ export const waitUtil = (condition, func) => {
}
}, 500);
})
}

export const doUntil = (condition, func) => {
return new Promise(resolve => {
if (condition()) {
resolve()
return
}
const taskId = setInterval(() => {
if (condition()) {
clearInterval(taskId)
resolve()
}
if (func) {
func()
}
}, 500);
})
}

0 comments on commit b25ae48

Please sign in to comment.