// ==UserScript== // @name 遇见八三的心动瞬间 // @namespace // @version 1.6.10-20240115 // @description 学企来砍一刀 // @author 我纯f5捏 // @match https://www.cscec83.cn/user/login* // @match http://120.27.194.253/* // @match http://47.98.152.121/* // @match https://learn.cscec83.cn/* // @match https://ks.wjx.top/*/* // @match http://ks.wjx.top/*/* // @exclude https://www.cscec83.cn/dashboard/analysis* // @compatible edge // @license // @icon https://s11.ax1x.com/2023/12/30/piOtPX9.jpg // @grant GM_addStyle // @grant GM_setValue // @grant GM_getValue // @require https://cdn.jsdelivr.net/npm/tesseract.js@5/dist/tesseract.min.js // @require https://update.greasyfork.icu/scripts/447483/1071404/Boxjs.js // @require https://update.greasyfork.icu/scripts/482872/1308046/%E4%B8%AD%E5%BB%BA%E5%AD%A6%E4%BC%81%E6%9D%A5%E5%85%A8%E9%A2%98%E5%BA%93part1.js // @require https://update.greasyfork.icu/scripts/482873/1299972/%E4%B8%AD%E5%BB%BA%E5%AD%A6%E4%BC%81%E6%9D%A5%E5%85%A8%E9%A2%98%E5%BA%93part2.js // @require https://update.greasyfork.icu/scripts/482874/1299974/%E4%B8%AD%E5%BB%BA%E5%AD%A6%E4%BC%81%E6%9D%A5%E5%85%A8%E9%A2%98%E5%BA%93part3.js // @require https://update.greasyfork.icu/scripts/482875/1299975/%E4%B8%AD%E5%BB%BA%E5%AD%A6%E4%BC%81%E6%9D%A5%E5%85%A8%E9%A2%98%E5%BA%93part4.js // @require https://update.greasyfork.icu/scripts/482876/1299976/%E4%B8%AD%E5%BB%BA%E5%AD%A6%E4%BC%81%E6%9D%A5%E5%85%A8%E9%A2%98%E5%BA%93part5.js // @require https://update.greasyfork.icu/scripts/482877/1299978/%E4%B8%AD%E5%BB%BA%E5%AD%A6%E4%BC%81%E6%9D%A5%E5%85%A8%E9%A2%98%E5%BA%93part6.js // @require https://update.greasyfork.icu/scripts/484651/1312352/cscec83require.js // @downloadURL none // ==/UserScript== /* *********************************************************** 以上参数为脚本必须读取的脚本元属性值,请勿随意改动 以下参数修改请参见语雀功能文档或者代码注释定制化修改 *********************************************************** */ (function () { 'use strict'; var oldStudyAdminRevise = true; // 控制学企来首页修改, true 为刷新; false 为不刷; var cscecAdminCount = true; // 控制主页刷新次数, true 为刷新; false 为不刷新; var rootFontSize = 46.6667; // 页面如果大小显示异常, 可尝试修改, 请勿随意变动此数值; var clickNextPage = true; // 旧版学企来部门中心默认进入第二页, false 则不翻页; var answerTimeGap = 400; // 一键做题操作间隔, 太快页面来不及响应, 太慢影响使用, 单位:ms; var loginCheck = 500; // 输入验证码后登录的间隔, 太快无法响应, 太慢影响使用, 单位:ms; var monitorGap = 400; // 控制url监控间隔, 太快会影响性能, 太慢影响使用, 单位:ms; var yourName = ""; // 问卷星填写名字 var yourApartment = "/"; // 问卷星填写部门 var yourId = ""; // 问卷星填写员工编号 var yourPost = "专业工程师"; // 问卷星填写岗位 /* *********************************************************** 以下参数为功能必须的参数初始化或功能预留,请勿随意改动 *********************************************************** */ var AllQA = AllQA1.concat(AllQA2, AllQA3, AllQA4, AllQA5, AllQA6); AllQA = AllQA.map(item => { return { ...item, question: trimText(item.question), option1: trimText(item.option1), option2: trimText(item.option2), option3: trimText(item.option3), option4: trimText(item.option4), option5: trimText(item.option5), option6: trimText(item.option6), option7: trimText(item.option7), option8: trimText(item.option8) }; }); console.log("全题库共 " + AllQA.length + " 道题目"); try { var titleMsgAlert = GM_getValue("userName") + " " + GM_getValue("nickName"); } catch (error) { var titleMsgAlert = "未登录"; } var targetValues = ["您的姓名:", "您的部门:", "所属项目:", "所在岗位:"]; var rightArr = ["正确", "对", "✓", "√", "A", "a", "是"]; var wrongArr = ["错误", "错", "×", "x", "B", "b", "否"]; var clickMyPractice = true; var isDraggable = false; var innerMsgAlert = ""; var QAComplete = false; var answerArray = ''; var currentUrl = ""; var clickCount = 0; var a = ""; var b = ""; var C = ""; var d = ""; var examQuestionTypeArray = []; var oldPracticeData = []; var practiceData = []; var savedData = []; overrideOpen(); setMouseImg(); setTipsImg(); webPageWatchUrl(urlOperate); console.log("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); console.log("+ " + "请关注语雀文档对本脚本的说明:"); console.log("+ " + "https://www.yuque.com/yuqueyonghuuadmba/kb/gan09a7zvlktoa9v?singleDoc# 《遇见八三的心动瞬间》"); console.log("+ " + "语雀文档地址如上。"); console.log("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); window.onload = function () { addDiv(); changeByClick(); var tipsCard = document.getElementById("tipsCard"); tipsCard.addEventListener('mouseover', displayTipsImg); tipsCard.addEventListener('mouseout', vanishTipsImg); tipsCard.addEventListener('mousemove', displayTipsImg); document.addEventListener('mousemove', mouseImgMove); btnClick(".option1", verifyAndToast); btnClick(".option2", function () { if (getAb()) { switch (verifyUrl()) { case 1: answerExam(); break; case 2: simpleToast("此页面未配置本功能", "仅支持一键考试功能", 3e3); break; case 3: answerOldQuestion(); break; case 4: simpleToast("此页面未配置本功能", "请使用问卷星答题功能", 3e3); break; case 5: simpleToast("此页面未配置本功能", "请使用填写验证码功能", 3e3); break; case 6: answerQuestion(); break; default: simpleToast("此页面未配置本功能", "如功能配置错误请联系我", 3e3); break; } } else { failVerify(); waitToast(titleMsgAlert, innerMsgAlert, a); } }); btnClick(".option3", function () { if (getAb()) { switch (verifyUrl()) { case 1: autoExam(); break; case 2: answerOldExam(); break; case 3: simpleToast("此页面未配置本功能", "不支持一键考试功能", 3e3) break; case 4: simpleToast("此页面未配置本功能", "请使用问卷星答题功能", 3e3); break; case 5: simpleToast("此页面未配置本功能", "请使用填写验证码功能", 3e3); break; case 6: autoAnswerQuestion(); break; default: simpleToast("此页面未配置本功能", "如功能配置错误请联系我", 3e3); break; } } else { failVerify(); waitToast(titleMsgAlert, innerMsgAlert, a); } }); btnClick(".option4", answerQAStarExam); btnClick(".option5", function () { deleteAllCookies(); clearCookie(); clearStorage(); console.log("cookie数据已清除"); }); btnClick(".option6", function () { var root = document.documentElement; var currentSize = parseFloat(window.getComputedStyle(root).fontSize); root.style.fontSize = `${currentSize * 3 / 4}px`; }); btnClick(".option7", fillVerificationCode); btnClickToUrl(".option9", "https://space.bilibili.com/43880280?spm_id_from=444.42.0.0"); getWords(); } function getWords() { fetch("https://oiapi.net/API/Sentences") .then(response => { if (!response.ok) { throw new Error("Network response was not ok"); } return response.json(); }) .then(data => { if (data.code === 1) { document.querySelector("#questionAnswerTexts1").innerText = data.data.content; document.querySelector("#questionAnswerTexts2").innerText = " ——" + data.data.works + " " + data.data.author; } else { document.querySelector("#questionAnswerTexts1").innerText = "今日无事"; } }) .catch(error => { console.error("Fetch error:", error); }); } function answerOldQuestion() { var titleName = document.querySelector(".title"); if (titleName) { if (titleName.innerText === "每日一练" || titleName.innerText === "闯关练习") { var elements = document.getElementsByClassName("issus-item-title-text"); try { var trimmedText = trimText(elements[0].innerText); } catch (error) { } let questionAnswerBankIndex = AllQA.findIndex(function (item) { return item.question == trimmedText; }); if (questionAnswerBankIndex !== -1 && getAb()) { let questionType = getType(questionAnswerBankIndex); if (questionType.includes("单选")) { let answerSpans = document.querySelectorAll(".issus-item-answer-radio-label"); let answerArray = convertToNumbers(convertAnswerToArray(questionAnswerBankIndex)); if (answerSpans[answerArray[0] - 1].parentNode.parentNode.parentNode.classList.contains('is-checked')) { clickOldNextQuestion(); } else { answerSpans[answerArray[0] - 1].click(); } } else if (questionType.includes("判断")) { var judgeStr = getAnswer(questionAnswerBankIndex).match(/(正确)|(错误)|[对错✓√×xABab]/g); try { let judgeStrClick = 'input[class="el-radio__original"][value=' + judgeStr + ']'; document.querySelector(judgeStrClick).click(); } catch (error) { if (rightArr.includes(judgeStr[0])) { for (let i = 0; i < rightArr.length; i++) { try { var judgeStrClick = 'input[class="el-radio__original"][value=' + rightArr[i] + ']'; if (document.querySelector(judgeStrClick).parentNode.parentNode.classList.contains('is-checked')) { clickOldNextQuestion(); break; } else { document.querySelector(judgeStrClick).click(); break; } } catch (error) { } } } if (wrongArr.includes(judgeStr[0])) { for (let i = 0; i < wrongArr.length; i++) { try { var judgeStrClick = 'input[class="el-radio__original"][value=' + wrongArr[i] + ']'; document.querySelector(judgeStrClick).click(); if (document.querySelector(judgeStrClick).parentNode.parentNode.classList.contains('is-checked')) { clickOldNextQuestion(); break; } else { document.querySelector(judgeStrClick).click(); break; } } catch (error) { } } } } } else if (questionType.includes("多选")) { let answerSpans = document.querySelectorAll('span.el-checkbox__input'); let arr = convertToNumbers(convertAnswerToArray(questionAnswerBankIndex)); let clickJudge = 1; for (let j = 0; j < arr.length; j++) { let isChecked = answerSpans[arr[0] - 1].classList.contains('is-checked'); clickJudge = clickJudge * isChecked; } if (clickJudge == 1 || clickJudge == NaN) { clickOldNextQuestion(); } else { for (var i = 0; i < arr.length; i++) { // 因为页面异步动画影响,直接点击会无法处理 (function (i) { requestAnimationFrame(function () { answerSpans[arr[i] - 1].click(); }); })(i); } } } } else { simpleToast("未找到答案", "题库无此题,请及时记录维护题库或 Ctrl+S 保存页面", 2e3); } } else if (titleName.innerText === "成绩结果") { if (document.querySelector(".upper-limit-tips") && document.querySelector(".upper-limit-tips").innerText.includes("积分已达到上限")) { // 返回 setTimeout(function () { document.querySelector(".back").childNodes[0].click(); }, 100); toast("完成", "此练习分数已满,请选择下一项练习。", 2e3); } else { // 再来一组 document.querySelector(".back").childNodes[2].click(); toast("未完成", "此练习分数未满,请继续答题。", 2e3); simpleToast("此页面未配置本功能", "请进入指定界面或关闭此脚本!", 3e3); } } } } function clickOldNextQuestion() { try { let parentElement = document.querySelector('div[class="btn-content"]'); let element = parentElement.querySelector('.el-button.fr.el-button--primary.el-button--mini'); if (element === undefined || element === null) { clickSpanContainingText('结束练习'); } else { clickSpanContainingText('确定'); clickSpanContainingText('下一题'); } } catch (error) { console.log("尝试确定失败"); } } function answerOldExam() { removeListener(); try { examQuestionTypeArray = getQuestionType(); for (let i = 0; i < examQuestionTypeArray.length; i++) { if (examQuestionTypeArray[i].Type.includes("单选")) { // console.log("开始作答单选题"); let typeElements = document.querySelector("#app > div > div.preview-box > div.preview-main > div:nth-child(" + (i + 1) + ")"); let childrenQuestion = typeElements.getElementsByClassName("issus-item-title-text"); for (let j = 0; j < childrenQuestion.length; j++) { let questionFind = trimText(childrenQuestion[j].innerText); let questionIndex = AllQA.findIndex(function (item) { return item.question == questionFind; }); try { if (questionIndex > -1) { let childrenAnswer = childrenQuestion[j].parentElement.nextElementSibling.getElementsByClassName(("issus-item-answer-radio-label")); let answerArray = convertAnswerArrayToDigitArray(questionIndex); setTimeout(() => { childrenAnswer[answerArray[0] - 1].click(); console.log("已作答单选题 " + (j + 1)); }, 10); } else { console.log("未获取到单选题 " + (j + 1) + " 的答案"); continue; } } catch { console.log("获取单选题 " + (j + 1) + " 答案失败"); continue; } } } else if (examQuestionTypeArray[i].Type.includes("多选")) { // console.log("开始作答多选题"); let typeElements = document.querySelector("#app > div > div.preview-box > div.preview-main > div:nth-child(" + (i + 1) + ")"); let childrenQuestion = typeElements.getElementsByClassName("issus-item-title-text"); for (let j = 0; j < childrenQuestion.length; j++) { let questionFind = trimText(childrenQuestion[j].innerText); let questionIndex = AllQA.findIndex(function (item) { return item.question == questionFind; }); try { if (questionIndex > -1) { // 获取对应题目的选项 let childrenAnswer = childrenQuestion[j].parentElement.nextElementSibling.getElementsByClassName(("issus-item-answer-radio-label")); let answerArray = convertAnswerArrayToDigitArray(questionIndex); for (let n = 0; n < answerArray.length; n++) { (function (n) { requestAnimationFrame(function () { setTimeout(() => { childrenAnswer[answerArray[n] - 1].click(); console.log("已作答多选题 " + (j + 1) + "的选项: " + n); }, 200); }); })(n); } } else { console.log("未获取到多选题 " + (j + 1) + " 的答案"); continue; } } catch { console.log("获取多选题 " + (j + 1) + " 答案失败"); continue; } } } else if (examQuestionTypeArray[i].Type.includes("判断")) { // console.log("开始作答判断题"); let typeElements = document.querySelector("#app > div > div.preview-box > div.preview-main > div:nth-child(" + (i + 1) + ")"); let childrenQuestion = typeElements.getElementsByClassName("issus-item-title-text"); for (let j = 0; j < childrenQuestion.length; j++) { let questionFind = trimText(childrenQuestion[j].innerText); let questionIndex = AllQA.findIndex(function (item) { return item.question == questionFind; }); try { if (questionIndex > -1) { let childrenAnswer = childrenQuestion[j].parentElement.nextElementSibling.getElementsByClassName(("issus-item-answer-radio")); let answerArray = getAnswer(questionIndex).match(/(正确)|(错误)|[对错✓√×xABab]/g); if (answerArray.some(item => rightArr.includes(item))) { childrenAnswer[0].firstChild.click(); } if (answerArray.some(item => wrongArr.includes(item))) { childrenAnswer[1].firstChild.click(); } console.log("已作答判断题 " + (j + 1)); } else { try { let childrenAnswer = childrenQuestion[j].parentElement.nextElementSibling.getElementsByClassName(("issus-item-answer-radio-label")); setTimeout(() => { childrenAnswer[0].firstChild.click(); }, 10); console.log("判断题蒙一个 " + (j + 1)); } catch (error) { } console.log("未获取到判断题 " + (j + 1) + " 的答案"); continue; } } catch { console.log("获取判断题 " + (j + 1) + " 答案失败"); continue; } } } else { simpleToast("存在无法处理的题型", "请及时记录维护题库或 Ctrl+S 保存页面", 2e3); continue; } } } catch (error) { let childrenQuestion = document.querySelectorAll(".issus-item-title-text"); // console.log(childrenQuestion.length); for (let j = 0; j < childrenQuestion.length; j++) { let questionFind = trimText(childrenQuestion[j].innerText); let questionIndex = AllQA.findIndex(function (item) { return item.question == questionFind; }); try { if (questionIndex > -1) { if (getType(questionIndex).includes("单选")) { let childrenAnswer = childrenQuestion[j].parentElement.nextElementSibling.getElementsByClassName(("issus-item-answer-radio-label")); let answerArray = convertAnswerArrayToDigitArray(questionIndex); setTimeout(() => { childrenAnswer[answerArray[0] - 1].click(); console.log("已作答单选题 " + (j + 1)); }, 10); } else if (getType(questionIndex).includes("多选")) { let childrenAnswer = childrenQuestion[j].parentElement.nextElementSibling.getElementsByClassName(("issus-item-answer-radio-label")); let answerArray = convertAnswerArrayToDigitArray(questionIndex); for (let n = 0; n < answerArray.length; n++) { (function (n) { requestAnimationFrame(function () { setTimeout(() => { childrenAnswer[answerArray[n] - 1].click(); console.log("已作答多选题 " + (j + 1) + "的选项: " + n); }, 200); }); })(n); } } else if (getType(questionIndex).includes("判断")) { let childrenAnswer = childrenQuestion[j].parentElement.nextElementSibling.getElementsByClassName(("issus-item-answer-radio")); let answerArray = getAnswer(questionIndex).match(/(正确)|(错误)|[对错✓√×xABab]/g); if (answerArray.some(item => rightArr.includes(item))) { childrenAnswer[0].firstChild.click(); } if (answerArray.some(item => wrongArr.includes(item))) { childrenAnswer[1].firstChild.click(); } console.log("已作答判断题 " + (j + 1)); } else { try { let childrenAnswer = childrenQuestion[j].parentElement.nextElementSibling.getElementsByClassName(("issus-item-answer-radio-label")); setTimeout(() => { childrenAnswer[0].firstChild.click(); }, 10); console.log("判断题蒙一个 " + (j + 1)); } catch (error) { } console.log("未获取到判断题 " + (j + 1) + " 的答案"); continue; } } else { console.log("未获取到 " + (j + 1) + " 的答案"); continue; } } catch { console.log("获取 " + (j + 1) + " 答案失败"); continue; } } } } function answerQAStarExam() { try { if (verifyUrl() == 4) { try { document.querySelector("#q1_0").innerText = yourName; document.querySelector("#q1_1").innerText = yourApartment; document.querySelector("#q1_2").innerText = yourId; document.querySelector("#q1_3").innerText = yourPost; } catch (error) { console.log("方式一信息填写失败或部分失败,尝试使用方式二填写"); try { document.querySelector("#q1").value = yourName; document.querySelector("#q2").value = yourApartment; document.querySelector("#q3").value = yourId; document.querySelector("#q4").value = yourPost; } catch (error) { console.log("信息填写失败或部分失败"); } } var QAStarQuestion = document.querySelectorAll('.topichtml'); if (QAStarQuestion.length == 0) { QAStarQuestion = document.querySelectorAll('.topic__type-title'); } for (let j = 0; j < QAStarQuestion.length; j++) { let questionFind = trimText(QAStarQuestion[j].innerText); try { questionFind = questionFind.match(/.+?(?=【.*】$)/)[0] } catch { }; let questionIndex = AllQA.findIndex(function (item) { return item.question == questionFind; }); if (questionIndex > -1) { let answerArray = convertAnswerArrayToDigitArray(questionIndex); for (let i = 0; i < answerArray.length; i++) { (function (i) { requestAnimationFrame(function () { setTimeout(() => { try { QAStarQuestion[j].nextElementSibling.childNodes[answerArray[i] - 1].click(); } catch (error) { try { QAStarQuestion[j].parentNode.nextSibling.childNodes[answerArray[i] - 1].click(); } catch (error) { } } }, 150); }); })(i); } } else { console.log(QAStarQuestion[j] + " 未找到答案", "题库无此题,请及时记录维护题库或 Ctrl+S 保存页面"); } } } else { simpleToast("此页面未配置本功能", "请进入指定界面或关闭此脚本!", 3e3); } } catch (error) { console.log("进入进入exam函数未完全适配导致的问题" + "请 Ctrl+S 保存页面并联系我"); } } function verifyUrl() { currentUrl = window.location.href; // 1 新版学企来考试 if (currentUrl.includes('https://learn.cscec83.cn/exam/examItem')) { return 1; // 2 旧版学企来考试 } else if (currentUrl.includes('http://120.27.194.253/exam/') || currentUrl.includes('http://47.98.152.121/exam/')) { return 2; // 3 旧版学企来练习 } else if (currentUrl.includes('http://120.27.194.253/') || currentUrl.includes('http://47.98.152.121/')) { return 3; // 4 问卷星 } else if (currentUrl.includes('wjx.top/') || currentUrl.includes('wjx.cn/')) { return 4; // 5 公司登录界面 } else if (currentUrl.includes('https://www.cscec83.cn/user/login')) { return 5; // 6 新版学企来练习 } else if (currentUrl.includes('https://learn.cscec83.cn/exam/dayItem')) { return 6; } else { return false; } } function getAnswer(questionAnswerBankIndex) { return AllQA[questionAnswerBankIndex].answer; // 通过传入问题的索引来获取答案 } function getType(questionAnswerBankIndex) { return AllQA[questionAnswerBankIndex].type; } function getQuestion(questionAnswerBankIndex) { return AllQA[questionAnswerBankIndex].question; } function convertAnswerToArray(questionAnswerBankIndex) { let answerArray = getAnswer(questionAnswerBankIndex).match(/[A-Za-z]/g).map(function (val) { return val.toLowerCase(); }); return answerArray; } // 转换字母答案为数字并生成数组 function convertAnswerArrayToDigitArray(questionIndex) { let answerArray = convertAnswerToArray(questionIndex).map(char => char.charCodeAt(0) - 96); return answerArray; } // 数组中字母转换为数字 function convertToNumbers(arr) { return arr.map(function (letter) { var num = letter.charCodeAt(0) - 'a'.charCodeAt(0) + 1; return num; }); } // 点击页面具有某个文本的span function clickSpanContainingText(text) { var spans = document.getElementsByTagName('span'); for (var i = 0; i < spans.length; i++) { if (spans[i].innerText === text) { spans[i].click(); break; } } } function reviseRem() { var root = document.documentElement; var currentSize = parseFloat(window.getComputedStyle(root).fontSize); if (currentSize !== rootFontSize) { // root.style.fontSize = `${currentSize * 4}px`; root.style.fontSize = rootFontSize + "px" } } function webPageWatchUrl(watchCallback) { watchCallback(); currentUrl = window.location.href; setInterval(function () { if (currentUrl !== window.location.href) { currentUrl = window.location.href; watchCallback(currentUrl); } }, monitorGap); } function urlOperate() { reviseRem(); currentUrl = window.location.href; if (verifyUrl() == 4) { try { // 解除复制粘贴限制 setTimeout(function () { $(".textCont,input,textarea").off(); }, 2000) $(".textCont,input,textarea").off(); // 既不生效,再来一次又何妨 document.oncontextmenu = function () { return true; }; document.onselectstart = function () { return true; }; $("body").css("user-select", "text"); syncManyinput(); } catch (error) { console.log("破解复制失败"); } }; if (currentUrl.includes('https://www.cscec83.cn/dashboard/analysis') && cscecAdminCount) { location.reload(); cscecAdminCount = false; }; if ((currentUrl === ('http://120.27.194.253/') || currentUrl === ('http://120.27.194.253/index') || currentUrl === ('http://47.98.152.121/') || currentUrl === ('http://47.98.152.121/index')) && oldStudyAdminRevise) { try { let targetElement = document.querySelectorAll(".nav_item")[0]; targetElement.innerText = "科技质量"; targetElement.style.color = 'red'; targetElement.style.fontWeight = 'bold'; targetElement.parentNode.setAttribute("href", "/org/pgdJgz"); oldStudyAdminRevise = false; } catch (error) { console.log("old学企来首页科技质量修改失败"); } } if (currentUrl == 'http://120.27.194.253/org' || currentUrl === ('http://47.98.152.121/org')) { setApartmentCSS(); if (clickNextPage) { // 进入第二页 try { document.querySelector("#app > div > div.content > div.pagination.el-pagination.is-background > button.btn-next").click(); clickNextPage = false; } catch (error) { console.log("自动点击'我的'失败"); }; }; let departmentElement = document.querySelectorAll(".mechanism_item > .mechanism_item_title"); for (let i = 0; i < departmentElement.length; i++) { let targetElement = departmentElement[i]; if (targetElement.innerText == '科技质量部') { targetElement.style.color = 'red'; targetElement.style.fontWeight = 'bold'; }; }; }; if (currentUrl.match(new RegExp('http://120.27.194.253/org/[a-zA-Z]{6}$')) !== null || currentUrl.match(new RegExp('http://47.98.152.121/org/[a-zA-Z]{6}$')) !== null) { try { if (clickMyPractice) { document.querySelector("#tab-my").click(); document.querySelector(".goods_type_list").childNodes[1].click(); clickMyPractice = false; } } catch (error) { clickMyPractice = false; }; } }; function fillVerificationCode() { if (window.location.href.includes('https://www.cscec83.cn/user/login')) { var imgSrc = document.querySelectorAll("img")[4].src; var image = new Image(); image.src = imgSrc; const { createWorker } = Tesseract; (async () => { const worker = await createWorker('eng'); const { data: { text } } = await worker.recognize(image); var inputElement = document.getElementById("inputCode"); inputElement.value = text; // 创建并触发 input 事件 var event = new Event('input', { bubbles: true, cancelable: true, }); inputElement.dispatchEvent(event); })(); setTimeout(function () { document.querySelector(".login-button").click(); }, loginCheck); } else { simpleToast("此页面未配置本功能", "填写验证码", 2e3); return false; } } // 移动 function handleMouseDown(event) { isDraggable = true; var handleMoveDiv = document.getElementById("mainDiv"); var offsetX = event.clientX - handleMoveDiv.getBoundingClientRect().left; var offsetY = event.clientY - handleMoveDiv.getBoundingClientRect().top; // 阻止默认行为和冒泡 event.preventDefault(); event.stopPropagation(); document.addEventListener('mousemove', handleWindowMouseMove); document.addEventListener('mouseup', handleWindowMouseUp); function handleWindowMouseMove(event) { if (isDraggable) { requestAnimationFrame(() => { handleMoveDiv.style.left = event.clientX - offsetX + 'px'; handleMoveDiv.style.top = event.clientY - offsetY + 'px'; window.getSelection().empty(); }); } } function handleWindowMouseUp() { isDraggable = false; document.removeEventListener('mousemove', handleWindowMouseMove); document.removeEventListener('mouseup', handleWindowMouseUp); } } // 给所有的可选按钮增加点击事件 function changeByClick() { document.getElementById('movedCard').addEventListener('mousedown', handleMouseDown); // 给所有的图片增加点击事件(除了含有speedChoose类的) let images = document.querySelectorAll('.clickable-image'); images.forEach(image => { // 检查图片是否包含speedChoose类,如果不包含则添加点击事件 if (!image.classList.contains('speedChoose')) { image.addEventListener('click', function () { this.classList.toggle('clicked'); }); } }); // 按钮点击互斥 var speedChooses = document.querySelectorAll('.speedChoose'); speedChooses.forEach(function (box) { box.addEventListener('click', function () { // 如果当前按钮已经是点击状态,则取消点击状态,否则激活点击状态 if (box.classList.contains('clicked')) { box.classList.remove('clicked'); } else { // 点击任何一个box时,移除所有box的clicked类 speedChooses.forEach(function (otherBox) { otherBox.classList.remove('clicked'); }); box.classList.add('clicked'); } }); }); } function overrideOpen() { var open = XMLHttpRequest.prototype.open; XMLHttpRequest.prototype.open = function () { var self = this; this.addEventListener('load', function () { var data = self.responseText; var isProfileData = (data.includes('userName') && data.includes('nickName') && data.includes('postGroup')); var isPracticeData = data.includes('testPaperTopics'); var isOldPracticeData = data.includes('loginName') && data.includes('nickname') && data.includes('userNo'); if (isProfileData || isPracticeData || isOldPracticeData) { if (isProfileData) { var profileData = profileData || []; if (!Array.isArray(profileData)) { profileData = []; } profileData = JSON.parse(data); handleProfileData(profileData); } if (isPracticeData) { practiceData = practiceData || []; if (!Array.isArray(practiceData)) { practiceData = []; } practiceData.push(JSON.parse(data)); handlePracticeData(practiceData); } if (isOldPracticeData) { oldPracticeData = oldPracticeData || []; if (!Array.isArray(oldPracticeData)) { oldPracticeData = []; } oldPracticeData.push(JSON.parse(data)); handleOldPracticeData(oldPracticeData); } } }); open.apply(this, arguments); }; } function handlePracticeData(practiceData) { return new Promise(function (resolve) { var targetArray = practiceData.find(function (response) { return response.msg === "操作成功" && response.code === 200 && response.data.testPaperTopics; }); if (targetArray) { let formattedData = outputPracticeTopics(targetArray.data); savedData = formattedData.slice(); } else { console.log('脚本未找到符合条件的题库信息'); } practiceData.length = 0; resolve(); }); } function handleProfileData(profileData) { return new Promise(function (resolve) { var targetArray = Object.values(profileData).find(function (response) { return typeof response === 'object' && response !== null; }); if (targetArray) { let result = { userName: targetArray.userName, nickName: targetArray.nickName, }; let formattedData = outputProfileDataTopics(JSON.stringify(result)); GM_setValue('userName', formattedData.userName); GM_setValue('nickName', formattedData.nickName); titleMsgAlert = GM_getValue("userName") + " " + GM_getValue("nickName"); } else { console.log("脚本未找到符合条件的个人信息"); } targetArray = []; resolve(); }); } function handleOldPracticeData(oldPracticeData) { return new Promise(function (resolve) { var targetArray = oldPracticeData.find(function (response) { return response.code === 200 && response !== null; }); if (targetArray) { let result = { "userName": targetArray.data.loginName, "nickName": targetArray.data.nickname, }; GM_setValue('userName', result.userName); GM_setValue('nickName', result.nickName); titleMsgAlert = GM_getValue("userName") + " " + GM_getValue("nickName"); } else { console.log("脚本未找到符合条件的个人信息"); } targetArray = []; resolve(); }); } function answerQuestion() { try { var isQuestionFound = savedData.some((questionObject) => { return trimText(questionObject.question) == trimText(document.querySelectorAll(".el-card__body")[1].childNodes[2].innerText); }); if (isQuestionFound && getAb()) { var answerList = []; let questionNumber = getQANumber(); for (let i = 0; i < savedData.length; i++) { let answerArray = savedData[i].TrueAnswer.split(','); let numericArray = answerArray.map(function (letter) { // 多减 1 个 1, 后面处理点击次序时方便 return letter.charCodeAt(0) - 65; }); answerList.push(numericArray); } try { if (answerList[questionNumber - 1].length == 1) { var targetAnswerElement = document.querySelectorAll(".el-radio-group")[0].childNodes[answerList[questionNumber - 1][0]]; if (targetAnswerElement && !targetAnswerElement.classList.contains('is-checked')) { targetAnswerElement.click(); console.log("题号 " + questionNumber + " 点选: " + String.fromCharCode((answerList[questionNumber - 1][0] + 1) + 64)); } else { document.querySelectorAll(".el-button")[0].click(); } } else if (answerList[questionNumber - 1].length > 1) { for (let i = 0; i < answerList[questionNumber - 1].length; i++) { (function (i) { requestAnimationFrame(function () { var targetAnswerElement = document.querySelectorAll(".el-checkbox-group")[0].childNodes[answerList[questionNumber - 1][i]]; if (targetAnswerElement && !targetAnswerElement.classList.contains('is-checked')) { targetAnswerElement.click(); console.log("题号 " + questionNumber + " 点击选项: " + String.fromCharCode((answerList[questionNumber - 1][i] + 1) + 64)); } else { document.querySelectorAll(".el-button")[0].click(); } }); })(i); } } else { simpleToast("提醒", "不在可答题的页面", 3e3); } } catch (error) { console.log("异常错误"); } } else { simpleToast("提醒", "尝试检查权限与操作", 3e3); } } catch (error) { clickSpanContainingText("回到首页"); } } function trimOptions(options) { let modifiedOptions = options.map(function (option) { return trimText(option.replace(/[A-J]\. /, '')); }); return modifiedOptions; } function trimOption(option) { return trimText(option.replace(/[A-J]\.\s*/, '')); } function answerExam() { let questionType = document.querySelectorAll(".el-card__body")[1].childNodes[0].childNodes[0].innerText; var questionText = document.querySelectorAll(".el-card__body")[1].childNodes[2].innerText; try { var trimmedText = trimText(questionText) } catch (error) { } let questionAnswerBankIndex = AllQA.findIndex(function (item) { return item.question == trimmedText; }); if (questionType && questionAnswerBankIndex) { if (questionType.includes("单选")) { let options = document.querySelectorAll(".el-radio__label"); let optionTexts = []; for (let i = 0; i < options.length; i++) { optionTexts.push(options[i].innerText); } let trimOptionArray = trimOptions(optionTexts); let optionKey = "option" + (AllQA[questionAnswerBankIndex].answer.toLowerCase().charCodeAt(0) - 'a'.charCodeAt(0) + 1); let isTrueOption = trimOptionArray.indexOf(AllQA[questionAnswerBankIndex][optionKey]); if (isTrueOption !== -1) { if (options[isTrueOption].previousElementSibling.classList.contains("is-checked")) { if (document.querySelectorAll(".el-button")[2].innerText == "下一题") { document.querySelectorAll(".el-button")[2].click(); } else { document.querySelectorAll(".el-button")[1].click(); } } else { options[isTrueOption].click(); } } else { simpleToast("可能系统题库有所变更", AllQA[questionAnswerBankIndex][optionKey], 3e3); } } else if (questionType.includes("多选")) { if (QAComplete) { if (document.querySelectorAll(".el-button")[2].innerText == "下一题") { document.querySelectorAll(".el-button")[2].click(); QAComplete = false; } else { document.querySelectorAll(".el-button")[1].click(); } } else { QAComplete = false; let options = document.querySelectorAll(".el-checkbox__label"); let optionTexts = []; for (let i = 0; i < options.length; i++) { optionTexts.push(options[i].innerText); } let trimOptionArray = trimOptions(optionTexts); let AnswerArrayToNumberArray = convertAnswerArrayToDigitArray(questionAnswerBankIndex); for (let i = 0; i < AnswerArrayToNumberArray.length; i++) { let optionKey = "option" + AnswerArrayToNumberArray[i]; let isTrueOption = trimOptionArray.indexOf(AllQA[questionAnswerBankIndex][optionKey]); if (isTrueOption !== -1) { if (!options[isTrueOption].previousElementSibling.classList.contains("is-checked")) { try { (function (i) { requestAnimationFrame(function () { options[isTrueOption].click(); }); })(i); } catch (error) { console.log("多选题选项缺少"); } } } else { simpleToast("可能系统题库有所变更", AllQA[questionAnswerBankIndex][optionKey], 3e3); } if (i == AnswerArrayToNumberArray.length - 1) { QAComplete = true; } } } } else if (questionType.includes("判断")) { let options = document.querySelectorAll(".el-radio__label"); // optionTexts 预留参数,无实际意义,目前题目答案均为"对"错" let optionTexts = []; for (let i = 0; i < options.length; i++) { optionTexts.push(options[i].innerText); } let optionKey = AllQA[questionAnswerBankIndex].answer; if (optionKey) { switch (optionKey) { case 'A': for (let j = 0; j < options.length; j++) { if (rightArr.includes(options[j].innerText)) { if (options[j].previousElementSibling.classList.contains("is-checked")) { if (document.querySelectorAll(".el-button")[2].innerText == "下一题") { document.querySelectorAll(".el-button")[2].click(); } else { document.querySelectorAll(".el-button")[1].click(); } } else { options[j].click(); } } } break; case 'B': for (let j = 0; j < options.length; j++) { if (wrongArr.includes(options[j].innerText)) { if (options[j].previousElementSibling.classList.contains("is-checked")) { if (document.querySelectorAll(".el-button")[2].innerText == "下一题") { document.querySelectorAll(".el-button")[2].click(); } else { document.querySelectorAll(".el-button")[1].click(); } } else { options[j].click(); } } } break; default: console.log("题库答案错误"); break; } } } } else { if (questionType.includes("单选") || questionType.includes("判断")) { if (document.querySelectorAll(".el-radio__label")[0]) { var option1 = trimOption(document.querySelectorAll(".el-radio__label")[0].innerText) } else { option1 = "" }; if (document.querySelectorAll(".el-radio__label")[1]) { var option2 = trimOption(document.querySelectorAll(".el-radio__label")[1].innerText) } else { option2 = "" }; if (document.querySelectorAll(".el-radio__label")[2]) { var option3 = trimOption(document.querySelectorAll(".el-radio__label")[2].innerText) } else { option3 = "" }; if (document.querySelectorAll(".el-radio__label")[3]) { var option4 = trimOption(document.querySelectorAll(".el-radio__label")[3].innerText) } else { option4 = "" }; if (document.querySelectorAll(".el-radio__label")[4]) { var option5 = trimOption(document.querySelectorAll(".el-radio__label")[4].innerText) } else { option5 = "" }; if (document.querySelectorAll(".el-radio__label")[5]) { var option6 = trimOption(document.querySelectorAll(".el-radio__label")[5].innerText) } else { option6 = "" }; if (document.querySelectorAll(".el-radio__label")[6]) { var option7 = trimOption(document.querySelectorAll(".el-radio__label")[6].innerText) } else { option7 = "" }; if (document.querySelectorAll(".el-radio__label")[7]) { var option8 = trimOption(document.querySelectorAll(".el-radio__label")[7].innerText) } else { option8 = "" }; } if (questionType.includes("多选")) { if (document.querySelectorAll(".el-checkbox__label")[0]) { var option1 = trimOption(document.querySelectorAll(".el-checkbox__label")[0].innerText) } else { option1 = "" }; if (document.querySelectorAll(".el-checkbox__label")[1]) { var option2 = trimOption(document.querySelectorAll(".el-checkbox__label")[1].innerText) } else { option2 = "" }; if (document.querySelectorAll(".el-checkbox__label")[2]) { var option3 = trimOption(document.querySelectorAll(".el-checkbox__label")[2].innerText) } else { option3 = "" }; if (document.querySelectorAll(".el-checkbox__label")[3]) { var option4 = trimOption(document.querySelectorAll(".el-checkbox__label")[3].innerText) } else { option4 = "" }; if (document.querySelectorAll(".el-checkbox__label")[4]) { var option5 = trimOption(document.querySelectorAll(".el-checkbox__label")[4].innerText) } else { option5 = "" }; if (document.querySelectorAll(".el-checkbox__label")[5]) { var option6 = trimOption(document.querySelectorAll(".el-checkbox__label")[5].innerText) } else { option6 = "" }; if (document.querySelectorAll(".el-checkbox__label")[6]) { var option7 = trimOption(document.querySelectorAll(".el-checkbox__label")[6].innerText) } else { option7 = "" }; if (document.querySelectorAll(".el-checkbox__label")[7]) { var option8 = trimOption(document.querySelectorAll(".el-checkbox__label")[7].innerText) } else { option8 = "" }; } console.log("{\n" + "question: '" + trimmedText + "',\n" + "answer: " + "'',\ntype'" + document.querySelectorAll(".el-card__body")[1].childNodes[0].childNodes[0].innerText.match(/单选题|多选题|判断题/g)[0] + "',\n" + "option1: '" + option1 + "',\n" + "option2: '" + option2 + "',\n" + "option3: '" + option3 + "',\n" + "option4: '" + option4 + "',\n" + "option5: '" + option5 + "',\n" + "option6: '" + option6 + "',\n" + "option7: '" + option7 + "',\n" + "option8: '" + option8 + "',\n" + "},"); } } function autoExam() { let autoAnswerCount = 0; console.log("开始自动做题,共计 " + document.querySelectorAll(".el-col").length + " 道题目"); const autoExam = setInterval(() => { if (autoAnswerCount < 20) { autoAnswerCount++; answerExam(); } else { clearInterval(autoExam); console.log("结束自动做题"); } }, 100); } function autoAnswerQuestion() { if (getAb()) { if (savedData.length == 0) { simpleToast("未劫持到数据", "一键答题仅支持新版学企来、旧版学企来考试与问卷星", 2e3); } else { for (let i = getQANumber() - 1; i < savedData.length; i++) { try { setTimeout(function () { answerQuestion(); }, answerTimeGap * i); } catch (error) { simpleToast("提醒", "请正常手动答题或重新进入", 3e3); } try { setTimeout(function () { document.querySelectorAll(".el-button")[0].click(); }, answerTimeGap * (i + 1 / 2)); } catch (error) { simpleToast("提醒", "不在指定页面", 3e3); } } setTimeout(function () { simpleToast("完成", "所有题目已完成", 3e3); }, answerTimeGap * savedData.length); } } else { simpleToast("权限提醒", "请联系管理员添加权限", 2e3); } } function getAb() { try { var a = userList.some(function (user) { if (user.userName === GM_getValue("userName") && user.nickName === GM_getValue("nickName")) { return true; } else { return false; } }); } catch (error) { simpleToast("提醒", "请从公司页面正常渠道进入", 3e3); return false; } if (a) { try { var userName = userList.find(u => u.userName === GM_getValue("userName")); var userTime = userName ? userName.time : null; } catch (error) { console.log("时长获取错误。"); return false; } innerMsgAlert = ""; innerMsgAlert = verifyTime(userTime) ? verifyTime(userTime) : "  权限过期或已无权限 请联系重新授权。  "; return verifyTime(userTime); } else { failVerify(); return false; } } function failVerify() { if (userList.find(u => u.userName === GM_getValue("userName")) && GM_getValue("userName") !== undefined && GM_getValue("nickName") !== undefined) { console.log(userList.find(u => u.userName === GM_getValue("userName"))); titleMsgAlert = GM_getValue("userName") + " " + GM_getValue("nickName"); var userName = userList.find(u => u.userName === GM_getValue("userName")); var userTime = userName ? userName.time : null; innerMsgAlert = verifyTime(userTime) ? verifyTime(userTime) : "  权限过期 请联系重新授权。  "; } else { if (GM_getValue("userName") !== undefined && GM_getValue("nickName") !== undefined) { titleMsgAlert = GM_getValue("userName") + " " + GM_getValue("nickName"); } else { titleMsgAlert = "未登录"; } innerMsgAlert = ""; for (let i = 0; i < failStringArray.length; i++) { innerMsgAlert += String.fromCharCode(failStringArray[i]); } } } function verifyAndToast() { getAb(); waitToast(titleMsgAlert, innerMsgAlert, a); } function waitToast(titleText, innerText, logText) { let CustomBox = Box.mixin({ customFunction: function () { console.log(logText); }, }); let customBoxInstance = new CustomBox({ title: titleText, text: innerText, }); try { customBoxInstance.customFunction(); } catch (error) { console.log("toast 库 error"); } } function simpleToast(title, innerText, time) { let Toast = Box.mixin({ title: title, toast: true, time: time, }); new Toast({ text: innerText }); } function clearCookie() { // 这段代码来自其它脚本,为MIT协议, var keys = document.cookie.match(/[^ =;]+(?==)/g); if (keys) { for (var i = keys.length; i--;) { document.cookie = keys[i] + '=0;path=/;expires=' + new Date(0).toUTCString(); document.cookie = keys[i] + '=0;path=/;domain=' + document.domain + ';expires=' + new Date(0).toUTCString(); document.cookie = keys[i] + '=0;path=/;domain=ratingdog.cn;expires=' + new Date(0).toUTCString(); } } location.reload(); }; // 通用函数,清理cookie【方法2】 function deleteAllCookies() { var cookies = document.cookie.split(";"); console.log(cookies) for (var i = 0; i < cookies.length; i++) { var cookie = cookies[i]; var eqPos = cookie.indexOf("="); var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie; document.cookie = name + "=;"; //document.cookie = null } var cookies2 = document.cookie.split(";"); } // 通用函数,清理storage function clearStorage() { localStorage.clear() sessionStorage.clear() } function btnClick(query, func) { document.querySelector(query).addEventListener('click', func); } function btnClickToUrl(query, url) { btnClick(query, function () { window.open(url).location; }) } // 同步Manyinput的内容到真正的input标签 // 来源: EasyWJX;作者: MelonFish function syncManyinput() { setInterval(function () { var all_textCont = document.querySelectorAll('.textCont') for (var i = 0; i < all_textCont.length; i++) { var input = all_textCont[i].parentNode.previousSibling; input.value = all_textCont[i].innerText } }, 1500) } function removeListener() { try { history.pushState = null; console.log("移除页面切换监听1成功"); } catch (error) { console.log("移除页面切换监听1失败"); } try { window.removeEventListener("popstate", console.log("移除页面切换监听2成功")); } catch (error) { console.log("移除页面切换监听2失败"); } } })();