// ==UserScript== // @name 电子科技大学教务助手 // @namespace http://shawroger.gitee.io/ // @version 0.0.1 // @description 电子科技大学教务助手帮你更便捷地使用教务系统 // @author shawroger // @match *://eams.uestc.edu.cn/eams/* // @require https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js // @icon https://www.uestc.edu.cn/favicon.ico // @downloadURL none // ==/UserScript== var loopRunCheckPlan = true; // 跳转首页 function toHome() { window.location.href = `http://eams.uestc.edu.cn/eams`; } // 判断是否在选课页面 function isStdElectCourse() { return window.location.href.includes("stdElectCourse"); } // 注入全局 CSS 样式 function injectCSS() { const head = $("head"); const css = ` `; head.append(css); } function bindAction() { const btn = $("#reset_btn"); btn.click(toHome); } // 注入 HTML 代码 function injectHTML() { const div = $("body"); const html = `

欢迎使用教务系统小助手

`; div.prepend(html); } // 监听教务系统是否显示不正常 function listenBrokenFrame() { const bar = $("#position_bar"); if (bar.length === 0 && !isStdElectCourse()) { $("#helper-text").text("教务系统页面显示异常,即将自动重置"); $("#helper-text").css("color", "red"); // 等待1.5秒后跳回 setTimeout(toHome, 1500); } } // 重整布局 function resetLayout() { $("img[src = '/eams/avatar/my.action']").hide(); if (window.location.href.includes("home!submenus.action?")) { const node = $("div.list_box_1 li.li_1").last().clone(true); const itemConfig = [ { text: "快速查询成绩", img: "https://pic.imgdb.cn/item/60ead77f5132923bf8f3f56b.png", href: "http://eams.uestc.edu.cn/eams/teach/grade/course/person!search.action?semesterId=303&projectType=", }, { text: "审阅我的计划", img: "https://pic.imgdb.cn/item/60eadacf5132923bf8ffcca2.png", href: "http://eams.uestc.edu.cn/eams/myPlanCompl.action", }, ]; itemConfig.forEach(({ text, img, href }) => { node.find("h3").text(text); node.find("a").attr("href", href); node.find("div").css("background", `url("${img}") no-repeat 50% 50%`); $("div.list_box_1 li.li_1") .last() .parent() .append(`
  • ` + node.html() + `
  • `); }); } } function addBottomText() { const footer = $("#BottomBg"); footer.html( footer.text() + `

    页面启用了电子科技大学教务助手 Made by Shawroger` ); } // 计划完成情况 function checkPlan() { if (!window.location.href.includes("myPlanCompl.action")) { return; } else { loopRunCheckPlan = false; } const table = $("table.formTable"); table.find("tr").each((_, e) => { const tr = $(e); tr.find("td").each((_, e) => { const td = $(e); const text = td.text().trim(); if (text === "否") { tr.css("background", "Maroon"); tr.find("td").each((_, e) => { $(e).css("color", "white"); }); } else if (["P", "A", "通过"].includes(text) || parseInt(text) >= 80) { tr.css("background", "LightSeaGreen"); } else if (70 <= parseInt(text) && parseInt(text) < 80) { tr.css("background", "LawnGreen"); } else if (60 <= parseInt(text) && parseInt(text) < 70) { tr.css("background", "NavajoWhite"); } }); }); } (function () { "use strict"; injectCSS(); injectHTML(); resetLayout(); addBottomText(); listenBrokenFrame(); setInterval(() => { listenBrokenFrame(); if (loopRunCheckPlan) { checkPlan(); } }, 200); bindAction(); checkPlan(); })();