getCanvasCourseCode

getCanvasCourseCode and show on the top of the page

  1. // ==UserScript==
  2. // @name getCanvasCourseCode
  3. // @name:en getCanvasCourseCode
  4. // @name:zh 获取Canvas课程代码
  5. // @namespace getCanvasCourseCode
  6. // @match *://*canvas*/courses
  7. // @grant none
  8. // @version 1.1.2
  9. // @author wznmickey
  10. // @description:en get Canvas Course Code and show on the top of the page
  11. // @description:zh 获取Canvas课程代码并展示在页面顶部
  12. // @license Apache License 2.0
  13. // @language
  14. // @description getCanvasCourseCode and show on the top of the page
  15. // ==/UserScript==
  16. function getCode() {
  17. try {
  18. temp = document.getElementsByClassName("course-list-table-row");
  19. data = [];
  20. for (let i = 0; i < temp.length; i++) {
  21. try {
  22. url = temp[i].getElementsByClassName("course-list-course-title-column")[0].lastElementChild;
  23. x = url.href.split("/");
  24. y = x[x.length - 1]
  25. data.push(Number(y));
  26. }
  27. catch (err) {
  28. console.log(err);
  29. }
  30. }
  31. ans = { "courseIDs": data };
  32. return JSON.stringify(ans);
  33. }
  34. catch (err) {
  35.  
  36. }
  37. }
  38. function showID(st) {
  39. x = document.createElement("div");
  40. x.innerHTML = st;
  41. y = document.getElementsByClassName("header-bar")[0].parentNode;
  42. y.insertBefore(x, document.getElementsByClassName("header-bar")[0]);
  43. console.log(st);
  44. }
  45. showID(getCode());
  46.  

QingJ © 2025

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