QUST教务评测
// ==UserScript==
// @name QUST教务评测
// @namespace https://bbs.tampermonkey.net.cn/
// @version 0.2.0
// @description 青岛科技大学教务评测脚本,以信息学院测评为样本,默认全好评,别的定制请联系kulujun@gmail.com
// @author kitUIN
// @match https://*.qust.edu.cn/jwglxt/xspjgl/xspj_cxXspjIndex.html?*
// ==/UserScript==
(function() {
'use strict';
async function waitForSelector(selector) {
for (let index = 0; index < 20; index++) {
await new Promise((resolve,reject)=>{
setTimeout(resolve,500)
});
// console.log(index)
var r = document.querySelector(selector);
if (r!==null) {
return r;
}
}
return null;
}
function setOne(){
return waitForSelector(".radio-pjf").then(
async (ele) =>{
if(ele!=null){
ele.click();
document.getElementsByClassName("form-control")[0].value = "无";
document.getElementsByClassName("form-control")[1].value = "好好好";
const btn = document.getElementById("btn_xspj_bc");
$("#btn_xspj_bc").data("enter","1");
btn.click();
await waitForSelector("#btn_ok").then(ele =>{ // 跳过成功对话框
if(ele!=null){
ele.click();
}
})
}
}
);
}
function isLast(){
const no = document.getElementsByClassName("ui-pg-input")[0].value;
const total = document.getElementById("sp_1_pager").innerHTML;
return no >= total;
}
async function setAll(submit){
var rows = document.getElementById("tempGrid").rows;
for (var i = 1; i < rows.length; i++) {
var cells = rows[i].cells;
console.log(cells[10].innerHTML + "(" +cells[11].innerHTML+"):"+ cells[7].innerHTML);
if(cells[7].innerHTML === "提交"){
$.alert("全部提交了你按啥😡");
return;
}
if(cells[7].innerHTML === "已评完"){
continue;
}
if(rows[i].getAttribute("aria-selected") != "true"){ // 当前没被选中
rows[i].click();
}
await setOne(); // 评价
}
if(!isLast()){ // 需要翻页
document.getElementById("next_pager").click();
setTimeout(()=>setAll(submit), 1000);
}else{
if(submit){
const btn = document.getElementById("btn_xspj_tj");
if(btn!=null){
$("#btn_xspj_tj").data("enter","1");
btn.click();
}
}
}
}
function clickBotton(){
setAll(false);
}
function clickBotton2(){
setAll(true);
}
var button = document.createElement("button"); //创建一个按钮
button.textContent = "一键评教(仅保存)"; //按钮内容
button.style.width = "140px"; //按钮宽度
button.style.height = "28px"; //按钮高度
button.style.marginTop = "4px";
button.style.align = "center"; //文本居中
button.style.color = "white"; //按钮文字颜色
button.style.background = "#e33e33"; //按钮底色
button.style.border = "1px solid #e33e33"; //边框属性
button.style.borderRadius = "4px"; //按钮四个角弧度
button.addEventListener("click", clickBotton) //监听按钮点击事件
var button2 = document.createElement("button"); //创建一个按钮
button2.textContent = "一键评教"; //按钮内容
button2.style.width = "90px"; //按钮宽度
button2.style.height = "28px"; //按钮高度
button2.style.marginTop = "4px";
button2.style.marginLeft = "10px";
button2.style.align = "center"; //文本居中
button2.style.color = "white"; //按钮文字颜色
button2.style.background = "#e33e33"; //按钮底色
button2.style.border = "1px solid #e33e33"; //边框属性
button2.style.borderRadius = "4px"; //按钮四个角弧度
button2.addEventListener("click", clickBotton2) //监听按钮点击事件
var like_comment = document.getElementsByClassName('panel-heading')[0];
like_comment.appendChild(button); //把按钮加入到 x 的子节点中
like_comment.appendChild(button2); //把按钮加入到 x 的子节点中
})();