// ==UserScript== // @name 电子科技大学教务助手 // @namespace http://shawroger.gitee.io/ // @version 0.0.2 // @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== function initStorage() { let initState = 1; if ( window.localStorage.getItem("UESTC_STUDYSYS_HELPER_SHOWBAR_ALL") === null ) { window.localStorage.setItem("UESTC_STUDYSYS_HELPER_SHOWBAR_ALL", "1"); return initState; } else { try { initState = JSON.parse( window.localStorage.getItem("UESTC_STUDYSYS_HELPER_SHOWBAR_ALL") ); } catch (e) { initState = 1; window.localStorage.setItem("UESTC_STUDYSYS_HELPER_SHOWBAR_ALL", "1"); } finally { return initState; } } } let loopVars = { renderPlan: true, renderScore: true, }; const itemConfig = [ { text: "查询平时成绩", img: "https://pic.imgdb.cn/item/60ead7fd5132923bf8f5b136.png", href: "http://eams.uestc.edu.cn/eams/teach/grade/usual/usual-grade-std.action", }, { text: "快速查询成绩", img: "https://pic.imgdb.cn/item/60ead77f5132923bf8f3f56b.png", href: "http://eams.uestc.edu.cn/eams/teach/grade/course/person.action", }, { text: "审阅我的计划", img: "https://pic.imgdb.cn/item/60eadacf5132923bf8ffcca2.png", href: "http://eams.uestc.edu.cn/eams/myPlanCompl.action", }, ]; function hrefContains(url) { return window.location.href.includes(url); } // 跳转首页 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 resetBtn = $("#reset_btn"); resetBtn.click(toHome); const closeBtn = $("#close_btn"); closeBtn.click(() => { $(".uestc-helper-box").hide(); window.localStorage.setItem("UESTC_STUDYSYS_HELPER_SHOWBAR_ALL", "0"); toHome(); }); const showBtn = $("#show_btn"); showBtn.click(() => { $(".uestc-helper-box").show(); window.localStorage.setItem("UESTC_STUDYSYS_HELPER_SHOWBAR_ALL", "1"); toHome(); }); } // 注入 HTML 代码 function injectHTML() { if (initStorage()) { const div = $("body"); const html = `
`; div.prepend(html); } else { const div = $("form[action='/eams/home.action']"); const html = ``; div.append(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 (hrefContains("home!submenus.action?")) { const node = $("div.list_box_1 li.li_1").last().clone(true); 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(`