// ==UserScript==
// @name 遇见八三的心动瞬间
// @namespace
// @version 1.12.16.20240318
// @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/*/*
// @match https://www.amap.com/*
// @match https://www.cscec83.cn/dashboard/analysis*
// @compatible edge
// @license
// @icon https://www.gstatic.com/android/keyboard/emojikitchen/20201001/u1f614/u1f614_u1f614.png
// @grant GM_addStyle
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_deleteValue
// @grant GM_notification
// @grant GM_setClipboard
// @run-at document-start
// @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/462234/1307862/Message.js
// @require https://update.greasyfork.icu/scripts/482872/1344837/%E4%B8%AD%E5%BB%BA%E5%AD%A6%E4%BC%81%E6%9D%A5%E5%85%A8%E9%A2%98%E5%BA%93%E5%8D%95%E9%80%891.js
// @require https://update.greasyfork.icu/scripts/482873/1344838/%E4%B8%AD%E5%BB%BA%E5%AD%A6%E4%BC%81%E6%9D%A5%E5%85%A8%E9%A2%98%E5%BA%93%E5%8D%95%E9%80%892.js
// @require https://update.greasyfork.icu/scripts/482874/1344787/%E4%B8%AD%E5%BB%BA%E5%AD%A6%E4%BC%81%E6%9D%A5%E5%85%A8%E9%A2%98%E5%BA%93%E5%A4%9A%E9%80%89.js
// @require https://update.greasyfork.icu/scripts/482875/1344786/%E4%B8%AD%E5%BB%BA%E5%AD%A6%E4%BC%81%E6%9D%A5%E5%85%A8%E9%A2%98%E5%BA%93%E5%88%A4%E6%96%AD.js
// @require https://update.greasyfork.icu/scripts/484651/1342101/cscec83require.js
// @downloadURL none
// ==/UserScript==
/*
***********************************************************
以上参数为脚本必须读取的脚本元属性值,请勿随意改动
以下参数修改请参见语雀功能文档或者代码注释定制化修改
***********************************************************
*/
killAllMonitor();
(function () {
'use strict';
var visionNum = "1.12.16.20240318";
var cscecAdminCount = true; // 控制主页是否隐藏脚本窗口, true 为隐藏; false 为不隐藏;
const rootFontSize = 46.6667; // 页面如果大小显示异常, 可尝试修改, 请勿随意变动此数值;
const answerTimeGap = 100; // 一键做题操作间隔, 太快页面来不及响应, 太慢影响使用, 单位:ms;
const loginCheck = 1000; // 输入验证码后登录的间隔, 太快无法响应, 太慢影响使用, 单位:ms;
const monitorGap = 400; // 控制url监控间隔, 太快会影响性能, 太慢影响使用, 单位:ms;
const yourName = ''; // 问卷星填写名字
const yourApartment = "/"; // 问卷星填写部门
const yourId = ''; // 问卷星填写员工编号
const yourPost = "专业工程师"; // 问卷星填写岗位
/*
***********************************************************
以下参数为功能必须的参数初始化或功能预留,请勿随意改动
***********************************************************
*/
Qmsg.config({
showClose: true,
timeout: 4000
})
try {
var radioQA = GM_getValue("radioQA");
var multipleQA = GM_getValue("multipleQA");
var judgeQA = GM_getValue("judgeQA");
if (radioQA.length !== 14410 && multipleQA.length !== 6230 && judgeQA.length !== 4056) {
asd;
} else{
Qmsg.success(`正常读取全题库,单选题:${radioQA.length + 1};多选题:${multipleQA.length + 1};判断题:${judgeQA.length + 1}`);
}
} catch (error) {
var radioQA = [...radioQuestionBank1, ...radioQuestionBank2];
radioQA = radioQA.map(item => {
return {
...item,
question: trimText(item.question),
options: item.options.map(option => trimText(option))
};
});
var multipleQA = multipleQuestionBank.map(item => {
return {
...item,
question: trimText(item.question),
options: item.options.map(option => trimText(option))
};
});
var judgeQA = judgeQuestionBank.map(item => {
return {
...item,
question: trimText(item.question),
options: item.options.map(option => trimText(option))
};
});
try {
GM_setValue("radioQA", radioQA);
GM_setValue("multipleQA", multipleQA);
GM_setValue("judgeQA", judgeQA);
Qmsg.success(`全题库共 单选题:${radioQA.length + 1};多选题:${multipleQA.length + 1};判断题:${judgeQA.length + 1} 已存储`);
} catch {
Qmsg.error(`全题库写入失败`);
}
}
GM_setValue('userAgent', window.navigator.userAgent);
try {
var titleMsgAlert = `${GM_getValue('userName')} ${GM_getValue('nickName')}`;
} catch (error) {
titleMsgAlert = "未登录";
}
const targetValues = ["您的姓名:", "您的部门:", "所属项目:", "所在岗位:"];
const rightArr = ["正确", "对", "✓", "√", "A", "a", "是"];
const wrongArr = ["错误", "错", "×", "x", "B", "b", "否"];
const getYears = [2020, 2021, 2022, 2023, 2024];
const filterArray = ['每月考试'];
var clickMyPractice = true;
var isDraggable = false;
var lngAndLatData = '';
var innerMsgAlert = '';
var lastVisionNum = '';
var xAccessToken = '';
var currentUrl = '';
var myPicImage = '';
var timestamp = '';
var ipData = '';
var a = '';
var b = '';
var C = '';
var d = '';
var isQuestionFinishArray = [];
var moneyResults = {};
var practiceData = [];
var savedData = [];
var tokenData = [];
overrideOpen();
setMouseImg();
setTipsImg();
getIP();
hello('遇见八三的心动瞬间', visionNum);
getTrueUsers();
console.log("%c%s",
"color: white; background: black; font-size: 20px; font-weight:1000; text-decoration: none;",
"https://www.yuque.com/yuqueyonghuuadmba/kb/gan09a7zvlktoa9v?singleDoc");
window.onload = function () {
addDiv();
document.querySelector('#noteText2').innerHTML = `版本号: ${visionNum}
`;
getNotes();
changeByClick();
webPageWatchUrl(urlOperate);
getLastVisionNum();
let 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 4:
Qmsg.error("此页面未配置本功能,请使用问卷星答题功能");
break;
case 5:
Qmsg.error("此页面未配置本功能,请使用填写验证码功能");
break;
case 6:
answerQuestion();
break;
default:
Qmsg.error("此页面未配置本功能,如功能配置错误请联系我");
break;
}
} else {
failVerify();
waitToast(titleMsgAlert, innerMsgAlert, a);
}
});
btnClick(".option3", function () {
if (getAb()) {
switch (verifyUrl()) {
case 1:
autoExam();
break;
case 4:
Qmsg.error("此页面未配置本功能,请使用问卷星答题功能");
break;
case 5:
Qmsg.error("此页面未配置本功能,请使用填写验证码功能");
break;
case 6:
autoAnswerQuestion();
break;
case 7:
getAddress(window.location.href);
break;
default:
Qmsg.error("此页面未配置本功能,如功能配置错误请联系我");
break;
}
} else {
failVerify();
waitToast(titleMsgAlert, innerMsgAlert, a);
}
});
btnClick(".option4", answerQAStarExam);
btnClick(".option5", function () {
if (getAb()) {
if (window.location.href.includes("https://learn.cscec83.cn/exam/exam")) {
forceExam();
}
else {
deleteAllCookies();
clearCookie();
clearStorage();
Qmsg.success("cookie数据已清除");
}
} else {
failVerify();
waitToast(titleMsgAlert, innerMsgAlert, a);
}
});
btnClick(".option6", function () {
GM_addStyle(`
.mainDiv {
display: none;
}
#minDiv {
display: Block;
}
`)
let minDiv = document.createElement('div');
minDiv.innerHTML = `
`;
minDiv.style.position = 'fixed';
minDiv.style.left = '0';
minDiv.style.top = '50%';
minDiv.width = '50px';
minDiv.className = "minDiv";
minDiv.style.zIndex = '999';
minDiv.id = 'minDiv';
minDiv.addEventListener('click', function () {
GM_addStyle(`
.mainDiv {
display: grid;
}
#minDiv {
display: none;
}
`)
});
document.body.appendChild(minDiv);
});
btnClick(".option7", fillVerificationCode);
btnClick(".option9", sendMsg);
getWords();
}
function removeDiv(divId) {
let divRemove = document.getElementById(divId);
divRemove.parentNode.removeChild(divRemove);
}
function hello(title, version) {
console.log(
`%c ${title} %cV ${version} `,
'padding: 2px 1px; border-radius: 3px 0 0 3px; color: #fff; background: #606060; font-weight: bold;',
'padding: 2px 1px; border-radius: 0 3px 3px 0; color: #fff; background: #42c02e; font-weight: bold;',
);
}
function getAddress(urls) {
let regex = /lng=([\d.]+)&lat=([\d.]+)&name=([^&]+)/;
let match = urls.match(regex);
if (match) {
let texts = '[{"mAddress":"' + decodeURIComponent(match[3]) + '","mLatitude":' + match[2] + ',"mLongitude":' + match[1] + '}]';
GM.setClipboard(texts, "text");
console.log(texts);
Qmsg.success("已复制相关信息。");
}
}
function forceExam() {
var originalSend = XMLHttpRequest.prototype.send;
XMLHttpRequest.prototype.send = function () {
var self = this;
var originalOnreadystatechange = this.onreadystatechange;
this.onreadystatechange = function () {
if (self.responseURL.match(/getInfoCanPaperNum\?paperId=.+/g)) {
Object.defineProperty(self, 'response', {
value: { "code": 200, "msg": null, "data": 999 },
writable: true,
enumerable: true,
configurable: true
});
Object.defineProperty(self, 'responseText', {
value: "{\"code\":200,\"msg\":null,\"data\":999}",
writable: true,
enumerable: true,
configurable: true
});
// 调用原有的onreadystatechange回调
if (originalOnreadystatechange) {
originalOnreadystatechange.call(self);
}
}
};
// 调用原始的send方法
originalSend.apply(this, arguments);
};
Qmsg.success("强制考试,启动!");
systemAlert('强制考试,启动!', '考!随便考!', 8000, console.log('点击无限的通知'));
}
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("#infoText1").innerText = data.data.content;
document.querySelector("#infoText2").innerText = "——" + data.data.works + ' ' + data.data.author;
} else {
document.querySelector("#infoText1").innerText = "今日无事";
}
})
.catch(error => {
Qmsg.error("获取每日一言失败");
document.querySelector("#infoText1").innerText = "今日无事";
console.error("Fetch error:", error);
});
}
function answerQAStarExam() {
var AllQA = [...radioQA, ...multipleQA, ...judgeQA];
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, AllQA);
for (let i = 0; i < answerArray.length; i++) {
(function (i) {
requestAnimationFrame(function () {
setTimeout(() => {
try {
QAStarQuestion[j].nextElementSibling.childNodes[answerArray[i]].click();
} catch (error) {
try {
QAStarQuestion[j].parentNode.nextSibling.childNodes[answerArray[i]].click();
} catch (error) {
}
}
}, 150);
});
})(i);
}
} else {
console.log(QAStarQuestion[j] + " 未找到答案", "题库无此题,请及时记录维护题库或 Ctrl+S 保存页面");
}
}
} else {
Qmsg.error("此页面未配置本功能,如功能配置错误请联系我");
}
} catch (error) {
Qmsg.error("exam函数未完全适配导致的问题,请 Ctrl+S 保存页面并联系我");
}
}
function verifyUrl() {
currentUrl = window.location.href;
// 1 新版学企来考试
if (currentUrl.includes('https://learn.cscec83.cn/exam/examItem')) {
return 1;
// 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;
// 7 高德定位
} else if (currentUrl.includes("https://www.amap.com/regeo") && currentUrl.includes("lng=") && currentUrl.includes("lat=")) {
return 7;
// 8 八三主页
} else if (currentUrl.includes("https://www.cscec83.cn/dashboard/analysis")) {
return 8;
}
else {
return false;
}
}
function getAnswer(questionAnswerBankIndex, questionsArray) {
return questionsArray[questionAnswerBankIndex].answer;
}
function convertAnswerToArray(questionAnswerBankIndex, questionsArray) {
let answerArray = getAnswer(questionAnswerBankIndex, questionsArray).match(/[A-Za-z]/g).map(function (val) {
return val.toLowerCase();
});
return answerArray;
}
// 转换字母答案为数字并生成数组
function convertAnswerArrayToDigitArray(questionIndex, questionsArray) {
let answerArray = convertAnswerToArray(questionIndex, questionsArray).map(char => char.charCodeAt(0) - 96 - 1); // 多减一个 1 好点击
return answerArray;
}
// 点击页面具有某个文本的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"
if (verifyUrl() === 8) {
root.style.fontSize = 16 + "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;
switch (verifyUrl()) {
case 1:
// removeListener();
break;
case 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) {
Qmsg.error("破解复制失败");
}
break;
case 5:
try {
GM_addStyle(`
.bgi[data-v-556a153e] {
background:url(https://bing.img.run/rand_uhd.php) no-repeat;
background-size:100% 100%;
}
`);
} catch (error) {
}
break;
default:
break;
}
if (currentUrl.includes('https://www.cscec83.cn/dashboard/analysis')) {
document.documentElement.style.fontSize = 16 + "px";
if (cscecAdminCount) {
try {
GM_addStyle(`
.mainDiv {
display: none;
}
#mouseImg {
display: none;
}
`);
} catch (error) { }
}
setInterval(function () {
try {
let content = document.querySelector("#content").childNodes[2];
if (content.style.background !== '') {
document.querySelector("#content").childNodes[2].style.background = '';
Qmsg.success("去除水印成功")
}
} catch (error) { }
}, 2000);
let intervalId; // 存储 setInterval 的返回值
let isClickListenerAdded = false; // 标记是否已添加点击事件监听器
intervalId = setInterval(function () {
if (GM_getValue("thirdToken")) {
var cardTitle = document.querySelector('.card-title');
if (cardTitle) {
try {
if (isClickListenerAdded) {
clearInterval(intervalId);
return;
};
let cardTitle = document.querySelector('.card-title');
cardTitle.addEventListener('click', function () {
let url = 'https://learn.cscec83.cn' + '?token=' + GM_getValue("thirdToken");
window.open(url, '_blank');
});
isClickListenerAdded = true;
} catch (error) {
console.error(error);
}
}
}
}, 500);
// location.reload();
cscecAdminCount = 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 {
Qmsg.error("此页面未配置本功能,如功能配置错误请联系我");
// 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);
}
}
// 给所有的可选按钮增加点击事件
// 类中加 clickable-image speedChoose
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 (method, url) {
var self = this;
this.addEventListener('load', function () {
var data = self.responseText;
var isPracticeData = data.includes('testPaperTopics');
var isTokenData = data.includes('thirdToken');
var isAuthorization = data.includes('token') && data.includes('data');
if (isPracticeData || isTokenData || isAuthorization) {
if (isAuthorization) {
var authorizationData = authorizationData || [];
if (!Array.isArray(authorizationData)) {
authorizationData = [];
}
authorizationData = JSON.parse(data);
handleAuthorizationData(authorizationData);
}
if (isPracticeData) {
practiceData = practiceData || [];
if (!Array.isArray(practiceData)) {
practiceData = [];
}
practiceData.push(JSON.parse(data));
handlePracticeData(practiceData);
}
if (isTokenData) {
tokenData = tokenData || [];
if (!Array.isArray(tokenData)) {
tokenData = [];
}
tokenData.push(JSON.parse(data));
handleTokenData(tokenData);
}
}
});
open.apply(this, arguments);
};
}
function handlePracticeData(practiceData) {
return new Promise(function (resolve) {
let 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 handleAuthorizationData(authorizationData) {
return new Promise(function (resolve) {
if (authorizationData.code === 200) {
fetch("https://learn.cscec83.cn/prod-api/system/user/signIn", {
"headers": {
"accept": "application/json, text/plain, */*",
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
"authorization": authorizationData.data.token,
"cache-control": "no-cache",
"pragma": "no-cache",
},
"method": "POST",
})
.then(response => {
return response.json()
})
.then(data => {
switch (data.code) {
case 200:
Qmsg.success("自动签到完成");
break;
case 500:
console.log("今天已经签到过了");
default:
break;
}
})
.catch(error => {
console.log("自动签到 error" + error);
})
fetch("https://learn.cscec83.cn/prod-api/system/private-point-statistics/study-points", {
"headers": {
"accept": "application/json, text/plain, */*",
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
"authorization": authorizationData.data.token,
"cache-control": "no-cache",
"pragma": "no-cache",
},
"method": "GET",
})
.then(response => {
return response.json()
})
.then(data => {
handelTodayPointsList(data.data.todayPointsList)
})
.catch(error => {
console.log("积分获取情况获得 error" + error);
})
} else {
console.log('脚本未找到符合条件的 authorization token');
}
authorizationData.length = 0;
resolve();
});
}
function handelTodayPointsList(todayPointsList) {
let arr = todayPointsList.filter(function (topic) {
return !filterArray.includes(topic.pointSource);
});
let isFinishInfoHtml = '';
arr.forEach(function (topic) {
topic.maxPoints === topic.currentPoints ? isFinishInfoHtml = `${isFinishInfoHtml}