// ==UserScript== // @name 国科大人文讲座抢课脚本 // @namespace http://tampermonkey.net/ // @version 2025-04-21 // @description 只在包含指定课程信息的行中寻找并点击对应的“报名”按钮,需要用户更新网页上"讲座名称"信息 // @author You // @match https://xkcts.ucas.ac.cn:8443/subject/humanityLecture // @icon https://www.google.com/s2/favicons?sz=64&domain=ai1.bar // @grant none // @license MIT // @downloadURL none // ==/UserScript== (function() { // 根据指定的课程标题查找包含该信息的行,并在该行中寻找“报名”按钮 function getEnrollmentButton() { // 假设课程信息集中在 标签内 var rows = document.querySelectorAll("tr"); for (var i = 0; i < rows.length; i++) { // 判断当前行是否包含目标课程标题(需要用户自行更新) if (rows[i].textContent.indexOf("M1055雁栖湖主会场") > -1) { // 在该行内查找所有链接或按钮 var buttons = rows[i].querySelectorAll("a, button"); // 根据需求,你可以选择第一个或进行更细致的筛选 for (var j = 0; j < buttons.length; j++) { if (buttons[j].textContent.indexOf("报名") > -1) { return buttons[j]; // 返回目标行中第一个“报名”按钮 } } } } return null; // 若未找到则返回 null } // 每隔6秒执行一次检测 setInterval(function() { var enrollBtn = getEnrollmentButton(); if (enrollBtn) { console.log("检测到目标行内的报名按钮,立即点击注册!"); enrollBtn.click(); // 点击后延迟2秒再刷新页面 setTimeout(function() { location.reload(); }, 2000); } else { console.log("未在目标行中检测到报名按钮,继续等待..."); } }, 60000); })();