auto mark

华理评选教系统轻松评分

  1. // ==UserScript==
  2. // @name auto mark
  3. // @namespace 华理评选教系统自动评分
  4. // @description 华理评选教系统轻松评分
  5. // @version 2.0
  6. // @include http://pjb.ecust.edu.cn/pingce/*
  7. // ==/UserScript==
  8.  
  9.  
  10. //辅助函数
  11. function loadStyle(css){
  12. if(typeof GM_addStyle!='undefined') {
  13. GM_addStyle(css);
  14. }
  15. else{
  16. var heads=document.getElementsByTagName('head');
  17. if(heads.length>0){
  18. var node=document.createElement('style');
  19. node.type='text/css';
  20. node.appendChild(document.createTextNode(css));
  21. heads[0].appendChild(node);
  22. }
  23. }
  24. }
  25. function $(id){
  26. 'use script';
  27. if(typeof id != 'undefined'){
  28. return document.getElementById(id);
  29. }
  30. }
  31.  
  32.  
  33. var b = document.getElementsByTagName('input');
  34. var table = document.getElementsByTagName('table')[1];
  35. var k = 0 , sum = 0;
  36. var a = [b[0]];
  37. for(var i = 0, l = b.length; i < l; i++){
  38. if(b[i].type == 'radio') {
  39. a[++k] = b[i];
  40. }
  41. }
  42. var LastVote = document.getElementsByName('yq17');
  43. var a = a.splice(0,a.length - LastVote.length);
  44. for (var i = 1, len = a.length, dif = a[1].value - a[0].value; i < len ; i++){
  45. dif = Math.abs(a[i].value - a[i == 0 ? 0 : i - 1].value) > dif ? dif : Math.abs(a[i].value - a[i - 1].value);
  46. }
  47.  
  48. var isopen = 'closed';
  49.  
  50.  
  51. //添加按钮
  52. var float_window = document.createElement('div');
  53. var float_button = document.createElement('div');
  54. var float_content = document.createElement('div');
  55. float_button.id = 'float_button';
  56. float_window.id = 'float_window';
  57. float_content.id = 'float_content';
  58. float_button.innerHTML = '<';
  59. document.body.appendChild(float_window);
  60. float_window.appendChild(float_button);
  61. float_window.appendChild(float_content);
  62. var box = '<div id = "score"></div>';
  63. box += '<div>';
  64. box += '<input type = "button" id = "haoping" value="好评"/>';
  65. box += '<input type = "button" id = "chaping" value="差评"/>';
  66. box += '<input type = "button" id = "submit" value="提交"/>';
  67. box += '</div>';
  68. box += '<p></p>';
  69. box += '<div>';
  70. box += '<input type = "checkbox" id = "noF" checked = true/>';
  71. box += '<label onclick="document.getElementById(' + ' \'noF\'' + ').click()" style="-moz-user-select:none" onselectstart="return false">不要差ですぅ</label>'
  72. box += '<input type = "button" id = "goodbtn" value="大于80"/>';
  73. box += '<div>';
  74. box += '<input type = "button" id = "suiji" value="随机"/>';
  75. box += '<label>大于等于</label>';
  76. box += '<input id = "range_low" class = "range" type="text" maxlength = 3></input>';
  77. box += '<label>小于等于</label>';
  78. box += '<input id = "range_upper" class = "range" type="text" maxlength = 3></input>';
  79. box += '</div>';
  80. box += '</div>';
  81. float_content.innerHTML = box;
  82. var hpbtn = $('haoping');
  83. var cpbtn = $('chaping');
  84. var randbtn = $('suiji');
  85. var goodbtn = $('goodbtn');
  86. var score = $('score');
  87.  
  88. var css = "@namespace url(http://www.w3.org/1999/xhtml);";
  89. css += '#float_window{ background-color:#FCFCFC;width:14px;height:14px;top:20%;right:10px;position:fixed;padding:4px;border:2px;border-radius:4px;box-shadow:0px 0px 8px #dddddd;z-index:9999; }';
  90. css += '#float_window >*{margin:2px;}';
  91. css += '#float_window input[type="button"]:not(#submit){border:1px solid #BBBBBB;border-radius:3px;background-color:#FCFCFC;margin:3px;}';
  92. css += '#float_content{background-color:#f7f7f7;padding:1px;border:1px solid rgb(221,221,221);border-radius:4px;display:none;overflow:hidden; }';
  93. css += '#float_button{background-color:whitesmoke;width:16px;height:16px;position:absolute;top:0px;right:0px;border:1px solid #BBBBBB;border-radius:4px;text-align:center;cursor:pointer;z-Index:9 }';
  94. css += '#float_window p{margin:4px;border:1px solid rgba(140, 140, 140, 0.7);}'
  95. css += '#score{margin:3px;position: relative;left:6px;font-size:14px;cursor:default;}';
  96. css += 'input.range{width:30px;}';
  97. css += '#noF{height:12px;}';
  98. css += '#noF+label{font-size:14px !important;padding-right:10px;}'
  99. css += '#submit{margin:3px 3px 3px 50px;border:1px solid #BBBBBB;border-radius:3px;background-color:#FCFCFC;}';
  100. loadStyle(css);
  101.  
  102. float_button.addEventListener('click',showmenu,false);
  103.  
  104. function showmenu(){
  105. var floatWindowWidthMax = 220;
  106. var floatWindowHeightMax = 128;
  107. var floatWindowWidthMin = 14;
  108. var floatWindowHeightMin = 14;
  109. if(isopen == 'closed'){
  110. float_button.innerHTML = '>';
  111. float_content.style.display = 'block';
  112. var w_width = floatWindowWidthMin;
  113. var w_height = floatWindowHeightMin;
  114. var timer = setInterval(function(){
  115. if(w_height < floatWindowHeightMax){
  116. float_window.style.width = w_width + 'px';
  117. float_window.style.height = w_height + 'px';
  118. float_content.style.width = w_width - 8 + 'px';
  119. float_content.style.height = w_height - 8 + 'px';
  120. w_width += (floatWindowWidthMax - floatWindowWidthMin) / 100;
  121. w_height += (floatWindowHeightMax - floatWindowHeightMin) / 100;
  122. }else{
  123. clearInterval(timer);
  124. }
  125. },5)
  126. float_window.addEventListener('mouseleave',fadeout,false);
  127. float_window.addEventListener('mouseenter',fadein,false);
  128. isopen = 'opened';
  129. }
  130. else if (isopen == 'opened'){
  131. float_window.removeEventListener('mouseleave',fadeout,false);
  132. float_window.removeEventListener('mouseenter',fadein,false);
  133. float_button.innerHTML = '<';
  134. w_width = floatWindowWidthMax;
  135. w_height = floatWindowHeightMax;
  136. var timer = setInterval(function(){
  137. if(w_width > floatWindowWidthMin){
  138. w_width -= (floatWindowWidthMax - floatWindowWidthMin) / 100;
  139. w_height -= (floatWindowHeightMax - floatWindowHeightMin) / 100;
  140. float_window.style.width = w_width + 'px';
  141. float_window.style.height = w_height + 'px';
  142. float_content.style.width = w_width - 8 + 'px';
  143. float_content.style.height = w_height - 8 + 'px';
  144. }else{
  145. clearInterval(timer);
  146. }
  147. },5)
  148. isopen = 'closed';
  149. }
  150. }
  151.  
  152. function fadeout(){
  153. var opac = float_window.style.opacity >= 1 ? float_window.style.opacity * 1 : 1;
  154. var timer = setInterval(function(){
  155. if(opac > 0.4){
  156. opac -= 0.1;
  157. float_window.style.opacity = opac;
  158. }
  159. else{
  160. clearInterval(timer);
  161. }
  162. },30)
  163. }
  164. function fadein(){
  165. var opac = float_window.style.opacity * 1;
  166. var timer = setInterval(function(){
  167. if(opac < 1.0){
  168. opac += 0.1;
  169. float_window.style.opacity = opac;
  170. }
  171. else{
  172. clearInterval(timer);
  173. }
  174. },30)
  175. }
  176.  
  177. //评价函数
  178. var noFail = $('noF').checked ? 1 : 0;
  179. score.innerHTML = '分数在' + (noFail ? '60' : '40') + '到100之间';
  180. hpbtn.addEventListener('click',haoping,false);
  181. cpbtn.addEventListener('click',chaping,false);
  182. randbtn.addEventListener('click',suiji,false);
  183. goodbtn.addEventListener('click',function(){
  184. $('range_upper').value = 100;
  185. $('range_low').value = 80;
  186. suiji();
  187. },false);
  188. $('noF').addEventListener('click',function(){
  189. noFail = $('noF').checked ? 1 : 0;
  190. score.innerHTML = '分数在' + (noFail ? '60' : '40') + '到100之间';
  191. },false)
  192. $('submit').addEventListener('click',tijiao,false);
  193.  
  194. function haoping(){
  195. sum = 0;
  196. for (var i = 1, l = a.length; i < l - 1; i++) {
  197. if(i == 1 ? 1 : (a[i].value * 1 > a[i + 1].value * 1) && a[i].value * 1 > a[i - 1].value * 1){
  198. a[i].checked = 'checked';
  199. sum += a[i].value * 1;
  200. }
  201. }
  202. zongping();
  203. score.innerHTML = '总分:' + sum;
  204. }
  205.  
  206. function chaping(){
  207. sum = 0;
  208. for (var i = 1, l = a.length; i < l ; i++){
  209. if(i == l - 1 ? 1 : (a[i].value * 1 < a[i + 1].value * 1) && a[i].value * 1 < a[i - 1].value * 1){
  210. a[i].checked = 'checked';
  211. sum += a[i].value * 1;
  212. }
  213. }
  214. zongping();
  215. score.innerHTML = '总分:' + sum;
  216. }
  217.  
  218. function suiji(){
  219. var upper = $('range_upper').value;
  220. var low = $('range_low').value;
  221.  
  222. upper = parseInt(upper == '' ? 100 : upper);
  223. low = parseInt(low == '' ? 40 : low);
  224.  
  225. var judge_value = judge(upper,low);
  226. if(judge_value){
  227. warning(Math.floor(Math.random() * 2 + 1),judge_value);
  228. $('range_upper').value = '';
  229. $('range_low').value = '';
  230. score.innerHTML = '分数在' + (noFail ? '60' : '40') + '到100之间';
  231. }
  232. else{
  233. random(upper,low);
  234. zongping();
  235. }
  236. }
  237.  
  238. //判断随机所填范围是否违规
  239. function judge(upper,low){
  240. var sum = 0;
  241. if(!(upper <= 100 && upper >= 40 && low >= 40 && low <= 100)){return 1;}
  242. if(low > upper){return 2;}
  243. if (noFail == 1 && upper < 60) {return 3};
  244. for (var i = 0; i <= 60/dif; ++i) {
  245. if(dif > 1 && upper < 40 + dif * i && low > 40 + dif * (i - 1)){
  246. return 4;
  247. }
  248. }
  249. return 0;
  250. }
  251.  
  252. //随机本体
  253. function random(upper,low){
  254. sum = 0;
  255. for(var j = 0 , l = (a.length - 1) / 4; j < l; j++){
  256. var index = Math.floor(Math.random() * (4 - noFail) + 1);
  257. a[4 * j + index].checked = true;
  258. sum += a[4 * j + index].value * 1;
  259. }
  260. var row;
  261. var line;
  262. while(sum < low || sum > upper){
  263. row = Math.floor(Math.random() * l);
  264. for(var i = 1; i < 5; i++){
  265. if(a[4 * row + i].checked == true) line = i;
  266. }
  267. if(sum < low){
  268. var min = a[4 * row + line].value * 1;
  269. line = Math.floor(Math.random() * (line - noFail) + 1);
  270. a[4 * row + line].checked = true;
  271. sum += a[4 * row + line].value * 1 - min;
  272. }
  273. if(sum > upper){
  274. var max = a[4 * row + line].value * 1;
  275. line = Math.floor(Math.random() * (5 - line - noFail) + line);
  276. a[4 * row + line].checked = true;
  277. sum -= max - a[4 * row + line].value * 1;
  278. }
  279. }
  280. score.innerHTML = '总分:' + sum;
  281. }
  282.  
  283. //校正总评
  284. function zongping(){
  285. if(sum >= 90){
  286. LastVote[0].checked = true;
  287. }else if(sum >= 70){
  288. LastVote[1].checked = true;
  289. }else if(sum >= 50){
  290. LastVote[2].checked = true;
  291. }else{
  292. LastVote[3].checked = true;
  293. }
  294. }
  295.  
  296. //提交
  297. function tijiao(){
  298. var submitbutton = new Array;
  299. for(var i = 0,n = 0,l = b .length;i < l;i++){
  300. if(b[i].type == 'submit'){
  301. submitbutton[n++] = b[i];
  302. }
  303. }
  304. submitbutton[0].click();
  305. }
  306.  
  307. //警告
  308. function warning(style,id){
  309. switch(style){
  310. case 1:
  311. switch(id){
  312. case 1:
  313. alert('魂淡,都说了是' + (noFail ? '60' : '40') + '到100之间的数字啊o( ̄ヘ ̄o#)');
  314. break;
  315. case 2:
  316. alert('魂淡,给我分清大小啊喂Σ(っ °Д °;)っ ');
  317. break;
  318. case 3:
  319. alert('魂淡,又要低分又不要差不管你了啦ヽ(*。>Д<)o゜');
  320. break;
  321. case 4:
  322. alert('魂淡,给我把范围扩大啊打不了分啦( ̄△ ̄;) ');
  323. break;
  324. }
  325. break;
  326. case 2:
  327. switch(id){
  328. case 1:
  329. alert('要填在' + (noFail ? '60' : '40') + '到100之间的数字哦(●ܫ●)');
  330. break;
  331. case 2:
  332. alert('大小什么的搞错了哦(* ̄︿ ̄)');
  333. break;
  334. case 3:
  335. $('noF').checked = false;
  336. alert('偷偷摸摸把勾去掉 啊被发现了ε=ε=┏( >_<)┛ ');
  337. break;
  338. case 4:
  339. alert('啊咧这个范围里面不能打分诶 把范围扩大试试╮( ̄▽ ̄")╭ ');
  340. break;
  341. }
  342. break;
  343. }
  344. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址