-
Notifications
You must be signed in to change notification settings - Fork 4
/
evaluate.min.js
1 lines (1 loc) · 2.15 KB
/
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()})();