USTC Teacher Email

Get Teacher Email

  1. // ==UserScript==
  2. // @name USTC Teacher Email
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.3
  5. // @description Get Teacher Email
  6. // @author txtxj
  7. // @match https://jw.ustc.edu.cn/home*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=github.com
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. $(window).on("load", function() {
  13.  
  14. 'use strict';
  15.  
  16. let title = document.getElementById("e-top-home-page");
  17. let li = document.createElement("li");
  18. li.setAttribute("class", "tabLi active");
  19. let btn = document.createElement("a");
  20. btn.href = "javascript:void(0)";
  21. btn.onclick = function() {
  22. var teacherName = prompt("请输入老师姓名\n搜索需要用时约 30 秒\n搜索结果将以弹窗形式给出\n详细输出可在控制台查看");
  23.  
  24. async function getTeacherEmail(teacher, terms=10, interval=3) {
  25. // 学期 id 配置
  26. const POOL = ["281", "261", "241", "221", "202", "201", "281", "261", "181", "161", "141", "121", "101", "81", "62", "61", "39", "35", "23", "38", "20", "43", "21", "34", "42", "37", "17", "41", "18", "33", "22", "9", "19", "40", "36", "32", "10", "24", "44", "25", "11", "47", "46", "45", "27", "51", "50", "12", "26", "49", "48", "8", "7", "31", "6", "16", "5", "30", "4", "15", "3", "29", "2", "1", "14", "28", "53", "52", "13"];
  27.  
  28. // 首先获取学生查询的标识码
  29. const queryDoc = await $.ajax({
  30. url: "https://jw.ustc.edu.cn/for-std/lesson-search",
  31. });
  32. const student_id = queryDoc.match(
  33. /\/for-std\/lesson-search\/index\/(\d*)/
  34. )[1];
  35.  
  36. // 查找老师教的课程 id
  37. const course_id = await (async () => {
  38. for (let i = 0; i < terms; i++) {
  39. const courses_url = `https://jw.ustc.edu.cn/for-std/lesson-search/semester/${POOL[i]}/search/${student_id}?teacherNameLike=${teacher}`;
  40. const courses_info = await $.ajax({ url: courses_url });
  41. if (courses_info.data && courses_info.data.length) {
  42. const courses_teachers = courses_info.data.map((course) => ({
  43. teachers: course.teacherAssignmentList.map((teacher_object) => teacher_object.person.nameZh),
  44. id: course.id
  45. })).filter((course_teachers) => course_teachers.teachers.includes(teacher))
  46. if (courses_teachers)
  47. return courses_teachers[0].id;
  48. }
  49. console.log(`第 ${i + 1} 个学期查询失败,正在等待 ${interval} 秒...`);
  50. await new Promise((r) => setTimeout(r, interval * 1000));
  51. }
  52. })();
  53.  
  54. if (typeof(course_id) == "undefined") {
  55. alert(`没有找到${teacherName}`);
  56. return;
  57. }
  58.  
  59. // 根据课程 id,查询邮箱
  60. const email_url = `https://jw.ustc.edu.cn/ws/course-adjustment-apply/get-teacher-info?lessonId=${course_id}`;
  61. const email_res = await $.ajax({ url: email_url });
  62.  
  63. email_res.forEach((object) => {
  64. if (object[teacher]) {
  65. console.log(object[teacher]);
  66. alert(object[teacher]);
  67. }
  68. });
  69.  
  70. }
  71.  
  72. getTeacherEmail(teacherName);
  73. }
  74. btn.id = "teacher-email";
  75. btn.innerHTML = " 邮箱 ";
  76. title.appendChild(li);
  77. li.appendChild(btn);
  78.  
  79. let space = document.getElementsByClassName("toolbarView nav navbar-nav ")[0];
  80. space.style.width = "65%";
  81. });

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址