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

Commit a8a07f2

Browse files
committed
增加对人保学堂(中国人民保险的支持)
1 parent b25ae48 commit a8a07f2

File tree

6 files changed

+93
-64
lines changed

6 files changed

+93
-64
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Course Robot中文译为课程机器人,是用于辅助学习“知学云”平台网上大学课程的浏览器扩展程序。
44

5-
适用范围:中国移动、中国电信、国家电投、中国石油、中国广核集团等企业使用“知学云在线学习平台”要求完成网上课程学习的员工。
5+
适用范围:中国移动、中国电信、中国人民保险、国家电投、中国石油、中国广核集团等企业使用“知学云在线学习平台”要求完成网上课程学习的员工。
66

77
## 软件特性
88

@@ -20,7 +20,7 @@ Course Robot中文译为课程机器人,是用于辅助学习“知学云”
2020

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

23-
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)
23+
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.5.0/course-robot.zip)
2424

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

course-robot.zip

364 Bytes
Binary file not shown.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "course-robot",
3-
"version": "1.4.0",
3+
"version": "1.5.0",
44
"description": "The Course Robot For ZhiXueYun",
55
"private": true,
66
"scripts": {

public/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"manifest_version": 3,
33
"name": "Course Robot",
4-
"version": "1.4.0",
4+
"version": "1.5.0",
55
"description": "The Course Robot For ZhiXueYun",
66
"author": "qi.cheng",
77
"icons": {

size-plugin.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

src/core/course.js

Lines changed: 88 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,81 @@ class Course {
88
class CommonCourse extends Course {
99

1010
start() {
11-
if (!hasCourseNeedCountinue()) {
11+
if (!this.hasCourseNeedCountinue()) {
1212
notifyFinish()
1313
return
1414
}
1515
startCourse()
16-
checkSituation()
16+
this.checkSituation()
17+
}
18+
19+
parseInnerDom(item) {
20+
// return item.lastElementChild.lastElementChild
21+
return item.lastElementChild.children[1]
22+
}
23+
24+
isCompleted(status) {
25+
return status === '重新学习' || status === '已完成'
26+
}
27+
28+
hasCourseNeedCountinue() {
29+
const lists = Array.from(document.getElementsByClassName('chapter-list-box'))
30+
const needCoutinue = lists.some(item => {
31+
const innerDom = this.parseInnerDom(item)
32+
const type = innerDom.firstElementChild.innerHTML
33+
const status = innerDom.lastElementChild.lastElementChild.innerHTML
34+
return (type === '视频' || type === '文档') && !this.isCompleted(status)
35+
})
36+
return needCoutinue
37+
}
38+
39+
checkSituation() {
40+
const taskId = setInterval(() => {
41+
const needCoutinue = this.hasCourseNeedCountinue()
42+
if (!needCoutinue) {
43+
clearInterval(taskId)
44+
notifyFinish()
45+
} else {
46+
this.changeVideoIfNecessary()
47+
}
48+
const node = currentNode()
49+
const courseName = node.getElementsByClassName('text-overflow')[0].innerText
50+
window.document.title = `🔵正在播放【${courseName}】`
51+
}, 1000)
52+
}
53+
54+
changeVideoIfNecessary() {
55+
if (this.currentFinish()) {
56+
const nextCourse = Array.from(document.getElementsByClassName('chapter-list-box')).filter(item => {
57+
const innerDom = this.parseInnerDom(item)
58+
const type = innerDom.firstElementChild.innerHTML
59+
const status = innerDom.lastElementChild.lastElementChild.innerHTML
60+
return (type === '视频' || type === '文档') && !this.isCompleted(status)
61+
}).shift()
62+
if (nextCourse) {
63+
nextCourse.click()
64+
setTimeout(() => {
65+
startCourse()
66+
}, 1000);
67+
}
68+
} else {
69+
//有些电脑太卡,初始化时播放不了,用于兜底
70+
startCourse()
71+
}
72+
}
73+
74+
currentFinish() {
75+
const itemDom = this.parseInnerDom(currentNode())
76+
const type = itemDom.firstElementChild.innerHTML
77+
const status = itemDom.lastElementChild.lastElementChild.innerHTML
78+
return (this.isCompleted(status)) || (type === '考试' && status !== '参与考试')
79+
}
80+
}
81+
82+
class RenbaoCourse extends CommonCourse {
83+
84+
parseInnerDom(item) {
85+
return item.lastElementChild.children[1]
1786
}
1887
}
1988

@@ -43,59 +112,6 @@ const currentNode = () => {
43112
return document.getElementsByClassName('chapter-list-box focus')[0]
44113
}
45114

46-
const currentFinish = () => {
47-
const itemDom = currentNode().lastElementChild.lastElementChild
48-
const type = itemDom.firstElementChild.innerHTML
49-
const status = itemDom.lastElementChild.lastElementChild.innerHTML
50-
return (status === '重新学习') || (type === '考试' && status !== '参与考试')
51-
}
52-
53-
const changeVideoIfNecessary = () => {
54-
if (currentFinish()) {
55-
const nextCourse = Array.from(document.getElementsByClassName('chapter-list-box')).filter(item => {
56-
const innerDom = item.lastElementChild.lastElementChild
57-
const type = innerDom.firstElementChild.innerHTML
58-
const status = innerDom.lastElementChild.lastElementChild.innerHTML
59-
return (type === '视频' || type === '文档') && status !== '重新学习'
60-
}).shift()
61-
if (nextCourse) {
62-
nextCourse.click()
63-
setTimeout(() => {
64-
startCourse()
65-
}, 1000);
66-
}
67-
} else {
68-
//有些电脑太卡,初始化时播放不了,用于兜底
69-
startCourse()
70-
}
71-
}
72-
73-
const checkSituation = () => {
74-
const taskId = setInterval(() => {
75-
const needCoutinue = hasCourseNeedCountinue()
76-
if (!needCoutinue) {
77-
clearInterval(taskId)
78-
notifyFinish()
79-
} else {
80-
changeVideoIfNecessary()
81-
}
82-
const node = currentNode()
83-
const courseName = node.getElementsByClassName('text-overflow')[0].innerText
84-
window.document.title = `🔵正在播放【${courseName}】`
85-
}, 1000)
86-
}
87-
88-
const hasCourseNeedCountinue = () => {
89-
const lists = Array.from(document.getElementsByClassName('chapter-list-box'))
90-
const needCoutinue = lists.some(item => {
91-
const innerDom = item.lastElementChild.lastElementChild
92-
const type = innerDom.firstElementChild.innerHTML
93-
const status = innerDom.lastElementChild.lastElementChild.innerHTML
94-
return (type === '视频' || type === '文档') && status !== '重新学习'
95-
})
96-
return needCoutinue
97-
}
98-
99115
const notifyFinish = () => {
100116
chrome.runtime.sendMessage({event: 'finishStudyCourse'})
101117
}
@@ -113,13 +129,26 @@ export const createCourse = () => {
113129
if (domCollection && domCollection.length > 0) {
114130
clearInterval(taskId)
115131
const lists = Array.from(domCollection)
116-
const hasCourse = lists.some(item => {
117-
const innerDom = item.lastElementChild.lastElementChild
132+
let hasCourse = lists.some(item => {
133+
// const innerDom = item.lastElementChild.lastElementChild
134+
const innerDom = item.lastElementChild.children[1]
118135
const type = innerDom.firstElementChild.innerHTML
119136
return type === '视频'|| type === '文档'
120137
})
121-
const course = hasCourse? new CommonCourse(): new OtherCourse()
122-
resolve(course)
138+
if (hasCourse) {
139+
resolve(new CommonCourse())
140+
return
141+
}
142+
// hasCourse = lists.some(item => {
143+
// const innerDom = item.lastElementChild.children[1]
144+
// const type = innerDom.firstElementChild.innerHTML
145+
// return type === '视频'|| type === '文档'
146+
// })
147+
// if (hasCourse) {
148+
// resolve(new RenbaoCourse())
149+
// return
150+
// }
151+
resolve(new OtherCourse())
123152
}
124153
}, 1000);
125154
})

0 commit comments

Comments
 (0)