海大一键评教

广东海洋大学一键评教

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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();
})();