海大一键评教

广东海洋大学一键评教

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         海大一键评教
// @namespace    https://github.com/hgb0607
// @version      0.3 正式版
// @description  广东海洋大学一键评教
// @author       韩国彪
// @match        *://210.38.137.126:8016/*
// @match        *://210.38.137.125:8016/*
// @match        *://210.38.137.124:8016/*
// @match        *://210.38.137.79:8016/*
// @grant        none
// ==/UserScript==

//原作者信息
// @name         海大一键评教
// @namespace    https://github.com/A0150315
// @version      0.2
// @description  广东海洋大学一键评教
// @author       谭健青

//后期修改:韩国彪
//修改说明:
//修复无法评教教材的bug
//修复无法评教最后一项课程的bug
//目前发现的新bug:弹出两次评教成功
//目前发现的新bug:最后一科会卡顿一下,不过不影响评教,如果无法退出,请关闭脚本刷新页面

//如果无法退出,请关闭脚本刷新页面

(function() {
  'use strict';

  function autoComplete(select, ...args) {
    if (select.name.indexOf('DataGrid') > -1) {
      select.value = randomBetweenANB();
    }
    else if (select.name.indexOf('dgPjc') > -1) {
      select.value = randomBetweenANB();
    }
    return select;
  }


  function randomBetweenANB(...args) {
    return parseInt((Math.random() * 10)) % 2 === 0 ? 'A' : 'B';
  }
  function isLastItem(...args){
    let pjkc=document.querySelector('#pjkc');
    if(pjkc){
      const selectedIndex=document.querySelector('#pjkc').options.selectedIndex;
      const selectionLength=document.querySelector('#pjkc').options.length;
      if(selectedIndex===selectionLength-1){
        return true;
      }
      return false;
    }
  }
  function getAllSelectionNCompleteIt(...args) {
    let selects = document.getElementsByTagName('select');
    let pjxx = document.getElementById('pjxx');
    let Button1 = document.querySelector('#Button1');
    const Button2 = document.querySelector('#Button2');
    if (selects) {
      if(isLastItem()){
      [].forEach.call(selects, autoComplete);
      if (pjxx) {
        pjxx.value = '谢谢老师悉心指导!';
      }
      if (Button1 && Button2) {
        Button1.click();
      }
        if(Button2.value===' 提  交 '){
          Button2.click();
        }
        return true;
      }
     else{
      [].forEach.call(selects, autoComplete);
      if (pjxx) {
        pjxx.value = '谢谢老师悉心指导!';
      }
      if (Button1 && Button2) {
        Button1.click();
      }
     }
    }
    return true;
  }
  const TextBox2=document.querySelector("#TextBox2");
  if(TextBox2){
    TextBox2.style.display='block';
    return true;
  }
  getAllSelectionNCompleteIt();
})();