// ==UserScript== // @name njuCoursesPart1 // @namespace http://handsomeone.com // @description 补选南京大学的通识课(上) // @include http://*.nju.edu.cn:8080/jiaowu/student/elective/courseList.do?method=discussRenewCourseList&campus=* // @version 2 // @grant none // @downloadURL none // ==/UserScript== domain = window.location.hostname.slice(0, - 11); inputs = document.getElementsByTagName('input'); campus = document.getElementById('campusList').options[document.getElementById('campusList').selectedIndex].value; if (inputs.length == 1) { window.location.href = 'http://' + domain + '.nju.edu.cn:8080/jiaowu/student/elective/courseList.do?method=discussRenewCourseList&campus=' + campus; } else { luck = inputs[parseInt(Math.random() * (inputs.length - 1))]; name = luck.parentNode.parentNode.childNodes[2].innerHTML; if (localStorage.i) { localStorage.i = eval(localStorage.i) + 1; localStorage.n += ' ' + name; } else { localStorage.i = 1; localStorage.n = name; } window.location.href = 'http://' + domain + '.nju.edu.cn:8080/jiaowu/student/elective/courseList.do?method=submitDiscussRenew&classId=' + luck.value + '&campus=' + campus; }