Skip to content

Commit ac7afab

Browse files
committed
feat: 放宽课程匹配逻辑 (#8)
1 parent 40c38ff commit ac7afab

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

courseGrabber.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
const RETRY_DELAY = 3000; // 重试延迟(毫秒)
5555
const CONCURRENT_ENABLED = true; // 是否启用并发抢课
5656
const CLICK2EXPEND_ENABLED = true; // 用户设置: 是否在 jQuery 后自动展开目标课程信息,用于时间筛选和教师筛选
57-
57+
5858
let click2expend_enabled = true; // 用于脚本自动关闭
5959

6060
// ========== 过滤器配置 ==========
@@ -185,13 +185,30 @@
185185
const kcmcLink = kcmcSpan.querySelector('a');
186186
if (kcmcLink) {
187187
const courseName = kcmcLink.textContent.trim();
188-
// 精确匹配或包含匹配
189-
if (courseName === input || courseName.includes(input)) {
188+
// 宽松匹配:只要a元素内容包含用户输入就匹配(不区分大小写)
189+
if (courseName.toLowerCase().includes(input.toLowerCase())) {
190190
matched = true;
191191
}
192192
}
193193
}
194194
}
195+
/*
196+
<div class="panel-heading kc_head" onclick="loadJxbxxZzxk(this)"
197+
style="background-color:#C1FFC1;">
198+
<h3 class="panel-title"><span class="kcmc" id="kcmc_23005523">(23005523)<a
199+
href="javascript:void(0);"
200+
onclick="showCourseInfo('23005523')">质量管理</a><i class="l-kc-xf"
201+
style="display: inline;"> - <i id="xf_23005523">5.0</i>
202+
学分</i></span><span>教学班个数:<font class="jxbgsxx">4</font></span><span
203+
id="zt_txt_23005523">状态:<b>已选</b></span></h3><input type="hidden"
204+
name="kch_id" value="23005523"><input type="hidden" name="kcxzzt"
205+
id="kcxzzt_23005523" value="1"><input type="hidden" name="cxbj"
206+
id="cxbj_23005523" value="0"><input type="hidden" name="fxbj" id="fxbj_23005523"
207+
value="0"><input type="hidden" name="xxkbj" id="xxkbj_23005523" value="0"><input
208+
type="hidden" name="czzt" value="0"><a href="javascript:void(0);"
209+
class="expand_close expand1">展开关闭</a>
210+
</div>
211+
*/
195212

196213
if (matched) {
197214
// 直接触发 click(等价于用户点击)
@@ -383,7 +400,7 @@
383400

384401
// 方法1:直接遍历所有教学班行,按课程号或课程名称匹配
385402
const allRows = document.querySelectorAll('table tbody tr.body_tr');
386-
403+
387404
for (let row of allRows) {
388405
if (isRowMatchingCourse(row, input)) {
389406
const selectButton = row.querySelector('button, a, input[type="button"]');

0 commit comments

Comments
 (0)