// ==UserScript==
// @name 多分相关页面优化
// @namespace http://tampermonkey.net/
// @version 1.1
// @description 多分相关页面优化改进
// @author ds
// @match www.moofen.net/*
// @match http://47.92.71.131/*
// @match www.1010jiajiao.com/*
// @downloadURL none
// ==/UserScript==
//将同类别功能的代码进行了分类
var url = document.location.toString();
var m = null;
var img = null;
var i;
//---------类别零:多分相关页面优化---------
//多分新题库后台,试题录题结构管理
//http://47.92.71.131/tkn/pages/question/paper_item.html
if ((m = url.match(/^(https?:\/\/47\.92\.71\.131\/)(tkn\/pages\/question\/paper_item\.html)(.*)$/i))) {
if (document.querySelectorAll('a.btn.btn-primary.pl-4.pr-4')[0].innerText = "录题结构管理") {
//加载页面后自动增大CheckBox按钮尺寸,需要加上延迟才能生效
setTimeout(function () {
for (i = 0; i < document.querySelectorAll('input').length; i++) {
if (document.querySelectorAll('input')[i].type == "checkbox") {
document.querySelectorAll('input')[i].style.zoom = 2;
}
}
}, 500);
//原先单独做了一个按钮增大
/*
document.querySelectorAll('button.btn.btn-outline-danger.btn-sm.ml-2')[0].insertAdjacentHTML('afterEnd', '');
document.querySelectorAll('#zoom_all_btn')[0].onclick = CheckBox_Zoom;
function CheckBox_Zoom() {
//页面有很多input的type不是checkBox,而是hidden隐藏的
for (i = 0; i < document.querySelectorAll('input').length; i++) {
if (document.querySelectorAll('input')[i].type == "checkbox") {
document.querySelectorAll('input')[i].style.zoom = 2;
}
}
}
*/
var sjmc, km, nj, glth, glth_start, glth_end, tmsl, nbth, nbth_start, nbth_end;
//试卷名称,科目,年级,关联题号,关联题号起始,关联题号结束,题目数量,内部题号,内部题号起始,内部题号结束
sjmc = document.querySelectorAll('h1#paperTitle.mb-4.text-center')[0].innerText;
nj = sjmc.substr(sjmc.indexOf("年级") - 1, 1);
switch (nj) {
case "七":
nj = 7;
break;
case "八":
nj = 8;
break;
case "九":
nj = 9;
}
km = sjmc.slice(-2);
console.log(nj + km);
document.querySelectorAll('button.btn.btn-outline-danger.btn-sm.ml-2')[0].insertAdjacentHTML('afterEnd', '');
document.querySelectorAll('#auto_link')[0].onclick = auto_link;
document.querySelectorAll('#auto_link')[0].insertAdjacentHTML('afterEnd', '');
if (km == "英语" && nj == "8") {
document.querySelectorAll('#auto_link_content')[0].value = "79-83";
}
//17,关联17-1,17-2……,17-19,关联17-1,17-2,18,19
//console.log(glth);
document.querySelectorAll('#auto_link_content')[0].value = "8-12";
function auto_link() {
tmsl = document.querySelectorAll('tbody')[0].children.length;
glth = document.querySelectorAll('#auto_link_content')[0].value;
if (glth != "") {
if (glth.indexOf("-") != -1) {
glth_start = parseInt(glth.slice(0, glth.indexOf("-")));
glth_end = parseInt(glth.slice(glth.indexOf("-") + 1));
for (i = 0; i < tmsl; i++) {
nbth = document.querySelectorAll('tbody')[0].children[i].children[1].innerText;
if (nbth.indexOf("-") != -1) {
nbth_start = parseInt(nbth.slice(0, nbth.indexOf("-")));
nbth_end = parseInt(nbth.slice(nbth.indexOf("-") + 1));
nbth = nbth_start;
}
if (nbth <= glth_end && nbth >= glth_start) {
document.querySelectorAll('tbody')[0].children[i].children[0].children[0].checked = true;
}
}
} else {
for (i = 0; i < tmsl; i++) {
nbth = document.querySelectorAll('tbody')[0].children[i].children[1].innerText;
if (nbth.indexOf("-") != -1) {
nbth_start = parseInt(nbth.slice(0, nbth.indexOf("-")));
nbth_end = parseInt(nbth.slice(nbth.indexOf("-") + 1));
if (nbth_start == glth) {
document.querySelectorAll('tbody')[0].children[i].children[0].children[0].checked = true;
}
}
}
}
}
//点击综合题关联按钮并输入关联题号
setTimeout(function () {
document.querySelectorAll('button.btn.btn-outline-primary.btn-sm.ml-5')[0].onclick();
}, 100);
setTimeout(function () {
document.querySelectorAll('input.form-control.form-control-sm')[1].value = glth;
}, 100);
setTimeout(function () {
document.querySelectorAll('div.dui-dialog-footer')[0].children[0].onclick();
}, 100);
/*
//综合题关联,input的第0个是隐藏的,第1个是全选,第2个是第一题的,第17个是第二题的,第2+15n是第n题的
for (i = 0; i < document.querySelectorAll('input').length; i++) {
nbth=document.querySelectorAll('input')[2 + 15 * i].value;
document.querySelectorAll('input')[2 + 15 * i].checked = true;
}
*/
}
}
}
//多分新题库后台,试题编辑界面
//http://47.92.71.131/tkn/pages/question/question_content.html?errorCorrectionId=19005361
else if ((m = url.match(/^(https?:\/\/47\.92\.71\.131\/)(tkn\/pages\/question\/question_content\.html)(.*)$/i))) {
setTimeout(function () {
var stlb, xk, jmtx;
//试题类别、学科、卷面题型
stlb=document.querySelectorAll('a.nav-link.active')[1].id;
stlb=stlb.slice(0, stlb.indexOf("-"));
xk=document.querySelectorAll('select#subject')[0].value;
jmtx=document.querySelectorAll('select#category')[0].value;
if (xk==2 && stlb=="Q" && jmtx==""){document.querySelectorAll('select#category')[0].value=204;}
if (xk==2 && stlb=="C"){document.querySelectorAll('select#category')[0].value=201;}
//document.querySelectorAll('select#category')[0].children[4].selected=true;
}, 500);
}
//多分题库后台,试题录题结构管理
//http://www.moofen.net/tk/pages/paper/paperItem_search.html?paperCode=
else if ((m = url.match(/^(https?:\/\/www\.moofen\.net\/)(tk\/pages\/paper\/paperItem_search\.html)(.*)$/i))) {
//添加让左侧的选择框按钮变大的按钮
document.querySelectorAll('button.btn.btn-danger.btn-sm')[0].insertAdjacentHTML('afterEnd', '');
function CheckBox_Zoom() {
//页面前有2个input不是CheckBox的type
for (i = 2; i < document.querySelectorAll('input').length; i++) {
document.querySelectorAll('input')[i].style.zoom = 2;
}
//点击卷面题号的单元格,勾选左侧对应的选择框按钮,未完成
for (i = 0; i < document.querySelectorAll('td').length / 6; i++) {
document.querySelectorAll('td')[i * 6 + 3].insertAdjacentHTML('afterEnd', '')
}
}
document.querySelectorAll('button#zoom_all_btn.btn.btn-success.btn-sm')[0].onclick = CheckBox_Zoom;
}
//新版教师端学情分析系统
//http://www.moofen.net/school/web/pages/index.html
else if ((m = url.match(/^(https?:\/\/www\.moofen\.net\/)(school\/web\/pages\/index\.html)$/i))) {
//教研组长试卷分析界面,下载试卷难度区分度分布表,未完成
//获取考试与科目
var ksmc, jsmc;
document.querySelectorAll('i.iconfont.icon-home')[0].insertAdjacentHTML('beforeBegin', '');
document.querySelectorAll('button#ksxm')[0].onclick = ksxm_show;
function ksxm_show() {
ksmc = document.querySelectorAll('select#questExam.form-control.form-control-sm')[0].innerText;
jsmc = document.querySelectorAll('span#currRoleName.curr-role')[0].innerText;
document.querySelectorAll('span#ksmc')[0].innerText = ksmc + "_" + jsmc;
}
}
//试卷预览界面,点击刷新按钮,自动勾选显示所有信息,未完成
//http://www.moofen.net/tk/pages/paper/paper_preview.html
// @require http://www.moofen.net/tk/assets/js/paper/paper_preview_single.js
// @require http://cdn.staticfile.org/jquery/3.5.1/jquery.min.js
/* globals jQuery, $, waitForKeyElements */
else if ((m = url.match(/^(https?:\/\/www\.moofen\.net\/)(tk\/pages\/paper\/paper_preview\.html.*)$/i))) {
//位置调整,靠右以便于左右分屏对照
document.querySelectorAll('div.head-nav')[0].insertAdjacentHTML('afterEnd', '