// ==UserScript== // @name Tsinghua GPA calculator // @namespace https://github.com/ZenithalHourlyRate // @homepageURL https://github.com/ZenithalHourlyRate/thuservices // @version 1.1 // @description Calculate the gpa on page // @author Zenithal, SuXY15 // @match http://zhjw.cic.tsinghua.edu.cn/cj.cjCjbAll.do?m=*_yxkccj* // @grant none // @license MIT // @downloadURL none // ==/UserScript== // from https://stackoverflow.com/questions/6600868 var handler = { get: function(target, name) { return target.hasOwnProperty(name) ? target[name] : -1; } }; var old_gpa_dict = new Proxy({ 'A+': 4.0, 'A': 4.0, 'A-': 3.7, 'B+': 3.3, 'B': 3.0, 'B-': 2.7, 'C+': 2.3, 'C': 2.0, 'C-': 1.7, 'D+': 1.3, 'D': 1.0, 'F': 0 }, handler); var new_gpa_dict = new Proxy({ 'A+': 4.0, 'A': 4.0, 'A-': 4.0, 'B+': 3.6, 'B': 3.3, 'B-': 3.0, 'C+': 2.6, 'C': 2.3, 'C-': 2.0, 'D+': 1.6, 'D': 1.3, 'F': 0 }, handler); (function() { var table = document.getElementsByClassName('table')[0]; var oldSum=0, newSum=0, credit=0; var rOldSum=0, rNewSum=0, rCredit=0; // Required and Restricted selective for(var i=1; i