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

Commit

Permalink
修改域名校验规则,不再校验三级域名,只校验二级域名 zhixueyun.com
Browse files Browse the repository at this point in the history
  • Loading branch information
snchengqi committed Nov 30, 2023
1 parent 0188ed4 commit 5cbdc2c
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 92 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ 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.2.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.3.0/course-robot.zip)

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

![](./public/images/options/2022-08-28-12-23-50-1661660626221.jpg)![](./public/images/options/2022-08-28-12-26-08-1661660762546.jpg)![](./public/images/options/2022-08-28-12-28-48-1661660895453.jpg)![](./public/images/options/2022-08-28-12-31-04-1661661057301.jpg)

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.2.0",
"version": "1.3.0",
"description": "The Course Robot For ZhiXueYun",
"private": true,
"scripts": {
Expand Down
71 changes: 0 additions & 71 deletions public/Course Robot使用说明.md

This file was deleted.

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.2.0",
"version": "1.3.0",
"description": "The Course Robot For ZhiXueYun",
"author": "qi.cheng",
"icons": {
Expand Down
10 changes: 4 additions & 6 deletions public/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -1265,14 +1265,12 @@ <h2 class="atx" id="兼容性">兼容性</h2>
<h2 class="atx" id="安装说明">安装说明</h2>
<p>以Chrome浏览器为例安装Course Robot扩展程序,其它浏览器大同小异。</p>
<ol>
<li><p>浏览器【设置-隐私和安全-网站设置-弹出式窗口和重定向-允许发送弹出式窗口并使用重定向列表】,添加<a href="https://kc.zhixueyun.com">https://kc.zhixueyun.com</a></p>
<p><img alt="" src="./images/options/2022-08-28-12-23-50-1661660626221.jpg"><img alt="" src="./images/options/2022-08-28-12-26-08-1661660762546.jpg"><img alt="" src="./images/options/2022-08-28-12-28-48-1661660895453.jpg"><img alt="" src="./images/options/2022-08-28-12-31-04-1661661057301.jpg"></p>
<li><p>获取course-robot扩展程序安装包,Edge浏览器可在<a href="https://microsoftedge.microsoft.com/addons/detail/course-robot/iccmcglahjfomdcjgegidnjhjnajbfpo?hl=zh-CN">微软应用商店</a>获取,其它浏览器下载<a href="https://gitee.com/snchengqi/course-robot/releases/download/1.3.0/course-robot.zip">zip压缩包</a></p>
</li>
<li><p>下载安装包course-robot.zip(不要下载源码),可以在项目目录下载,也可以选择发布的版本下载。</p>
<p><img alt="" src="./images/options/1695264512354.jpg"></p>
<p><img alt="" src="./images/options/1695264573541.jpg"></p>
<li><p>浏览器【设置-隐私和安全-网站设置-弹出式窗口和重定向-允许发送弹出式窗口并使用重定向列表】,添加<a href="https://kc.zhixueyun.com">https://kc.zhixueyun.com</a> (如果公司知识中心三级域名不是kc.zhixueyun.com,则自行查看添加,或者设置默认允许网站可以发送弹出式窗口并使用重定向)</p>
<p><img alt="" src="./images/options/2022-08-28-12-23-50-1661660626221.jpg"><img alt="" src="./images/options/2022-08-28-12-26-08-1661660762546.jpg"><img alt="" src="./images/options/2022-08-28-12-28-48-1661660895453.jpg"><img alt="" src="./images/options/2022-08-28-12-31-04-1661661057301.jpg"></p>
</li>
<li><p>将安装包解压缩,然后打开浏览器扩展程序管理界面,打开开发者模式,加载已解压的扩展程序,选择刚刚解压缩的course-robot文件夹。</p>
<li><p>如果你是下载的zip压缩包(如果你是通过微软商店获取,则默认已经完成安装,直接跳过此步骤。),将安装包解压缩,然后打开浏览器扩展程序管理界面,打开开发者模式,加载已解压的扩展程序,选择刚刚解压缩的course-robot文件夹。</p>
<p><img alt="" src="./images/options/2022-08-28-16-12-53-1661674365048.jpg"><img alt="" src="./images/options/2022-08-28-16-17-27-1661674639981.jpg"><img alt="" src="./images/options/2022-08-28-16-20-04-1661674788304.jpg"><img alt="" src="./images/options/2022-08-28-16-21-51-1661674907614.jpg"></p>
</li>
<li><p>将程序固定到浏览器工具栏</p>
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/course.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ const notifyFinish = () => {
export const createCourse = () => {
return new Promise((resolve) => {
const currentUrl = window.location.href
const urlPrefix = `${config.baseUrl}/#/study/course/detail`
if (!currentUrl || currentUrl.indexOf(urlPrefix) !== 0) {
const urlRegExp = new RegExp(`^${config.baseUrlPattern}/#/study/course/detail/[^]*$`, 'g')
if (!currentUrl || !urlRegExp.test(currentUrl)) {
resolve(new OtherCourse())
return
}
Expand Down
14 changes: 9 additions & 5 deletions src/core/special.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import {config} from '../util/config.js'
import {waitUtil} from '../util/common.js'

const urlPrefixSubject = `${config.baseUrl}/#/study/subject/detail`
const urlPrefixTrainNew = `${config.baseUrl}/#/train-new`
const urlSubjectPattren = `^${config.baseUrlPattern}/#/study/subject/detail/[^]*$`
const urlTrainNewPattren = `^${config.baseUrlPattern}/#/train-new/[^]*$`
const urlSubjectRegExp = new RegExp(urlSubjectPattren, 'g')
const urlTrainNewRegExp = new RegExp(urlTrainNewPattren, 'g')
//专题顶层抽象
class Special {

Expand Down Expand Up @@ -163,13 +165,15 @@ const isNotSpecial = () => {
const isCommonSpecial = () => {
const currentUrl = window.location.href
const items = document.getElementsByClassName('item current-hover')
return currentUrl.indexOf(urlPrefixSubject) === 0 && items && items.length > 0
// return currentUrl.indexOf(urlPrefixSubject) === 0 && items && items.length > 0
return urlSubjectRegExp.test(currentUrl) && items && items.length > 0
}

const isTrainNewSpecial = () => {
const currentUrl = window.location.href
const items = document.getElementsByClassName('section')
return currentUrl.indexOf(urlPrefixTrainNew) === 0 && items && items.length > 0
// return currentUrl.indexOf(urlPrefixTrainNew) === 0 && items && items.length > 0
return urlTrainNewRegExp.test(currentUrl) && items && items.length > 0
}

const isFirstParticularSpecial = () => {
Expand All @@ -186,7 +190,7 @@ const complateInShcedule = (resolve, specail, taskId) => {
export const createSpecial = () => {
return new Promise((resolve) => {
const currentUrl = window.location.href
if (!currentUrl || (currentUrl.indexOf(urlPrefixSubject) !== 0 && currentUrl.indexOf(urlPrefixTrainNew) !== 0)) {
if (!currentUrl || (!urlSubjectRegExp.test(currentUrl) && !urlTrainNewRegExp.test(currentUrl))) {
resolve(new IllegalSpecial())
return
}
Expand Down
5 changes: 3 additions & 2 deletions src/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {config} from './util/config.js'
const validUrl = require('valid-url')
const startWorkText = '开始学习'
const stopWorkText = '结束学习'
const baseUrl = config.baseUrl
const baseUrlPattern = config.baseUrlPattern
// https://kc.zhixueyun.com/#/study/subject/detail/52d4b3dd-b6c9-4b33-b86e-1ea132aedfc6

const startWork = (specialTopicIpt, startWorkBtn) => {
Expand Down Expand Up @@ -50,7 +50,8 @@ const initPopup = async () => {
initStatus(specialTopicIpt, startWorkBtn, specialTopic, btnText)
specialTopicIpt.addEventListener('input', () => {
specialTopic = specialTopicIpt.value
if (specialTopic && specialTopic !== '' && validUrl.isWebUri(specialTopic) && specialTopic.indexOf(baseUrl) === 0) {
const regExp = new RegExp(`^${baseUrlPattern}/[^]*$`, 'g')
if (specialTopic && specialTopic !== '' && validUrl.isWebUri(specialTopic) && regExp.test(specialTopic)) {
startWorkBtn.disabled = false
} else {
startWorkBtn.disabled = true
Expand Down
2 changes: 1 addition & 1 deletion src/util/config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const config = {
baseUrl: 'https://kc.zhixueyun.com'
baseUrlPattern: 'https://[^]+.zhixueyun.com'
}

0 comments on commit 5cbdc2c

Please sign in to comment.