TsinghuaCourseConflictMarker

Tsinghua Course Time Confliction Marker

当前为 2020-08-07 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name TsinghuaCourseConflictMarker
  3. // @namespace https://github.com/ZenithalHourlyRate
  4. // @homepageURL https://github.com/ZenithalHourlyRate/thuservices
  5. // @version 1
  6. // @description Tsinghua Course Time Confliction Marker
  7. // @author Zenithal
  8. // @match http://zhjwxk.cic.tsinghua.edu.cn/xkBks.vxkBksXkbBs.do?m=selectKc*
  9. // @match http://zhjwxkyw.cic.tsinghua.edu.cn/xkBks.vxkBksXkbBs.do?m=selectKc*
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13.  
  14. function courseConflict(){
  15.  
  16. var a=document.getElementById('iframe2').contentWindow.document.getElementsByClassName("trunk");// get the iframe of selected courses
  17. var b=[];
  18. for(var i=0;i!=a.length;++i){
  19. if(a[i].text.match(/.-.(.*)/gi)){ // get the span with time information
  20. if(a[i].title == ""){ // some text is abbrevated
  21. b.push(a[i].text)
  22. }else{
  23. var c=a[i].title.split(","); // some has multiple time
  24. for(var j=0;j!=c.length;++j){
  25. b.push(c[j]);
  26. }
  27. }
  28. }
  29. }
  30.  
  31. var d=document.getElementById('iframe1').contentWindow.document.getElementsByClassName("trunk");
  32. for(i=0;i!=d.length;++i){
  33. if(d[i].text.match(/.-.(.*)/gi)){
  34. var e=""
  35. if(d[i].title == ""){
  36. e=d[i].text;
  37. } else {
  38. e=d[i].title;
  39. }
  40. var f=e.split(',');
  41. for(j=0;j!=f.length;++j){
  42. for(var k=0;k!=b.length;++k){
  43. if(f[j][0]==b[k][0] && f[j][2]==b[k][2]){ // just comparison on time, no comparison on others
  44. d[i].style.color="#ff0000"
  45. }
  46. }
  47. }
  48. }
  49. }
  50.  
  51. }
  52.  
  53. (function() {
  54. document.getElementById('iframe1').onload=courseConflict;
  55. document.getElementById('iframe2').onload=courseConflict;
  56. })();