// ==UserScript==
// @name 多分相关页面优化
// @namespace http://tampermonkey.net/
// @version 3.49
// @description 多分相关页面优化改进
// @author ds
// @match www.moofen.net/*
// @match http://47.92.71.131/*
// @match http://140.210.192.246/*
// @match www.1010jiajiao.com/*
// @downloadURL https://update.greasyfork.icu/scripts/429360/%E5%A4%9A%E5%88%86%E7%9B%B8%E5%85%B3%E9%A1%B5%E9%9D%A2%E4%BC%98%E5%8C%96.user.js
// @updateURL https://update.greasyfork.icu/scripts/429360/%E5%A4%9A%E5%88%86%E7%9B%B8%E5%85%B3%E9%A1%B5%E9%9D%A2%E4%BC%98%E5%8C%96.meta.js
// ==/UserScript==
//将同类别功能的代码进行了分类
var url = document.location.toString();
var m = null;
var temp = null;
var img = null;
var i;
//---------类别零:多分相关页面优化---------
//⭐多分新题库后台,选题组卷搜索页面,施工中
//2023-07-04_155327
//http://www.moofen.net/tkn/pages/paper/paper.html
if ((m = url.match(/^(https?:\/\/(47\.92\.71\.131|140\.210\.192\.246|www\.moofen\.net)\/)(tkn\/pages\/paper\/paper\.html)(.*)$/i))) {
var paper_list, paper_list_length, sjbh_css, sjbh
paper_list = document.querySelectorAll('div#paperList')[0];
paper_list_length = paper_list.childElementCount;
for (i = 0; i < paper_list_length; i++) {
//🧩处理筛选后的列表
sjbh_css = document.querySelectorAll('.text-muted')[2 * i];
sjbh = sjbh_css.innerText;
sjmc = document.querySelectorAll('h5')[2 * 1 + 1].innerText.replace(/(.+) +试题.+/g, '$1');
alert(1);
console.log(sjmc);
(function () {
sjbh_css.forEach(element => {
console.log(element);
let btn = document.createElement('button');
btn.innerText = '复制';
element.before(btn);
element.addEventListener('click', (e) => {
e.preventDefault()
console.log('点击了', element.innerText);
GM_setClipboard(element.innerText);
})
});
})();
}
}
//⭐多分新题库后台,试题录题结构管理
//http://47.92.71.131/tkn/pages/question/paper_item.html
else if ((m = url.match(/^(https?:\/\/(47\.92\.71\.131|140\.210\.192\.246|www\.moofen\.net)\/)(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;
}
}
}, 1000);
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;
break;
default:
nj = ""
}
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('beforeBegin', '');
//17,关联17-1,17-2……,17-19,关联17-1,17-2,18,19
//console.log(glth);
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;
}
*/
document.querySelectorAll('#auto_link_content')[0].value = "";
}
}
}
//⭐多分新题库后台,试题编辑界面
//http://47.92.71.131/tkn/pages/question/question_content.html?errorCorrectionId=19005361
//http://140.210.192.246/tkn/pages/question/question_content.html?ver=1692076287885
//http://www.moofen.net/tkn/pages/question/question_content.html?ver=1688714384318
else if ((m = url.match(/^(https?:\/\/(47\.92\.71\.131|140\.210\.192\.246|www\.moofen\.net)\/)(tkn\/pages\/question\/question_content\.html)(.*)$/i))) {
//window.onload = (event) => {
//ESC键关闭弹出的窗口
//document.querySelectorAll('span.dui-dialog-close')[0].click();
//修改页面背景
var img_url;
img_url = "https://c-ssl.duitang.com/uploads/blog/202105/11/20210511074902_5a821.thumb.1000_0.jpg"
img_url = "https://c-ssl.duitang.com/uploads/blog/202102/15/20210215131040_381d7.thumb.1000_0.jpg"
img_url = "https://images.669pic.com/element_pic/48/73/51/67/9739cd7057d9b2fa46c79756dfbfc1af.jpg_w700wb"
img_url = "https://hbimg.huabanimg.com/22816985639618e38bc8f3bb1810737b682e7dca44f0-QgCCPL_fw658/format/webp"
img_url = "http://thepatternlibrary.com/img/aq.jpg"
img_url = "http://bg-patterns.com/p/new0353/m_new03530.jpg"
img_url = "https://c-ssl.duitang.com/uploads/blog/202104/21/20210421111142_e2667.thumb.1000_0.jpg"
//document.querySelectorAll('div.widget')[0].style.backgroundImage = "url('" + img_url + "')";
setTimeout(function () {
/*
//添加取消关联试卷的按钮
document.querySelectorAll('button#saveQuestion')[0].insertAdjacentHTML('beforeBegin', ' ');
document.querySelectorAll('#unlink_paper')[0].onclick = unlink_paper;
//自动点击取消关联试卷的按钮与弹窗确认
function unlink_paper() {
document.querySelectorAll('span.ml-auto.close')[0].onclick();
setTimeout(function () {
document.querySelectorAll('a.alert_ok')[0].onclick(); //确认的按钮无法关闭
//确定
//报错,document.querySelectorAll(...)[0].onclick is not a function
}, 100);
}
//添加关联试卷的按钮
document.querySelectorAll('button#unlink_paper')[0].insertAdjacentHTML('beforeBegin', ' ');
document.querySelectorAll('#link_paper')[0].onclick = link_paper;
document.querySelectorAll('button#link_paper')[0].insertAdjacentHTML('beforeBegin', '');
//将试卷编号作为卷面题号
var jmth = document.location.toString().match(/^(.*errorCorrectionId=)(.*)$/i)[2];
document.querySelectorAll('input#link_paper_number')[0].value = jmth;
//自动点击关联试卷的按钮并在弹窗输入试卷编号与题号保存
function link_paper() {
//nbth=parseInt(document.querySelectorAll('input#link_paper_number')[0].value);
document.querySelectorAll('button.btn.btn-primary.btn-sm.mb-2')[0].onclick();
setTimeout(function () {
//输入试卷编号
document.querySelectorAll('input.form-control.form-control-sm')[3].value = "2111001040480000";
document.querySelectorAll('input.form-control.form-control-sm')[5].value = jmth;
//document.querySelectorAll('input.form-control.form-control-sm')[6].value=nbth; //内部题号用此方法关联不上
document.querySelectorAll('div.dui-dialog-footer')[0].firstChild.onclick(); //保存按钮
}, 500);
}
*/
var stlb, xk, jmtx, div_edit, tgnr, nd, zsd;
//试题类别、学科、卷面题型、可编辑框、题干内容、难度、知识点
stlb = document.querySelectorAll('a.nav-link.active')[1].getAttribute("data-type");
xk = document.querySelectorAll('select#subject')[0].value;
jmtx = document.querySelectorAll('select#category')[0].value;
//难度、知识点有时候在页面修改不了,被禁用了
//nd = document.querySelectorAll('select#difficulty')[0].value;
//zsd = document.querySelectorAll('textarea#knowledgePoint')[0].value;
//alert(xk)
//根据学科与试题类别调整卷面题型
//语文
if (xk == 1) {
if (stlb == "C" && jmtx == "") {
//选择题先统一设置成基础知识
document.querySelectorAll('select#category')[0].value = 101;
} else if (stlb == "W" && jmtx == "") {
//写作题-作文
document.querySelectorAll('select#category')[0].value = 108;
} else {
//其他题型先统一设成现代文阅读,问答题
document.querySelectorAll('select#category')[0].value = 105;
if (stlb !== "S" && jmtx == "") {
//不为综合题的情况才改试题类别
document.querySelectorAll('a#Q-tab.nav-link')[0].setAttribute("aria-selected", "true")
document.querySelectorAll('a#Q-tab.nav-link')[0].setAttribute("class", "nav-link active")
document.querySelectorAll('a#F-tab.nav-link')[0].setAttribute("aria-selected", "false")
document.querySelectorAll('a#F-tab.nav-link')[0].setAttribute("class", "nav-link")
} else {
//子题的题型难度知识点为空的话,设成与综合题的题型难度知识点一样,
//一步到位的方法,未完善,子题后添加单个按钮,保存子题后原有的脚本子题添加按钮会消失
document.querySelectorAll('ul#typeTab')[0].children[5].insertAdjacentHTML('afterEnd', '');
document.querySelectorAll('#complete_subtitle')[0].onclick = complete_subtitle;
function complete_subtitle() {
for (i = 0; i < document.querySelectorAll('button.btn.btn-danger.btn-xs.pl-3.pr-3').length; i++) {
document.querySelectorAll('button.btn.btn-danger.btn-xs.pl-3.pr-3')[i].insertAdjacentHTML('afterEnd', '');
document.querySelectorAll('button.btn.btn-success.btn-xs.pl-3.pr-3')[parseInt(i)].onclick = complete_subtitle0;
}
//子题背景变透明
var zt = document.querySelectorAll('div.card.card-extend');
for (i = 0; i < zt.length; i++) {
zt[i].style.backgroundColor = "rgb(0,0,0,0)";
}
}
function complete_subtitle0() {
jmtx = document.querySelectorAll('select#category')[0].value;
i = event.currentTarget.id.slice(-1);
console.log(event.currentTarget.id);
document.querySelectorAll('button.btn.btn-primary.btn-xs.pl-3.pr-3')[i].onclick();
setTimeout(function () {
document.querySelectorAll('select#subCategory')[0].value = jmtx;
document.querySelectorAll('select#subDifficulty')[0].value = nd;
document.querySelectorAll('textarea.form-control.form-control-sm')[2].value = zsd;
}, 500);
}
}
/*
*/
//一步到位的方法,未完善
/*
document.querySelectorAll('ul#typeTab')[0].children[5].insertAdjacentHTML('afterEnd', '');
document.querySelectorAll('#complete_subtitle')[0].onclick = complete_subtitle;
function complete_subtitle() {
jmtx=document.querySelectorAll('select#category')[0].value;
for (i=0; i试题难度合并 ');
document.querySelectorAll('#stndhb')[0].onclick = stndhb;
document.querySelectorAll('button#stndhb')[0].insertAdjacentHTML('beforeBegin', '');
function stndhb() {
var ndhb = ""; //难度合并
tmsl = document.querySelectorAll('div.card-footer.d-flex.justify-content-start').length; //题目数量
for (i = 0; i < tmsl; i++) {
var dfl = parseFloat(document.querySelectorAll('div.card-footer.d-flex.justify-content-start')[i].children[2].children[0].innerText); //得分率
var nd = dfl < 40 ? 5 : dfl < 80 ? 3 : 1;
ndhb = ndhb + " " + nd;
}
ndhb = ndhb.substring(1); //去掉开头多的一个空格
console.log(ndhb);
document.querySelectorAll('#ndhb_content')[0].value = ndhb;
}
}, 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', '