├── LICENSE ├── Makefile ├── README.md ├── evaluate.js └── evaluate.min.js /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Tianyang Xu 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | uglify: 2 | uglify -s evaluate.js -o evaluate.min.js 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 前言 2 | --- 3 | 4 | 身为杭电人,选课是必不可免的,但是在选课之前有一项很重要的任务就是教师评价。 5 | 6 | 这是一个比较烦的事情,尤其是课程比较多的时候。 7 | 8 | 这个时候,这个脚本或许可以帮你你减轻负担 9 | 10 | 特点 11 | --- 12 | 13 | - 一键操作,自动填写,自动保存,自动提交 14 | - 默认第一个为B,其他都为A 15 | - 支持多教师评价 16 | - 支持文字提示 17 | - 对用户友好 18 | 19 | 使用方式 20 | --- 21 | 22 | 1. 复制代码 23 | 2. 进入教室评价页面 24 | 3. 打开开发者面板 25 | - `Chrome` -> `菜单` -> `更多工具` -> `开发者工具` -> 切换到`Console` 26 | - `Firfox` -> `工具` -> `Web开发者` -> `切换工具箱` -> 切换到`控制台` 27 | - `IE/Edge` -> 身为Mac系统,无法打开。。。请自行寻找 28 | - `Safari` -> `开发` -> `显示 Web 检查器` -> 切换到`控制台` 29 | - `QQ/猎豹/360/傲游`等其他国产浏览器 -> 30 | - 极速模式 -> 同`Chrome` 31 | - 兼容模式 -> 同`IE` 32 | - Edge模式 -> 同`Edge` 33 | 4. 然后粘贴入复制的代码 34 | 5. Enter 35 | 6. 上个厕所等待结果吧 36 | 37 | 兼容性 38 | --- 39 | 40 | - Mac 41 | - Chrome *OK* 42 | 43 | - Window 44 | - Chrome *OK* 45 | - 360 46 | - Chrome kernel (极速模式) *OK* 47 | 48 | TODO 49 | --- 50 | 51 | - [x] 支持自定义评价等级 52 | - [ ] 允许中途暂停 53 | - [ ] 对普通用户更加友好 54 | - [ ] 多终端浏览器测试 55 | 56 | 贡献 57 | --- 58 | 直接给我提Issus或者pr就好 59 | 60 | 大家只需要修改`evaluate.js`代码,压缩版本的不需要修改,等待我审核过了之后,便更新. 61 | 62 | 欢迎大家在测试之后将浏览器的兼容性结果告诉我,我将继续更新 63 | 64 | 许可 65 | --- 66 | [MIT](LICENSE) 67 | -------------------------------------------------------------------------------- /evaluate.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | // https://github.com/hdu-coder/evaluate-teacher 3 | 'use strict'; 4 | 5 | // 请不要问我为什么不用 jQuery 去获取代码,因为,因为,TMD正方的$选择器是自己手写的 6 | // 所以我也决定手写,用它的不如自己去手写,就这么简单 7 | var slice = Array.prototype.slice; 8 | var config = { 9 | A: 1, 10 | B: 2, 11 | C: 3, 12 | D: 4, 13 | save: 'Button1', 14 | submit: 'Button2', 15 | levels: 'BAAAAAAAAA' 16 | } 17 | 18 | // 当前科目,-1表示没有开始 19 | var currentSubject = -1; 20 | 21 | // 提示框,学过VB的一定很熟悉吧 22 | var msgbox = document.createElement('div'); 23 | msgbox.style.cssText = "position: fixed;top: 0px;left: 0px;width: 100%;padding: 10px;margin: 0px;text-align: center;border: 1px solid rgb(204, 204, 204);box-shadow: black 0px 0px 10px;z-index: 10000;background: #3e3e3e;background: rgba(00,153,00,0.8);color: white;"; 24 | document.body.appendChild(msgbox); 25 | 26 | var iframe = document.getElementsByTagName('iframe')[0]; 27 | // 注册框架加载完成事件,这样可以保证无论加载多长时间,都可以正确的进行下一次处理 28 | iframe.addEventListener('load', function listener() { 29 | setTimeout(function() { 30 | if (!score()) { 31 | msg('保存完成,提交打分,2秒后自动消失,Thanks~'); 32 | iframe.removeEventListener('load', listener); 33 | submit(); 34 | setTimeout(function() { 35 | document.body.removeChild(msgbox); 36 | msgbox = null; 37 | }, 2000); 38 | return; 39 | } 40 | }, 1000) 41 | }) 42 | 43 | /** 44 | * 自动打分(score)函数 45 | * @return {Boolean} 代表这次操作是否成功,失败的可能就是已经全部处理完成了 46 | */ 47 | function score() { 48 | var fdocument = iframe.contentDocument; 49 | var subject = fdocument.getElementsByTagName('select')[0]; 50 | if (subject.selectedIndex === currentSubject) return false; 51 | msg('提交打分:' + subject.selectedOptions[0].innerText); 52 | currentSubject = subject.selectedIndex; 53 | var selects = slice.call(fdocument.getElementsByTagName('select'), 1) 54 | var column = parseInt(selects.length / 10); 55 | 56 | selects.forEach(function(select, index) { 57 | // 获取出来之后,顺序是以行,从左到右进行排列 58 | select.selectedIndex = config[config.levels[parseInt(index / column)]] 59 | }) 60 | fdocument.getElementById(config.save).click(); 61 | return true; 62 | } 63 | 64 | /** 65 | * 获取打分等级分布 66 | * 默认情况是第一个选择B,其余的选择A 67 | * 用户在弹出的输入框中输入想要的打分顺序,那么将会按照每一个都这样打分 68 | * @return {Boolean} false标识取消这次操作 69 | */ 70 | function level() { 71 | var levels; 72 | 73 | do { 74 | levels = prompt('请输入您想给老师打分的等级,一共10个字符,支持ABCD,其他均为不合法字符\n默认:第一个打B,其余9个打A\n不输入内容是选择【确定】使用默认值,选择【取消】取消此次操作'); 75 | 76 | if (levels === null) return false; 77 | }while(!check(levels)) 78 | 79 | config.levels = levels || config.levels; 80 | 81 | /** 82 | * 检测这个是否合法 83 | * @return {Boolean} 84 | */ 85 | function check(string) { 86 | if (string === '') return true; 87 | if (string.length !== 10) return false; 88 | if (!/^[A-D]{10}$/.test(string)) return false; 89 | if (/^A{10}$/.test(string)) return false; 90 | return true; 91 | } 92 | 93 | return true; 94 | } 95 | 96 | // 提交函数 97 | function submit() { 98 | iframe.contentDocument.getElementById(config.submit).click(); 99 | } 100 | 101 | // 消息现实函数 102 | function msg(string) { 103 | msgbox.innerText = string + ' By XGHeaven'; 104 | } 105 | 106 | // 获取打分等级(level)分布 107 | if (!level()) { 108 | document.body.removeChild(msgbox); 109 | msgbox = null; 110 | alert('您取消了此次操作'); 111 | return; 112 | } 113 | // 手动启动 114 | score(); 115 | })() 116 | -------------------------------------------------------------------------------- /evaluate.min.js: -------------------------------------------------------------------------------- 1 | (function(){"use strict";var slice=Array.prototype.slice;var config={A:1,B:2,C:3,D:4,save:"Button1",submit:"Button2",levels:"BAAAAAAAAA"};var currentSubject=-1;var msgbox=document.createElement("div");msgbox.style.cssText="position: fixed;top: 0px;left: 0px;width: 100%;padding: 10px;margin: 0px;text-align: center;border: 1px solid rgb(204, 204, 204);box-shadow: black 0px 0px 10px;z-index: 10000;background: #3e3e3e;background: rgba(00,153,00,0.8);color: white;";document.body.appendChild(msgbox);var iframe=document.getElementsByTagName("iframe")[0];iframe.addEventListener("load",function listener(){setTimeout(function(){if(!score()){msg("保存完成,提交打分,2秒后自动消失,Thanks~");iframe.removeEventListener("load",listener);submit();setTimeout(function(){document.body.removeChild(msgbox);msgbox=null},2e3);return}},1e3)});function score(){var fdocument=iframe.contentDocument;var subject=fdocument.getElementsByTagName("select")[0];if(subject.selectedIndex===currentSubject)return false;msg("提交打分:"+subject.selectedOptions[0].innerText);currentSubject=subject.selectedIndex;var selects=slice.call(fdocument.getElementsByTagName("select"),1);var column=parseInt(selects.length/10);selects.forEach(function(select,index){select.selectedIndex=config[config.levels[parseInt(index/column)]]});fdocument.getElementById(config.save).click();return true}function level(){var levels;do{levels=prompt("请输入您想给老师打分的等级,一共10个字符,支持ABCD,其他均为不合法字符\n默认:第一个打B,其余9个打A\n不输入内容是选择【确定】使用默认值,选择【取消】取消此次操作");if(levels===null)return false}while(!check(levels));config.levels=levels||config.levels;function check(string){if(string==="")return true;if(string.length!==10)return false;if(!/^[A-D]{10}$/.test(string))return false;if(/^A{10}$/.test(string))return false;return true}return true}function submit(){iframe.contentDocument.getElementById(config.submit).click()}function msg(string){msgbox.innerText=string+" By XGHeaven"}if(!level()){document.body.removeChild(msgbox);msgbox=null;alert("您取消了此次操作");return}score()})(); 2 | --------------------------------------------------------------------------------