Created
May 21, 2013 16:22
-
-
Save polyrabbit/5621135 to your computer and use it in GitHub Desktop.
计算在东华大学各学期选修的学分
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(!new RegExp('jw.dhu.edu.cn/dhu/student/query/scorequery.jsp').test(window.location)) { | |
alert('You should run this on http://jw.dhu.edu.cn/dhu/student/query/scorequery.jsp'); | |
return; | |
} | |
var lines=[], all_trs = document.getElementsByTagName('tr'); | |
var ignore = [/形势与政策/, /军事理论/, /学术讲座/, /课外科技活动/, /社会实践/, /军训/, /学业水平考试/]; | |
for(var i=0; i<all_trs.length; ++i) | |
if(all_trs[i].children.length==12) | |
lines.push(all_trs[i]); | |
seme_score = [0,0,0,0,0,0,0,0,0,0,0,0]; | |
lines.forEach( | |
function(line){ | |
var tds=line.getElementsByTagName('td'); | |
for(var i=0; i<tds.length; ++i) { | |
itext = tds[i].innerText; | |
var should_ignore = false; | |
ignore.forEach(function(patt){if(patt.test(itext)){should_ignore=true;return;}}); | |
if(should_ignore) return; | |
if(!should_ignore && itext) | |
seme_score[i]+=parseFloat(tds[3].innerText); | |
} | |
}); | |
headers = ['1A', '1B', '2A', '2B', '3A', '3B', '4A', '4B']; | |
result = []; | |
for(var i=4; i<seme_score.length; ++i) | |
result.push(headers[i-4]+': '+seme_score[i]); | |
console.log(result.join('\n')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment