Greasy Fork

Greasy Fork is available in English.

多分相关页面优化

多分相关页面优化改进

当前为 2022-10-31 提交的版本,查看 最新版本

// ==UserScript==
// @name         多分相关页面优化
// @namespace    http://tampermonkey.net/
// @version      2.02
// @description  多分相关页面优化改进
// @author       ds
// @match      www.moofen.net/*
// @match      http://47.92.71.131/*
// @match      www.1010jiajiao.com/*
// ==/UserScript==
//将同类别功能的代码进行了分类
var url = document.location.toString();
var m = null;
var temp = 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|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;
                }
            }
        }, 500);
        //原先单独做了一个按钮增大
        /*
        document.querySelectorAll('button.btn.btn-outline-danger.btn-sm.ml-2')[0].insertAdjacentHTML('afterEnd', '<button type="button" class="btn btn-outline-primary btn-sm ml-5" id="zoom_all_btn">CheckBox_Zoom</button>');
        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;
	default:
                nj=""
        }
        km = sjmc.slice(-2);
        console.log(nj + km);
        document.querySelectorAll('button.btn.btn-outline-danger.btn-sm.ml-2')[0].insertAdjacentHTML('afterEnd', '<button type="button" class="btn btn-outline-danger btn-sm ml-2" id="auto_link">【' + nj + km + '】自动关联</button>');
        document.querySelectorAll('#auto_link')[0].onclick = auto_link;
        document.querySelectorAll('#auto_link')[0].insertAdjacentHTML('beforeBegin', '<input id="auto_link_content" type="text" class="form-control form-control-sm" placeholder="请输入综合题关联题号" required="">');
        //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
else if ((m = url.match(/^(https?:\/\/47\.92\.71\.131\/)(tkn\/pages\/question\/question_content\.html)(.*)$/i))) {
    //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', '<button type="button" class="btn btn-success pl-4 pr-4" id="unlink_paper">取消关联</button>    ');
        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(); //确认的按钮无法关闭
                //<a class="alert_ok" data-mark="87">确定</a>
                //报错,document.querySelectorAll(...)[0].onclick is not a function
            }, 100);
        }
        //添加关联试卷的按钮
        document.querySelectorAll('button#unlink_paper')[0].insertAdjacentHTML('beforeBegin', '<button type="button" class="btn btn-success pl-4 pr-4" id="link_paper">关联试卷</button>    ');
        document.querySelectorAll('#link_paper')[0].onclick = link_paper;
        document.querySelectorAll('button#link_paper')[0].insertAdjacentHTML('beforeBegin', '<input id="link_paper_number" tpye="text" class="form-control-sm" placeholder="内部题号">');
        //将试卷编号作为卷面题号
        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].id;
        stlb = stlb.slice(0, stlb.indexOf("-"));
        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;
        //根据学科与试题类别调整卷面题型
        //语文
        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', '<button type="button" class="btn btn-success pl-4 pr-4" id="complete_subtitle">完善子题</button>');
                    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', '<button type="button" class="btn btn-success btn-xs pl-3 pr-3" id="subtitle' + i + '">完善子题</button>');
                            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', '<button type="button" class="btn btn-success pl-4 pr-4" id="complete_subtitle">完善子题</button>');
                            document.querySelectorAll('#complete_subtitle')[0].onclick = complete_subtitle;
                            function complete_subtitle() {
                                jmtx=document.querySelectorAll('select#category')[0].value;
                                for (i=0; i<document.querySelectorAll('button.btn.btn-primary.btn-xs.pl-3.pr-3').length; i++){
                                    setTimeout(function () {
                                        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);
                                    },1500);
                                }
                            }
                        setTimeout(function () {
                        tgnr=document.querySelectorAll('body.cke_editable.cke_editable_themed.cke_contents_ltr.cke_show_borders')[0].innerText; //题干内容
                                    },500);
                        console.log(tgnr);
                        if (tgnr.indexOf("00字") !== -1){
                            document.querySelectorAll('select#category')[0].value=108;
                            document.querySelectorAll('a#W-tab.nav-link')[0].setAttribute("aria-selected","true");
                            document.querySelectorAll('a#W-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")
                            document.querySelectorAll('body.cke_editable.cke_editable_themed.cke_contents_ltr.cke_show_borders')[0].innerText="此题无标准答案";
                        }
                            */
            }
        }
        //数学
        if (xk == 2 && stlb == "C") {
            document.querySelectorAll('select#category')[0].value = 201;
        }
        if (xk == 2 && stlb == "F") {
            document.querySelectorAll('select#category')[0].value = 202;
        }
        if (xk == 2 && stlb == "Q" && jmtx == "") {
            document.querySelectorAll('select#category')[0].value = 204;
        }
        //物理
        if (xk == 4 && stlb == "C" && jmtx == "") {
            document.querySelectorAll('select#category')[0].value = 401;
        }
        if (xk == 4 && stlb == "F" && jmtx == "") {
            document.querySelectorAll('select#category')[0].value = 403;
        }
        if (xk == 4 && stlb == "Q" && jmtx == "") {
            document.querySelectorAll('select#category')[0].value = 406;
        }
        //化学
        if (xk == 5 && stlb == "C" && jmtx == "") {
            document.querySelectorAll('select#category')[0].value = 501;
        }
        if (xk == 5 && stlb == "F" && jmtx == "") {
            document.querySelectorAll('select#category')[0].value = 503;
        }
        if (xk == 5 && stlb == "Q" && jmtx == "") {
            document.querySelectorAll('select#category')[0].value = 504;
        }
        //document.querySelectorAll('select#category')[0].children[4].selected=true;
        //可编辑框高度调整
        document.querySelectorAll('div.cke_contents.cke_reset')[0].style.height = "500px";
        document.querySelectorAll('div.cke_contents.cke_reset')[1].style.height = "500px";
        document.querySelectorAll('div.cke_contents.cke_reset')[2].style.height = "500px";
        document.querySelectorAll('div.cke_contents.cke_reset')[3].style.height = "500px";
        document.querySelectorAll('div.cke_contents.cke_reset')[4].style.height = "300px";
        document.querySelectorAll('div.cke_contents.cke_reset')[5].style.height = "300px";
        div_edit = document.querySelectorAll('div.cke_contents.cke_reset');
        //alert(div_edit.length); //不知道为什么循环不成功,只有第一个生效
        for (i = 0; i < div_edit.length; i++) {
            div_edit[0].style.height = "500px";
        }
    }, 500);
}
//多分新题库后台,选题组卷-查看试卷界面
//http://47.92.71.131/tkn/pages/paper/paper_single.html?paperCode=1001598493637272
else if ((m = url.match(/^(https?:\/\/47\.92\.71\.131\/)(tkn\/pages\/paper\/paper_single\.html)(.*)$/i))) {
    setTimeout(function() {
        //添加难度合并的按钮
        document.querySelectorAll('button.btn.btn-outline-primary.btn-square.btn-sm')[0].insertAdjacentHTML('beforeBegin', '<button type="button" class="btn btn-outline-primary btn-square btn-sm " id="stndhb">试题难度合并</button>    ');
        document.querySelectorAll('#stndhb')[0].onclick = stndhb;
        document.querySelectorAll('button#stndhb')[0].insertAdjacentHTML('beforeBegin', '<input id="ndhb_content" tpye="text" class="form-control-sm" placeholder="小题难度">');

        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', '<button type="button" class="btn btn-success btn-sm" id="zoom_all_btn">CheckBox_Zoom</button>');

    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', '<button id="ksxm">考试名称:</button><span id="ksmc"></span>');
    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', '                         <button id="pos_adj" class="btn btn-success btn-sm">位置调整</a>');
    document.querySelectorAll('#pos_adj')[0].onclick = pos_adj;

    function pos_adj() {
        //点击刷新按钮
        document.querySelectorAll('button#reloadPaper')[0].click();
        setTimeout(function() {
            var sjbh = document.querySelectorAll('div.card.mb-3')[0].id
            var sjmc = document.querySelectorAll('div.card-body')[0].innerText
            //标题添加新题库链接,配合后续代码方便获取难度
            document.querySelectorAll('div#paperContent.question-check')[0].children[0].remove()
            document.querySelectorAll('div#paperContent.question-check')[0].children[0].insertAdjacentHTML('beforeBegin', '<h3 class="title"><a href=\"http://47.92.71.131/tkn/pages/paper/paper_single.html?paperCode=' + sjbh + '\" target=\"_blank\">' + sjmc + '</a></h3>');
            //document.querySelectorAll('input#paper_check_01')[0].Checked=1
            //document.querySelectorAll('div.height-auto.col-xl-10.col-md-8.col-sm-8')[0].class="height-auto.col-xl-6.col-md-8.col-sm-8"
            //document.querySelectorAll('div#paperContent.question-check')[0].style.right="0px"
            document.querySelectorAll('div#paperSingle.content')[0].style.position = "relative";
            document.querySelectorAll('div#paperSingle.content')[0].style.left = "623px";
            document.querySelectorAll('div#paperSingle.content')[0].style.width = "920px";
            document.querySelectorAll('#pos_adj')[0].style.left = "623px";
            //显示所有基础信息 显示所有分析 显示所有答案 显示所有点评
            for (i = 0; i < document.querySelectorAll('div.show-key').length; i = i + 2) {
                document.querySelectorAll('div.show-key')[i].style.display = "block";
            }
        }, 1000);
    }
}
//编辑试题界面
//http://www.moofen.net/tk/pages/qb/question_edit.html?questionId=1615948988451
else if ((m = url.match(/^(https?:\/\/www\.moofen\.net\/)(tk\/pages\/qb\/question_edit\.html.*)$/i))) {
    //位置调整,靠右以便于左右分屏对照
    document.querySelectorAll('#typeTab')[0].lastElementChild.insertAdjacentHTML('afterEnd', '<li class="nav-item"><a class="nav-link" id="pos_adj">位置调整</a></li>');
    //document.querySelectorAll('#pos_adj')[0].onclick = pos_adj;
    //function pos_adj() {
    document.querySelectorAll('section')[0].style.position = "relative";
    document.querySelectorAll('section')[0].style.left = "500px";
    document.querySelectorAll('section')[0].style.width = "920px";
    document.querySelectorAll('#question')[0].style.width = "900px";
    document.querySelectorAll('#tabContent')[0].style.width = "900px";
    //}
}
//同步试卷界面,点击复制试卷编号,未完成
//http://www.moofen.net/tk/pages/sync/paper_sync.html
else if ((m = url.match(/^(https?:\/\/www\.moofen\.net\/)(tk\/pages\/sync\/paper_sync\.html.*)$/i))) {
    document.querySelectorAll('input#oldPaperId.form-control')[0].insertAdjacentHTML('beforeBegin', '<div  id="btn1" class="btn btn-success">EhanceCOPY</div>');
    var btn1 = document.getElementById('btn1');

    function EhanceCOPY() {
        var matchs = document.getElementsByClassName('table-item');
        var clipBoardContent = "";
        for (var j = 0; j < matchs.length; j++) {
            var content_before = matchs[j].children[2].innerHTML
            var content = content_before.match(/^(<i.+\/i>)(.+)$/i);
            //var content_after = '<input type="button"> value="' + content_before + '" index="' + j + '" onclick="javascript:(function copyToClipBoard(){var clipBoardContent="";clipBoardContent+=' + content_before + ';window.clipboardData.setData("Text",clipBoardContent);})"';
            var content_after = '<button onclick="javascript:(function (){window.clipboardData.setData("Text",' + content_before + ');})">' + content_before + ' </button>';
            matchs[j].children[2].innerHTML = content_after;
        }
    }
    btn1.onclick = EhanceCOPY;
}
//多分cube页面,因Ajax技术,所有功能都是这个网址
//http://www.moofen.net/cube/pages/cube.html
else if ((m = url.match(/^(https?:\/\/www\.moofen\.net\/)(cube\/pages\/cube\.html)$/i))) {
    /*
    (function() {
        'use strict';
        //alert("插件正在加载,请耐心等待5秒");
        setTimeout(function() {
            $("body").append(" <div style='left: 10px;bottom: 10px;background: #1a59b7;color:#ffffff;overflow: hidden;z-index: 9999;position: fixed;padding:5px;text-align:center;width: 175px;height: 22px;border-bottom-left-radius: 4px;border-bottom-right-radius: 4px;border-top-left-radius: 4px;border-top-right-radius: 4px;'>hhhh</div>");
        }, 4000);

    })();
    */
    //悬浮框添加,放置新增功能按钮
    $("body").append('<div id="cube_enhance_by_ds"  class="default_btn_small white_btn" style="left: 30px;bottom: 30px;overflow: hidden;z-index: 999999;position: fixed;"><button id="structure_enhance" class="default_btn_small yellow_btn">分析结构处理</button></div>')
    var cube_enhance, cube_enhance_count;
    cube_enhance = document.querySelectorAll("#cube_enhance_by_ds")[0];
    cube_enhance_count = cube_enhance.childElementCount;
    cube_enhance.lastChild.insertAdjacentHTML('afterEnd', '</br><button id="img_sort" class="default_btn_small green_btn" onclick="img_sort()">切图重排</button>');
    cube_enhance.lastChild.insertAdjacentHTML('afterEnd', '</br><button id="img_download" class="default_btn_small green_btn" onclick="img_download()">切图下载</button>');
    cube_enhance.lastChild.insertAdjacentHTML('afterEnd', '</br><button id="multi_funcion_switch" class="default_btn_small purple_btn" onclick="multi_funcion_switch()">多功能切换</button>');
    cube_enhance.lastChild.insertAdjacentHTML('afterEnd', '</br><button id="multi_funcion_call" class="default_btn_small blue_btn">多功能调用</button>');
    document.querySelectorAll('#structure_enhance')[0].onclick = structure_enhance;
    document.querySelectorAll('#img_sort')[0].onclick = img_sort;
    document.querySelectorAll('#img_download')[0].onclick = img_download;
    document.querySelectorAll('#multi_funcion_switch')[0].onclick = multi_funcion_switch;



    //分析结构处理
    function structure_enhance() {
        var nj, xd, subCode, xtsl, nbth, jmth, stlb, jmtx, fj, xztxx;
        //年级,学段,学科代码,小题数量,内部题号,卷面题号,试题类别,卷面题型,分卷,选择题选项
        nj = document.querySelectorAll("span.wid_span12")[2].innerText.replace(/年级/g,"");
        //1语文,2数学,3英语,4物理,5化学,6历史,7地理,8政治,9生物
        subCode = parseInt(document.querySelectorAll("input#currentsubCode")[0].value);
        xtsl = document.querySelectorAll("select.default_select.category").length;
        nbth = document.querySelectorAll("input.questionNo.form-control.form-control-sm.filter_region");
        jmth = document.querySelectorAll("input.scoreNo.form-control.form-control-sm.filter_region");
        stlb = document.querySelectorAll("select.default_select.type");
        jmtx = document.querySelectorAll("select.default_select.category");
        fj = document.querySelectorAll("select.default_select.section");
        xztxx = document.querySelectorAll("input.choice.form-control.form-control-sm.filter_region");
        if(nj=="七"){nj=7};
        if(nj=="八"){nj=8};
        if(nj=="九"){nj=9};
        if(nj=="高一" || nj=="十"){nj=10};
        if(nj=="高二" || nj=="十一"){nj=11};
        if(nj=="高三" || nj=="十二"){nj=12};
        nj=parseInt(nj);
        if(!isNaN(nj)){
            if(nj>6 & nj <10){xd="junior";}
            if(nj>9 & nj <13){xd="senior";}
        }
        var nbth_empty = 0,
            jmtx_empty = 0;
        for (i = 0; i < xtsl; i++) {
            if (nbth[i].value == "-" || nbth[i].value == "") {
                nbth_empty++;
            }
            if (jmtx[i].value == "") {
                jmtx_empty++;
            }
        }
        //内部题号有空的,先进行预设
        if (nbth_empty > 0) {
            //卷面题号区分了B卷以及带了“-”的,内部题号通用判断方式
            var jmth_current="", jmth_B_exist = 0, jmth_B_num=0, nbth_value="", nbth_start=0, nbth_end;
            for (i = 0; i < xtsl; i++) {
                jmth_current = jmth[i].value.replace(/[AB]/g, "");
                if (jmth[i].value.slice(0, 1) == "B") {
                    jmth_B_exist = 1;
                }
                if (i>0 && jmth[i].value.slice(0, 1) == "B" && jmth[i - 1].value.slice(0, 1) != "B") {
                    jmth_B_num = i;
                }
                if (jmth_current.indexOf("-") != -1 && !isNaN(parseInt(jmth_current))) {
                    nbth_start = parseInt(jmth_current.slice(0, jmth_current.indexOf("-")));
                    nbth_end = parseInt(jmth_current.slice(jmth_current.indexOf("-") + 1));
                    if (nbth_start < nbth_end ) {
                        nbth_value = nbth_start + (jmth_B_num-1) * jmth_B_exist;
                    }
                    if (nbth_start >= nbth_end) {
                        nbth_value = (jmth_B_num-1) * jmth_B_exist + nbth_start + "-" + nbth_end;
                    }
                } else {
                    if(isNaN(parseInt(jmth_current))){
                        //如果卷面题号为中文的话,内部题号的值就为上一项+1;
                        nbth_value=nbth_value+1;
                    } else {
                        nbth_value = parseInt(jmth_current) + (jmth_B_num-1) * jmth_B_exist;
                    }
                }
                nbth[i].value = nbth_value;
                if(jmth_B_num>0){
                    fj[1 - 1].value = "A";
                    fj[jmth_B_num].value = "B";
                }
            }
            if (xd="junior" && subCode == 3 && nbth_empty >= 4) {
                if (jmth[76].value == "B1") {
                    nbth[76].value = "76";
                }
                if (jmth[77].value == "B2") {
                    nbth[77].value = "77";
                }
                if (jmth[78].value == "B3") {
                    nbth[78].value = "78";
                }
                if (jmth[79].value == "B4B") {
                    nbth[79].value = "84";
                }
                if (jmth[80].value == "B5" && nbth_empty == 5) {
                    nbth[80].value = "85";
                }
            }
        } else {
            //卷面题型有空的才进行预设与填充
            if (jmtx_empty > 0) {
                //固定格式的单独修改,初中英语+数学+语文等
                if(xd="junior"){
                    switch (subCode) {
                        case 3:
                            if (xtsl >= 75) {
                                var nbth_26_30, nbth_76_78, nbth84_85;
                                if (xtsl == 75) {
                                    nbth_26_30 = 5;
                                    nbth_76_78 = 3;
                                }
                                if (xtsl >= 80) {
                                    nbth_26_30 = 5 - 1;
                                    nbth_76_78 = 3 - 3;
                                    stlb[25].value = "Q";
                                    nbth[25].value = "26";
                                    stlb[71].value = "Q";
                                    stlb[79].value = "Q";
                                    jmtx[25].value = "301";
                                    jmtx[71].value = "305";
                                    jmtx[72].value = "306";
                                    jmtx[73].value = "308";
                                }
                                if (xtsl == 81) {
                                    stlb[80].value = "W";
                                    jmtx[80].value = "311";
                                }
                                stlb[1 - 1].value = "C";
                                jmtx[1 - 1].value = "301";
                                jmtx[31 - 1 - nbth_26_30].value = "302";
                                jmtx[41 - 1 - nbth_26_30].value = "306";
                                jmtx[46 - 1 - nbth_26_30].value = "303";
                                jmtx[61 - 1 - nbth_26_30].value = "304";
                                jmtx[79 - 1 - nbth_26_30 - nbth_76_78].value = "309";
                                jmtx[1 - 1].value = "301";
                                fj[1 - 1].value = "A";
                                fj[76 - 1 - nbth_26_30 - nbth_76_78].value = "B";
                                xztxx[1 - 1].value = "ABC";
                                xztxx[6 - 1].value = "ABCDE";
                                xztxx[11 - 1].value = "ABC";
                                xztxx[31 - 1 - nbth_26_30].value = "ABC";
                                xztxx[41 - 1 - nbth_26_30].value = "ABCDE";
                                xztxx[46 - 1 - nbth_26_30].value = "ABC";
                                xztxx[61 - 1 - nbth_26_30].value = "AB";
                                xztxx[66 - 1 - nbth_26_30].value = "ABC";
                                xztxx[79 - 1 - nbth_26_30 - nbth_76_78].value = "ABCDEF";
                            }
                            for (i = 1; i <= 5; i++) {
                                jmth[i - 1 + 79 - 1 - nbth_26_30 - nbth_76_78].value = "B4A-" + i;
                            }
                            break;
                        case 2:
                            if (xtsl == 21 || xtsl == 28) {
                                var nbth_11_14, nbth_21_25;
                                if (xtsl == 21) {
                                    nbth_11_14 = 4 - 1;
                                    nbth_21_25 = 5 - 1;
                                    nbth[11 - 1].value = "11";
                                    nbth[21 - 1 - 3].value = "21";
                                }
                                if (xtsl == 28) {
                                    nbth_11_14 = 4 - 4;
                                    nbth_21_25 = 5 - 5;
                                }
                                stlb[1 - 1].value = "C";
                                stlb[11 - 1].value = "F";
                                stlb[15 - 1 - nbth_11_14].value = "Q";
                                stlb[21 - 1 - nbth_11_14].value = "F";
                                stlb[26 - 1 - nbth_11_14 - nbth_21_25].value = "Q";
                                jmtx[1 - 1].value = "201";
                                jmtx[11 - 1].value = "202";
                                jmtx[15 - 1 - nbth_11_14].value = "204";
                                jmtx[21 - 1 - nbth_11_14].value = "204";
                                jmtx[26 - 1 - nbth_11_14 - nbth_21_25].value = "204";
                                fj[1 - 1].value = "A";
                                fj[21 - 1 - nbth_11_14].value = "B";
                            }
                            //中考新题型
                            if (xtsl == 18 || xtsl == 26) {
                                var nbth_9_13, nbth_19_23;
                                if (xtsl == 18) {
                                    nbth_9_13 = 5 - 1;
                                    nbth_19_23 = 5 - 1;
                                    nbth[9 - 1].value = "9";
                                    nbth[19 - 1 - 4].value = "19";
                                }
                                if (xtsl == 26) {
                                    nbth_9_13 = 5 - 5;
                                    nbth_19_23 = 5 - 5;
                                }
                                stlb[1 - 1].value = "C";
                                stlb[9 - 1].value = "F";
                                stlb[14 - 1 - nbth_9_13].value = "Q";
                                stlb[19 - 1 - nbth_9_13].value = "F";
                                stlb[24 - 1 - nbth_9_13 - nbth_19_23].value = "Q";
                                jmtx[1 - 1].value = "201";
                                jmtx[9 - 1].value = "202";
                                jmtx[14 - 1 - nbth_9_13].value = "204";
                                jmtx[19 - 1 - nbth_9_13].value = "202";
                                jmtx[24 - 1 - nbth_9_13 - nbth_19_23].value = "204";
                                fj[1 - 1].value = "A";
                                fj[19 - 1 - nbth_9_13].value = "B";
                            }
                            break;
                        case 1:
                            if(xtsl==28 || xtsl==29){
                                var nbth_9_1_2 = 0;
                                var nbth_17_1_2 = 1;
                                if (xtsl == 29 && nbth[8].value.indexOf("-") != -1) {
                                    nbth_9_1_2 = 1;
                                }
                                stlb[1 - 1].value = "C";
                                stlb[9 - 1].value = "F";
                                stlb[9 - 1 + nbth_9_1_2].value = "Q";
                                stlb[10 - 1 + nbth_9_1_2].value = "Q";
                                stlb[13 - 1 + nbth_9_1_2].value = "W";
                                stlb[14 - 1 + nbth_9_1_2].value = "Q";
                                jmtx[1 - 1].value = "101";
                                jmtx[5 - 1].value = "102";
                                jmtx[9 - 1].value = "104";
                                jmtx[10 - 1 + nbth_9_1_2].value = "105";
                                jmtx[13 - 1 + nbth_9_1_2].value = "108";
                                jmtx[14 - 1 + nbth_9_1_2].value = "103";
                                jmtx[16 - 1 + nbth_9_1_2].value = "102";
                                jmtx[17 - 1 + nbth_9_1_2].value = "111";
                                jmtx[18 - 1 + nbth_9_1_2 + nbth_17_1_2].value = "102";
                                jmtx[19 - 1 + nbth_9_1_2 + nbth_17_1_2].value = "106";
                                jmtx[21 - 1 + nbth_9_1_2 + nbth_17_1_2].value = "105";
                                jmtx[25 - 1 + nbth_9_1_2 + nbth_17_1_2].value = "107";
                                fj[1 - 1].value = "A";
                                fj[14 - 1 + nbth_9_1_2].value = "B";
                            }
                            break;
                        default:
                            console.log(subCode);
                    }
                }
            }
                //分析结构的卷面题型、分卷、选择题选项依次填充
                for (i = 1; i < xtsl; i++) {
                    if (jmtx[i].value == "") {
                        jmtx[i].value = jmtx[i - 1].value;
                    }
                    if (fj[i].value == "") {
                        fj[i].value = fj[i - 1].value;
                    }
                    if (subCode == 3 && xztxx[i].value == "ABCD") {
                        xztxx[i].value = xztxx[i - 1].value;
                    }
                }
                //分析结构校验
                for (i = 0; i < xtsl; i++) {
                    var jmtx_name = jmtx[i].options[jmtx[i].selectedIndex].innerText;
                    if (jmtx_name.indexOf("选择题") != -1) {
                        stlb[i].value = "C";
                    }
                    if (jmtx_name == "填空题") {
                        stlb[i].value = "F";
                    }
                    if (jmtx_name == "作文" || jmtx_name == "书面表达") {
                        stlb[i].value = "W";
                    }
                }
            }
        //保存分析结构
        document.querySelectorAll("button.width_btn.green_btn")[1].onclick();
        }
    var bt_all, btsl, qtsl;
    //所有标题,标题数量,切图数量;
    /*
    bt_all = document.querySelectorAll("ul.header_nav_ul")[0];
    btsl = bt_all.childElementCount;
    bt_all.lastChild.insertAdjacentHTML('afterEnd', '<li id="img_sort" style="color:orange">切图重排</li>');
    bt_all.lastChild.insertAdjacentHTML('afterEnd', '<li id="img_download" style="color:orange">切图下载</li>');
    bt_all.lastChild.insertAdjacentHTML('afterEnd', '<li id="ianalyze_enhance" style="color:red">分析增强</li>');
    //bt_all.insertAfter('<li id="img_sort" style="color:orange">切图重排</li>',bt_all.lastChild)
    document.querySelectorAll('#img_sort')[0].onclick = img_sort;
    document.querySelectorAll('#img_download')[0].onclick = img_download;
    document.querySelectorAll('#ianalyze_enhance')[0].onclick = analyze_enhance;
    */
    //切图重排
    function img_sort() {
        var img_all = document.querySelectorAll("ul#cutImage.cutImage_ul")[0];
        qtsl = img_all.children.length;
        var img_arr = new Array(qtsl);
        for (i = 0; i < qtsl; i++) {
            nbth = img_all.children[i].innerText.replace(".gif", "");
            nbth = nbth.replace("-", "."); //方便后续作为数组排序
            img_arr[i] = nbth;
            if (nbth.indexOf("-") != -1) {
                nbth_start = nbth.slice(0, nbth.indexOf("-"));
                nbth_end = nbth.slice(nbth.indexOf("-") + 1);
            }
        }
        img_arr.sort(function(a, b) {
            return a - b
        }); //按照数值大小排序
        for (i = 0; i < qtsl; i++) {
            img_arr[i] = img_arr[i].replace(".", "-");
            var img_url = document.querySelectorAll("img.img_pdf_view")[0].src.replace(img_all.children[0].innerText, "") + img_arr[i] + ".gif";
            img_all.lastElementChild.insertAdjacentHTML('afterEnd', img_arr[i] + '<img src="' + img_url + '" style="width:100%">');
        }
        console.log(img_arr);
        //img_all.insertBefore(img_all.children[1],img_all.children[0]) //排序方法
    }
    //切图下载
    function img_download() {
        //http://www.moofen.net/res/res/paper/9/1001651029228864/s/4.gif
        //temp =document.querySelectorAll("img.img_pdf_view")[0].src;
        //var sjbh=temp.match(/^(https?:\/\/www\.moofen\.net\/)(res\/res\/paper\/\d+\/(\d{16})\/s\/.+)$/i)[3];
        var img_all = document.querySelectorAll("ul#cutImage.cutImage_ul")[0];
        qtsl = img_all.children.length;
        var img_arr = new Array(qtsl);
        for (i = 0; i < qtsl; i++) {
            img = document.querySelectorAll("img.img_pdf_view")[i].src;
            //批量下载多个文件,https://www.cnblogs.com/zhangym118/p/11352164.html
            let a = document.createElement('a') // 创建a标签
            let e = document.createEvent('MouseEvents') // 创建鼠标事件对象
            e.initEvent('click', false, false) // 初始化事件对象
            a.href = img // 设置下载地址
            a.download = '' // 设置下载文件名
            a.dispatchEvent(e)
        }
    }
    //分析增强
    //分析管理的界面,某一次考试,第三排年级日期后面新增一个按钮,触发成绩数据下载的动作
    //document.querySelectorAll('#ggg')[0].parentElement.parentElement.parentElement.children[2].children[3].onclick()
    //网阅系统,点击选择某一次的考试,自动汇总下载详分
    function analyze_enhance() {
        var exam_all, exam_num, school_id;
        exam_all = document.querySelectorAll("div.card-header");
        exam_num = exam_all.length;
        school_id = document.querySelectorAll("span#schoolName")[0].dataset.id;
        for (i = 0; i < exam_num; i++) {}
    }
    ////学校管理界面-配置-等级-得分率
    function grade_scoring_rate() {
        var input_box, subject_box, subject_num;
        //新增等级规则
        document.querySelectorAll("button#addLevel")[0].click();
        //方式改成得分率
        document.querySelectorAll("#selectLevelType")[0].value = 4;
        //规则等级添加并填入对应的值
        for (i = 0; i < 3; i++) {
            document.querySelectorAll("button.btn.btn-success.btn-sm.add")[0].click();
        }
        var dic = {
            A: 80,
            B: 70,
            C: 60,
            D: 0
        };
        i = 0;
        for (var key in dic) {
            input_box = document.querySelectorAll("input.form-control.form-control-sm.d-inline.w-auto");
            input_box[i * 2].value = dic[key];
            input_box[i * 2 + 1].value = key;
            i++;
        }
        //勾选所有学科
        subject_box = document.querySelectorAll("div#subject")[0];
        subject_num = subject_box.childElementCount;
        for (i = 0; i < subject_num; i++) {
            //subject_box.children[i].children[0].click(); //切换input-checkbox的选中状态
            subject_box.children[i].children[0].checked = true; //将input-checkbox设为选中状态
        }
    }
    function multi_funcion_switch() {
        var multi_funcion_num=prompt("多功能切换-功能选择","1");
            if (multi_funcion_num == "1" ) {
                var multi_funcion_call = grade_scoring_rate;
            }
        document.querySelectorAll('#multi_funcion_call')[0].onclick = multi_funcion_call;
    }
}
//cube-知识点标注-上传试卷界面,根据上传文件名称自动选择相应选项,未完成
//http://www.moofen.net/cube/pages/cube.html
/*
else if ((m = url.match(/^(https?:\/\/www\.moofen\.net\/)(cube\/pages\/cube\.html)$/i))) {
        //document.querySelectorAll('li')[6].insertAdjacentHTML('afterEnd', '<input type="search" class="form-control" width="100" placeholder="请输入试卷名称">');
        document.querySelectorAll('li')[6].insertAdjacentHTML('afterEnd', '<button class="btn btn-primary" type="button" id="uploadPaper" onclick="MARK.onClickUploadPaper()">上传试卷</button>');
        document.querySelectorAll('li')[6].insertAdjacentHTML('afterEnd', '<div  id="btn1" class="btn btn-success">EhanceUPLOAD</div>');
        document.querySelectorAll('select#grade.form-control.form-control-sm.required')[0].value=8;
        btn1 = document.getElementById('btn1');
        function EhanceUPLOAD() {
            document.querySelectorAll('select#grade.form-control.form-control-sm.required')[0].value=8;
            var matchs = document.getElementsByClassName('table-item');
        }
        btn1.onclick = EhanceUPLOAD;
}
*/
//可弃用,uBlock插件更容易实现
//青夏教育,试题搜索结果页面去掉干扰
//http://www.1010jiajiao.com/czsx/shiti_id_7d8dda54d23f54ee9d80e1a05b5eb272
else if ((m = url.match(/^(https?:\/\/www\.1010jiajiao\.com\/)(czsx\/shiti_id_.+)$/i))) {
    document.querySelectorAll('div.sublist')[2].remove();
    document.querySelectorAll('div.ndwz')[0].remove();
    document.querySelectorAll('div#daan_recommend')[0].remove();
    document.querySelectorAll('div.xt')[0].remove();
}