njuCoursesPart1

补选南京大学的通识课(上)

目前为 2015-03-04 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name njuCoursesPart1
  3. // @namespace http://handsomeone.com
  4. // @description 补选南京大学的通识课(上)
  5. // @include http://*.nju.edu.cn:8080/jiaowu/student/elective/courseList.do?method=discussRenewCourseList&campus=*
  6. // @version 2
  7. // @grant none
  8. // ==/UserScript==
  9. domain = window.location.hostname.slice(0, - 11);
  10. inputs = document.getElementsByTagName('input');
  11. campus = document.getElementById('campusList').options[document.getElementById('campusList').selectedIndex].value;
  12. if (inputs.length == 1) {
  13. window.location.href = 'http://' + domain + '.nju.edu.cn:8080/jiaowu/student/elective/courseList.do?method=discussRenewCourseList&campus=' + campus;
  14. }
  15. else {
  16. luck = inputs[parseInt(Math.random() * (inputs.length - 1))];
  17. name = luck.parentNode.parentNode.childNodes[2].innerHTML;
  18. if (localStorage.i) {
  19. localStorage.i = eval(localStorage.i) + 1;
  20. localStorage.n += ' ' + name;
  21. }
  22. else {
  23. localStorage.i = 1;
  24. localStorage.n = name;
  25. }
  26. window.location.href = 'http://' + domain + '.nju.edu.cn:8080/jiaowu/student/elective/courseList.do?method=submitDiscussRenew&classId=' + luck.value + '&campus=' + campus;
  27. }