TA的每日心情 | 无聊 2023-3-6 22:02 |
---|
签到天数: 1 天 [LV.1]初来乍到
助理工程师
- 积分
- 3
|
发表于
2023-3-6 22:06:09
|
显示全部楼层
// ==UserScript==
// @name 涓嶅涔犱綍浠ュ己鍥?beta
// @namespace http://tampermonkey.net/
// @version 20220214
// @description 闂鍙嶉浣嶇疆锛?https://github.com/TechXueXi/techxuexi-js/issues 銆傝鏂囩珷,鐪嬭棰戯紝鍋氫範棰樸€?// @author techxuexi 锛岃嵎鍖呰泲銆?// @match https://www.xuexi.cn
// @match https://www.xuexi.cn/*
// @match https://pc.xuexi.cn/points/login.html*
// @match https://pc.xuexi.cn/points/exam-practice.html
// @match https://pc.xuexi.cn/points/exam-weekly-detail.html?id=*
// @match https://pc.xuexi.cn/points/exam-weekly-list.html
// @match https://pc.xuexi.cn/points/exam-paper-detail.html?id=*
// @match https://pc.xuexi.cn/points/exam-paper-list.html
// @require https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.5.1.min.js
// @require https://cdn.jsdelivr.net/npm/blueimp-md5@2.9.0
// @grant GM_addStyle
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_deleteValue
// @grant GM_openInTab
// ==/UserScript==
var study_css = ".egg_study_btn{outline:0;border:0;position:fixed;top:5px;left:5px;padding:12px 20px;border-radius:10px;cursor:pointer;background-color:#fff;color:#d90609;font-size:18px;font-weight:bold;text-align:center;box-shadow:0 0 9px #666777}.egg_manual_btn{transition:0.5s;outline:none;border:none;padding:12px 20px;border-radius:10px;cursor:pointer;background-color:#e3484b;color:rgb(255,255,255);font-size:18px;font-weight:bold;text-align:center;}.egg_auto_btn{transition:0.5s;outline:none;border:none;padding:12px 20px;border-radius:10px;cursor:pointer;background-color:#666777;color:rgb(255,255,255);font-size:18px;font-weight:bold;text-align:center;}.egg_setting_box{position:fixed;top:70px;left:5px;padding:12px 20px;border-radius:10px;background-color:#fff;box-shadow:0 0 9px #666777}.egg_setting_item{margin-top:5px;height:30px;width:140px;font-size:16px;display:flex;justify-items:center;justify-content:space-between}input[type='checkbox'].egg_setting_switch{cursor:pointer;margin:0;outline:0;appearance:none;-webkit-appearance:none;-moz-appearance:none;position:relative;width:40px;height:22px;background:#ccc;border-radius:50px;transition:border-color .3s,background-color .3s}input[type='checkbox'].egg_setting_switch::after{content:'';display:inline-block;width:1rem;height:1rem;border-radius:50%;background:#fff;box-shadow:0,0,2px,#999;transition:.4s;top:3px;position:absolute;left:3px}input[type='checkbox'].egg_setting_switch:checked{background:#fd5052}input[type='checkbox'].egg_setting_switch:checked::after{content:'';position:absolute;left:55%;top:3px}";
GM_addStyle(study_css);
//https://www.xuexi.cn/lgdata/3uoe1tg20en0.json
//鏌ヨ浠婃棩瀹屾垚鎯呭喌
const SearchSocreUrl = "https://pc-proxy-api.xuexi.cn/api/score/days/listScoreProgress?sence=score&deviceType=2";
//閲嶈鏂伴椈鍒楄〃锛堜富锛?const NewsUrl1 = "https://www.xuexi.cn/lgdata/1jscb6pu1n2.json";
//瀛︿範鏃惰瘎鏂伴椈鍒楄〃
const NewsUrl2 = "https://www.xuexi.cn/lgdata/1ap1igfgdn2.json";
//鏂伴椈瑙嗛鍒楄〃
const VideosUrl1 = "https://www.xuexi.cn/lgdata/3o3ufqgl8rsn.json";
//鏂伴椈瑙嗛鍒楄〃
const VideosUrl2 = "https://www.xuexi.cn/lgdata/1742g60067k.json";
//姣忔棩绛旈椤甸潰
const ExamPracticeUrl = "https://pc.xuexi.cn/points/exam-practice.html";
//姣忓懆绛旈鍒楄〃API
const ExamWeeklyListUrl = "https://pc-proxy-api.xuexi.cn/api/exam/service/practice/pc/weekly/more?pageNo={pageNo}&pageSize=50";
//涓撻」绛旈鍒楄〃API
const ExamPaperListUrl = "https://pc-proxy-api.xuexi.cn/api/exam/service/paper/pc/list?pageSize=50&pageNo={pageNo}";
//棰樼洰API锛堝彧鏈夋瘡鍛ㄧ瓟棰樺拰涓撻」缁冧範锛?//const ExamQueryUrl = "https://pc-proxy-api.xuexi.cn/api/exam/service/detail/queryV3?type={type}&id={id}&forced=true";//type=1涓撻」缁冧範锛宼ype=2姣忓懆绛旈
//姣忓懆绛旈椤甸潰
const ExamWeeklyUrl = "https://pc.xuexi.cn/points/exam-weekly-detail.html?id={id}";
//涓撻」娴嬭瘯椤甸潰
const ExamPaperUrl = "https://pc.xuexi.cn/points/exam-paper-detail.html?id={id}";
//鏂囨湰鏈嶅姟鍣ㄤ繚瀛楢PI
const AnswerSaveUrl = "https://a6.qikekeji.com/txt/data/save/";
//鏂囨湰鏈嶅姟鍣ㄨ幏鍙朅PI
const AnswerDetailUrl = "https://a6.qikekeji.com/txt/data/detail/";
//鑾峰彇褰撳墠鏃ユ湡
var currDate = new Date().toISOString().split('T')[0];
var newsNum = 6;
var news = [];
var videoNum = 6;
var videos = [];
//閰嶇疆
var settings = {};
var settingsDefault = {
News: true, //0
Video: true,//1
ExamPractice: true, //6 姣忔棩绛旈
ExamWeekly: true,//2 姣忓懆绛旈
ExamPaper: true,//5 涓撻」缁冧範
ShowMenu: false, //7 闅愯棌鑿滃崟
AutoStart: false, //鏄惁鍔犺浇鑴氭湰鍚庤嚜鍔ㄦ挱鏀?}
var pause = false;//鏄惁鏆傚仠绛旈
//姣忓懆绛旈褰撳墠椤电爜
var examWeeklyPageNo = 1;
//姣忓懆绛旈鎬婚〉鐮?var examWeeklyTotalPageCount = null;
//姣忓懆绛旈寮€鍚€嗗簭绛旈: false: 椤哄簭绛旈; true: 閫嗗簭绛旈
var examWeeklyReverse = false;
//涓撻」绛旈褰撳墠椤电爜
var examPaperPageNo = 1;
//涓撻」绛旈鎬婚〉鐮?var examPaperTotalPageCount = null;
//涓撻」绛旈寮€鍚€嗗簭绛旈: false: 椤哄簭绛旈; true: 閫嗗簭绛旈
var examPaperReverse = false;
//姣忓懆绛旈锛屼笓椤圭瓟棰?璇锋眰rate 闄愬埗 姣?3000ms 涓€娆?const ratelimitms = 3000;
//榛樿鎯呭喌涓? chrome 鍙厑璁?window.close 鍏抽棴 window.open 鎵撳紑鐨勭獥鍙?鎵€浠ユ垜浠氨瑕佺敤window.open鍛戒护,鍦ㄥ師鍦扮綉椤垫墦寮€鑷韩绐楀彛鍐嶅叧涓?灏卞彲浠ユ垚鍔熷叧闂簡
function closeWin() {
try {
window.opener = window;
var win = window.open("", "_self");
win.close();
top.close();
} catch (e) {
}
}
async function sleep( timeMS ) {
return new Promise( res => setTimeout( res, time ) );
}
/** 妯℃嫙榧犳爣绉诲姩 鏀规柟娉曟潵鑷猦ttps://blog.csdn.net/Wuzihui___/article/details/79952068
* @param id
* @param clientX 鐩稿绐楀彛妯潗鏍? * @param clientY 鐩稿绐楀彛绾靛潗鏍? * @param distance 婊戝姩璺濈
*/
function dragandDrop(btn_hk, clientX, clientY, distance) {
var elem = btn_hk,
k = 0,
interval;
iME(elem,"mousedown",0, 0, clientX, clientY);
let waitTime = Math.floor(Math.random() * (0.005 * 1000 - 0.09 * 1000) + 0.09 * 1000)
interval = setInterval(function() {
k++;
iter(k);
if (k === distance) {
clearInterval(interval);
iME(elem, "mouseup", clientX + k, clientY, 220 + k, 400);
}
}, waitTime);
function iter(y) {
iME(elem, "mousemove", clientX + y, clientY, clientX + y, clientY);
}
function iME(obj, event, screenXArg, screenYArg, clientXArg, clientYArg) {
var mousemove = document.createEvent("MouseEvent");
mousemove.initMouseEvent(event, true, true, unsafeWindow, 0, screenXArg, screenYArg, clientXArg, clientYArg, 0, 0, 0, 0, 0, null);
obj.dispatchEvent(mousemove);
}
}
/**
* 闅忔満绛夊緟鏈€灏忓埌鏈€澶т箣闂村嚑绉? 闇€瑕乤wait
* @param {number} minSecond 鏈€鐭椂闀? * @param {number} MaxSecond 鏈€闀挎椂闀? * @returns Promise
*/
function waitRandomBetween(minSecond = 2, MaxSecond = 5) {
if (MaxSecond <= minSecond) {
MaxSecond = minSecond + 3
}
let waitTime = Math.floor(Math.random() * (MaxSecond * 1000 - minSecond * 1000) + minSecond * 1000)
return new Promise((resolve, reject) => {
setTimeout(() => {
console.log(`闅忔満绛夊緟${waitTime / 1000}绉抈)
resolve()
}, waitTime)
})
}
$(document).ready(function () {
let url = window.location.href;
if (url == "https://www.xuexi.cn" || url == "https://www.xuexi.cn/" || url == "https://www.xuexi.cn/index.html") {
let ready = setInterval(function () {
if (document.getElementsByClassName("text-wrap")[0]) {
clearInterval(ready);//鍋滄瀹氭椂鍣? //鍒濆鍖栬缃? initSetting();
//鍒涘缓"寮€濮嬪涔?鎸夐挳
createStartButton();
}
}, 800);
} else if (url.indexOf("login.html") !== -1) {
console.log("妫€娴嬪埌鐧诲綍椤?)
setTimeout(() => {
window.scrollTo(0, 1000);
}, 500);
}
else if (typeof GM_getValue("readingUrl") != 'object' && url == GM_getValue("readingUrl")) {
try {
let settingTemp = JSON.parse(GM_getValue('studySetting'));
if (!settingTemp[7]) {
createTip();//鍒涘缓瀛︿範鎻愮ず
}
reading(0);
} catch (e) {
createTip();//鍒涘缓瀛︿範鎻愮ず
reading(0);
}
} else if (typeof GM_getValue("watchingUrl") != 'object' && url == GM_getValue("watchingUrl")) {
try {
let settingTemp = JSON.parse(GM_getValue('studySetting'));
if (!settingTemp[7]) {
createTip();//鍒涘缓瀛︿範鎻愮ず
}
} catch (e) {
createTip();//鍒涘缓瀛︿範鎻愮ず
}
let randNum = 0;
var checkVideoPlayingInterval = setInterval(function () {
let temp = getVideoTag();
if (temp.video) {
if (!temp.video.muted) {
temp.video.muted = true;
}
if (temp.video.paused) {
temp.video.paused = false;
console.log("姝e湪灏濊瘯鎾斁瑙嗛")
if (randNum == 0) {//灏濊瘯浣跨敤js鐨勬柟寮忔挱鏀? try {
temp.video.play();//灏濊瘯浣跨敤js鐨勬柟寮忔挱鏀? } catch (e) { }
randNum++;
} else {
try {
temp.pauseButton.click();//灏濊瘯鐐瑰嚮鎾斁鎸夐挳鎾斁
} catch (e) { }
randNum--;
}
} else {
console.log("鎴愬姛鎾斁")
clearInterval(checkVideoPlayingInterval);
reading(1);
}
} else {
console.log("绛夊緟鍔犺浇")
}
}, 800);
} else if (url.indexOf("exam") != -1 && url.indexOf("list") == -1) {
//绛旈椤甸潰
let ready = setInterval(function () {
if (document.getElementsByClassName("title")[0]) {
clearInterval(ready);//鍋滄瀹氭椂鍣? //鍒涘缓鈥滄墜鍔ㄧ瓟棰樷€濇寜閽? createManualButton();
//鍘婚櫎绛旈楠岃瘉
//cancelVerify();
//寮€濮嬬瓟棰? doingExam();
}
}, 500);
} else {
}
});
//鑾峰彇video鏍囩
function getVideoTag() {
let iframe = document.getElementsByTagName("iframe")[0];
let video = null;
let pauseButton = null;
var u = navigator.userAgent;
// 瑙嗛鎾斁鎸夐挳鏇存柊
video = document.getElementsByTagName("video")[0];
pauseButton = document.getElementsByClassName("prism-big-play-btn")[0];
return {
"video": video,
"pauseButton": pauseButton
}
// if (u.indexOf('Mac') > -1) {//Mac
// if (iframe != null && iframe.innerHTML) {
// //濡傛灉鏈塱frame,璇存槑澶栭潰鐨剉ideo鏍囩鏄亣鐨? // video = iframe.contentWindow.document.getElementsByTagName("video")[0];
// pauseButton = iframe.contentWindow.document.getElementsByClassName("prism-play-btn")[0];
// } else {
// //鍚﹀垯杩欎釜video鏍囩鏄湡鐨? // video = document.getElementsByTagName("video")[0];
// pauseButton = document.getElementsByClassName("prism-play-btn")[0];
// }
// return {
// "video": video,
// "pauseButton": pauseButton
// }
// }
// else {
// if (iframe) {
// //濡傛灉鏈塱frame,璇存槑澶栭潰鐨剉ideo鏍囩鏄亣鐨? // video = iframe.contentWindow.document.getElementsByTagName("video")[0];
// pauseButton = iframe.contentWindow.document.getElementsByClassName("prism-play-btn")[0];
// } else {
// //鍚﹀垯杩欎釜video鏍囩鏄湡鐨? // video = document.getElementsByTagName("video")[0];
// pauseButton = document.getElementsByClassName("prism-play-btn")[0];
// }
// return {
// "video": video,
// "pauseButton": pauseButton
// }
// }
}
//璇绘柊闂绘垨鑰呯湅瑙嗛
//type:0涓烘柊闂伙紝1涓鸿棰?async function reading(type) {
//鐪嬫枃绔犳垨鑰呰棰? var time = 1;
if (type == 0) {
time = parseInt(Math.random() * (100 - 80 + 1) + 80, 10);//80-100绉掑悗鍏抽棴椤甸潰锛岀湅鏂囩珷
} else {
time = parseInt(Math.random() * (250 - 230 + 1) + 230, 10);//230-250绉掑悗鍏抽棴椤甸潰锛岀湅瑙嗛
}
let firstTime = time - 2;
let secendTime = 12;
let scrollLength = document.body.scrollHeight / 2;
var readingInterval = setInterval(function () {
time--;
$("#studyTip").text(time + " 绉掑悗鍏抽棴椤甸潰");
if (time <= firstTime) {
try {
$("html,body").animate({ scrollTop: 394 }, 1000);
} catch (e) {
window.scrollTo(0, 394);
}
firstTime = -1;
}
if (time <= secendTime) {
try {
$("html,body").animate({ scrollTop: scrollLength / 3 }, 1000);
} catch (e) {
window.scrollTo(0, scrollLength / 3);
}
secendTime = -1;
}
if (time <= 0) {
if (type == 0) {
GM_setValue('readingUrl', null);
} else {
GM_setValue('watchingUrl', null);
}
clearInterval(readingInterval);
closeWin();
}
}, 1000);
//鍏抽棴鏂囩珷鎴栬棰戦〉闈?}
//鍒涘缓瀛︿範鎻愮ず
function createTip() {
let tipInfo = document.createElement("div");
//娣诲姞鏍峰紡
tipInfo.setAttribute("id", "studyTip");
tipInfo.innerText = "姝e湪鍒濆鍖?...";
tipInfo.style.position = "fixed";
tipInfo.style.bottom = "15px";
tipInfo.style.left = "5px";
tipInfo.style.padding = "12px 14px";
tipInfo.style.border = "none";
tipInfo.style.borderRadius = "10px";
tipInfo.style.backgroundColor = "#222222";
tipInfo.style.color = "#ffffff";
tipInfo.style.fontSize = "14px";
tipInfo.style.fontWeight = "bold";
//鎻掑叆鑺傜偣
let body = document.getElementsByTagName("body")[0];
body.append(tipInfo)
}
//绛夊緟绐楀彛鍏抽棴
function waitingClose(newPage) {
return new Promise(resolve => {
let doing = setInterval(function () {
if (newPage.closed) {
clearInterval(doing);//鍋滄瀹氭椂鍣? resolve('done');
}
}, 1000);
});
}
//闃呰鏂囩珷
async function readNews() {
await getNews();
for (let i = 0; i < news.length; i++) {
GM_setValue('readingUrl', news.url);
console.log("姝e湪鐪嬬" + (i + 1) + "涓柊闂?);
let newPage = GM_openInTab(news.url, { active: true, insert: true, setParent: true });
await waitingClose(newPage);
await waitRandomBetween(1, 3);
}
}
//鑾峰彇鏂伴椈鍒楄〃
function getNews() {
return new Promise(resolve => {
news = new Array();
let n = 6;
if (newsNum < 6) {//濡傛灉闇€瑕佸涔犵殑鏂伴椈鏁伴噺涓嶅埌6锛屼篃灏辨槸宸茬粡瀛﹁繃浜嗭紝浣嗘槸绉垎涓嶅锛岃ˉ鐨? n = newsNum;
}
console.log("杩橀渶瑕佺湅" + n + "涓柊闂?)
//鏂伴椈鏁伴噺鏄惁瓒冲
let enough = true;
//鑾峰彇閲嶈鏂伴椈
$.ajax({
type: "GET",
url: NewsUrl1,
dataType: "json",
success: function (data) {
let j = 0;
if (n == 6) {//濡傛灉浠婂ぉ杩樻病瀛﹁繃锛屽垯浼樺厛鎵句粖澶╃殑鏂伴椈
for (let i = 0; i < n; i++) {
//濡傛灉鏈夊綋澶╂棩鏈熺殑,鍒欏姞鍏? if (data[j].auditTime.indexOf(currDate) != -1) {
news.push(data[j]);
j++;
} else {//鍚﹀垯璺冲嚭寰幆
break;
}
}
}
for (j; j < n; j++) {
let temp = parseInt(Math.random() * (data.length + 1), 10);
news.push(data[temp]);
}
resolve('done');
},
error: function () {
news = null;
resolve('done');
}
});
});
}
//鑾峰彇瑙嗛鍒楄〃
function getVideos() {
return new Promise(resolve => {
videos = new Array();
let n = 6;
if (videoNum < 6) {//濡傛灉闇€瑕佸涔犵殑瑙嗛鏁伴噺涓嶅埌6锛屼篃灏辨槸宸茬粡瀛﹁繃浜嗭紝浣嗘槸绉垎涓嶅锛岃ˉ鐨? n = videoNum;
}
console.log("杩橀渶瑕佺湅" + n + "涓棰?)
$.ajax({
type: "GET",
url: VideosUrl1,
dataType: "json",
success: function (data) {
let j = 0;
if (n == 6) {
for (let i = 0; i < n; i++) {
//濡傛灉鏈夊綋澶╂棩鏈熺殑,鍒欏姞鍏? if (data[j].auditTime.indexOf(currDate) != -1) {
videos.push(data[j]);
j++;
} else {//鍚﹀垯璺冲嚭寰幆
break;
}
}
}
for (j; j < n; j++) {
let temp = parseInt(Math.random() * (data.length + 1), 10);
videos.push(data[temp]);
}
resolve('done');
},
error: function () {
videos = [];
resolve('done');
}
});
});
}
//鐪嬪涔犺棰?async function watchVideo() {
await getVideos();
for (let i = 0; i < videos.length; i++) {
GM_setValue('watchingUrl', videos.url);
console.log("姝e湪瑙傜湅绗? + (i + 1) + "涓棰?);
let newPage = GM_openInTab(videos.url, { active: true, insert: true, setParent: true })
await waitingClose(newPage);
await waitRandomBetween(1, 3);
}
}
//鍋氭瘡鏃ョ瓟棰?function doExamPractice() {
return new Promise(resolve => {
console.log("姝e湪瀹屾垚姣忔棩绛旈")
let newPage = GM_openInTab(ExamPracticeUrl, { active: true, insert: true, setParent: true });
let doing = setInterval(function () {
if (newPage.closed) {
clearInterval(doing);//鍋滄瀹氭椂鍣? resolve('done');
}
}, 1000);
});
}
//fix code = 429
async function waitingDependStartTime(startTime) {
let remainms = Date.now() - startTime;
if (remainms < ratelimitms) {
let second = (ratelimitms - remainms) / 1000
await waitRandomBetween(second + 1, second + 3)
}
}
//鍒濆鍖栦笓椤圭瓟棰樻€婚〉鏁板睘鎬?async function InitExamPaperAttr() {
let startTime = Date.now();
var data = await getExamPaperByPageNo(1); // 榛樿浠庣涓€椤佃幏鍙栧叏閮ㄩ〉灞炴€? if (data) {
// 鍒濆鍖栨€婚〉鐮? examPaperTotalPageCount = data.totalPageCount;
// 鑻ヤ笓椤圭瓟棰橀€嗗簭, 鍒欎粠鏈€鍚庝竴椤靛紑濮? if (examPaperReverse) {
examPaperPageNo = examPaperTotalPageCount;
}
}
await waitingDependStartTime(startTime);
}
//鑾峰彇鎸囧畾椤垫暟鐨勪笓椤圭瓟棰樺垪琛?function getExamPaperByPageNo(examPaperPageNoParam) {
return new Promise(function (resolve) {
$.ajax({
type: "GET",
url: ExamPaperListUrl.replace("{pageNo}", examPaperPageNoParam),
xhrFields: {
withCredentials: true //濡傛灉娌℃湁杩欎釜璇锋眰澶辫触
},
dataType: "json",
success: function (data) {
data = decodeURIComponent(escape(window.atob(data.data_str.replace(/-/g, "+").replace(/_/g, "/"))));
//JSON鏍煎紡鍖? data = JSON.parse(data);
resolve(data);
},
error: function () {
resolve(new Array());
}
});
})
}
//鏌ヨ涓撻」绛旈鍒楄〃鐪嬬湅杩樻湁娌℃湁娌″仛杩囩殑锛屾湁鍒欒繑鍥瀒d
async function findExamPaper() {
var continueFind = true;
var examPaperId = null;
console.log("鍒濆鍖栦笓椤圭瓟棰樺睘鎬?);
await InitExamPaperAttr();
console.log("姝e湪瀵绘壘鏈畬鎴愮殑涓撻」绛旈");
while (continueFind) {
let startTime = Date.now();
await getExamPaperByPageNo(examPaperPageNo).then(async (data) => {
if (data) {
let examPapers = data.list;//鑾峰彇涓撻」绛旈鐨勫垪琛? if (examPaperReverse) {
// 鑻ュ紑鍚€嗗簭绛旈, 鍒欏弽杞笓椤圭瓟棰樺垪琛? console.log("涓撻」绛旈,寮€鍚€嗗簭妯″紡,浠庢渶鏃╃殑棰樼洰寮€濮嬬瓟棰?);
examPapers.reverse();
}
for (let j = 0; j < examPapers.length; j++) {
//閬嶅巻鏌ヨ鏈夋病鏈夋病鍋氳繃鐨? if (examPapers[j].status != 2) {//status锛?1涓?寮€濮嬬瓟棰? , 2涓?閲嶆柊绛旈"
//濡傛灉涓嶆槸"閲嶆柊绛旈"锛屽垯鍙互鍋? examPaperId = examPapers[j].id;
continueFind = false;
break;
}
}
if (!continueFind) {
} else {
//澧炲姞椤电爜 (鑻ュ紑鍚€嗗簭缈婚〉, 鍒欏噺灏戦〉鐮?
examPaperPageNo += examPaperReverse ? -1 : 1;
if (examPaperTotalPageCount == null
|| examPaperPageNo > examPaperTotalPageCount
|| examPaperPageNo < 1) {
//宸茬粡鎵惧畬鎵€鏈夐〉鐮侊紝杩樻槸娌℃壘鍒帮紝涓嶅啀缁х画鏌ユ壘
continueFind = false;
}
}
} else {
continueFind = false;
}
//fix code = 429
await waitingDependStartTime(startTime);
})
}
return examPaperId;
}
//鍋氫笓椤圭瓟棰?function doExamPaper() {
return new Promise(function (resolve) {
//鏌ユ壘鏈夋病鏈夋病鍋氳繃鐨勪笓椤圭瓟棰橈紝鏈夊垯杩斿洖ID
findExamPaper().then(examPaperId => {
if (examPaperId != null) {
console.log("姝e湪鍋氫笓椤圭瓟棰?)
let newPage = GM_openInTab(ExamPaperUrl.replace("{id}", examPaperId), { active: true, insert: true, setParent: true });
let doing = setInterval(function () {
if (newPage.closed) {
clearInterval(doing);//鍋滄瀹氭椂鍣? resolve('done');
}
}, 1000);
} else {
console.log("娌℃湁鎵惧埌鏈畬鎴愮殑涓撻」绛旈锛岃烦杩?)
resolve('noTest');
}
});
})
}
//鍒濆鍖栨瘡鍛ㄧ瓟棰樻€婚〉鏁板睘鎬?async function InitExamWeeklyAttr() {
let startTime = Date.now();
var data = await getExamWeeklyByPageNo(1); // 榛樿浠庣涓€椤佃幏鍙栧叏閮ㄩ〉灞炴€? if (data) {
// 鍒濆鍖栨€婚〉鐮? examWeeklyTotalPageCount = data.totalPageCount;
// 鑻ユ瘡鍛ㄧ瓟棰橀€嗗簭, 鍒欎粠鏈€鍚庝竴椤靛紑濮? if (examWeeklyReverse) {
examWeeklyPageNo = examWeeklyTotalPageCount;
}
}
await waitingDependStartTime(startTime);
}
//鑾峰彇鎸囧畾椤垫暟鐨勬瘡鍛ㄧ瓟棰樺垪琛?function getExamWeeklyByPageNo(examWeeklyPageNoParam) {
return new Promise(function (resolve) {
$.ajax({
type: "GET",
url: ExamWeeklyListUrl.replace("{pageNo}", examWeeklyPageNoParam),
xhrFields: {
withCredentials: true //濡傛灉娌℃湁杩欎釜璇锋眰澶辫触
},
dataType: "json",
success: function (data) {
data = decodeURIComponent(escape(window.atob(data.data_str.replace(/-/g, "+").replace(/_/g, "/"))));
//JSON鏍煎紡鍖? data = JSON.parse(data);
resolve(data);
},
error: function () {
resolve(new Array());
}
});
})
}
//鏌ヨ姣忓懆绛旈鍒楄〃鐪嬬湅杩樻湁娌℃湁娌″仛杩囩殑锛屾湁鍒欒繑鍥瀒d
async function findExamWeekly() {
var continueFind = true;
var examWeeklyId = null;
console.log("鍒濆鍖栨瘡鍛ㄧ瓟棰?);
await InitExamWeeklyAttr();
console.log("姝e湪瀵绘壘鏈畬鎴愮殑姣忓懆绛旈");
while (continueFind) {
let startTime = Date.now();
await getExamWeeklyByPageNo(examWeeklyPageNo).then(async (data) => {
if (data) {
if (examWeeklyReverse) {
// 鑻ュ紑鍚€嗗簭绛旈, 鍒欏弽杞垪琛? console.log("姣忓懆绛旈,寮€鍚€嗗簭妯″紡,浠庢渶鏃╃殑棰樼洰寮€濮嬬瓟棰?);
data.list.reverse();
}
for (let i = 0; i < data.list.length; i++) {
let examWeeks = data.list.practices;//鑾峰彇姣忓懆鐨勬祴璇曞垪琛? if (examWeeklyReverse) {
// 鑻ュ紑鍚€嗗簭, 鍒欏弽杞瘡鍛ㄧ殑娴嬭瘯鍒楄〃
examWeeks.reverse();
}
for (let j = 0; j < examWeeks.length; j++) {
//閬嶅巻鏌ヨ鏈夋病鏈夋病鍋氳繃鐨? if (examWeeks[j].status != 2) {//status锛?1涓?寮€濮嬬瓟棰? , 2涓?閲嶆柊绛旈"
//濡傛灉涓嶆槸"閲嶆柊绛旈"锛屽垯鍙互鍋? examWeeklyId = examWeeks[j].id;
continueFind = false;
break;
}
}
if (!continueFind) {
//濡傛灉宸茬粡鎵惧埌浜嗭紝鍒欓€€鍑哄惊鐜? break;
}
}
if (!continueFind) {
} else {
//澧炲姞椤电爜
examWeeklyPageNo += examWeeklyReverse ? -1 : 1;
if (examWeeklyTotalPageCount == null
|| examWeeklyPageNo > examWeeklyTotalPageCount
|| examWeeklyPageNo < 1) {
//宸茬粡鎵惧畬鎵€鏈夐〉鐮侊紝杩樻槸娌℃壘鍒帮紝涓嶅啀缁х画鏌ユ壘
continueFind = false;
}
}
} else {
continueFind = false;
}
//fix code = 429
await waitingDependStartTime(startTime);
})
}
return examWeeklyId;
}
//鍋氭瘡鍛ㄧ瓟棰?function doExamWeekly() {
return new Promise(function (resolve) {
//鏌ユ壘鏈夋病鏈夋病鍋氳繃鐨勬瘡鍛ㄦ祴璇曪紝鏈夊垯杩斿洖ID
//examWeeklyId = 147;//娴嬭瘯棰樼洰
findExamWeekly().then(examWeeklyId => {
if (examWeeklyId != null) {
console.log("姝e湪鍋氭瘡鍛ㄧ瓟棰?)
let newPage = GM_openInTab(ExamWeeklyUrl.replace("{id}", examWeeklyId), { active: true, insert: true, setParent: true });
let doing = setInterval(function () {
if (newPage.closed) {
clearInterval(doing);//鍋滄瀹氭椂鍣? resolve('done');
}
}, 1000);
} else {
console.log("娌℃湁鎵惧埌鏈畬鎴愮殑姣忓懆绛旈锛岃烦杩?)
resolve('noTest');
}
});
})
}
//鑾峰彇绛旈鎸夐挳
function getNextButton() {
return new Promise(function (resolve) {
let nextInterVal = setInterval(() => {
let nextAll = document.querySelectorAll(".ant-btn");
let next = nextAll[0];
if (nextAll.length == 2) {
next = nextAll[1];
}
if (next.textContent) {
clearInterval(nextInterVal);//鍋滄瀹氭椂鍣? resolve(next);
}
}, 800);
})
}
//鏆傚仠閿?function doingPause() {
return new Promise(function (resolve) {
let doing = setInterval(function () {
if (!pause) {
clearInterval(doing);//鍋滄瀹氭椂鍣? resolve('done');
}
console.log("绛夊緟")
}, 500);
})
}
//绛旈杩囩▼(鏁村悎)
async function doingExam() {
let nextButton = null;
let qNum = 0;//棰樺彿,绗竴棰樹粠0寮€濮嬬畻
let shouldSaveAnswer = false;
while (true) {
//鍏堢瓑绛夊啀寮€濮嬪仛棰? await waitRandomBetween(2, 5);
await doingPause();
nextButton = await getNextButton();
if (document.getElementsByClassName('nc_iconfont btn_slide')[0] != null) {
dragandDrop(document.getElementsByClassName('nc_iconfont btn_slide')[0], 0, 0, 300);
}
if (nextButton.textContent == "鍐嶇粌涓€娆? || nextButton.textContent == "鍐嶆潵涓€缁? || nextButton.textContent == "鏌ョ湅瑙f瀽") {
break;
}
try {
document.querySelector(".tips").click();
} catch (e) {
console.log(e);
}
//鎵€鏈夋彁绀? var allTips = document.querySelectorAll("font");
await waitRandomBetween(2, 3);
//閫夐」鎸夐挳
var allbuttons = document.querySelectorAll(".q-answer");
//鑾峰彇鎵€鏈夊~绌? var blanks = document.querySelectorAll("input[type=text][class=blank]");
try {
//鑾峰彇闂绫诲瀷
var questionType = document.querySelector(".q-header").textContent;
questionType = questionType.substr(0, 3)
} catch (e) {
}
var results = [];
switch (questionType) {
case "濉┖棰?: {
//绗嚑涓~绌? var inputBubblesEvent = new Event('input', { bubbles: true });
if (blanks.length > 1) {//濡傛灉鏈夊涓~绌? if (allTips.length == 0) {//濡傛灉娌℃湁鎻愮ず锛屽厛鑾峰彇鐪嬬湅鏈夋病鏈夌瓟妗? try {//灏濊瘯鐐瑰嚮瑙嗛鎾斁鎸夐挳,鎾笉鎾兘娌″叧绯? document.getElementsByClassName("outter")[0].click();
} catch (e) { }
//鐢熸垚绉橀挜
let key = getKey();
//灏濊瘯鑾峰彇绛旀
let answerData = await getAnswer(key);
if (answerData.status == 0 || answerData == "error") {//娌℃湁绛旀
for (let i = 0; i < blanks.length; i++) {//娌$瓟妗堬紝闅忎究濉偣涓滆タ
blanks.setAttribute("value", i);
//蹇呴』瑕侀樆姝簨浠讹紝涓嶇劧鏃犳晥
blanks.dispatchEvent(inputBubblesEvent);
}
shouldSaveAnswer = true;//绛斿畬淇濆瓨绛旀
} else {//鑾峰彇鍒颁簡绛旀
//鏍煎紡鍖? answerData = JSON.parse(answerData.data.txt_content);
answerData = answerData[0].content;
//鍥犱负鏈夊涓┖锛屾墍浠ユ湁澶氫釜绛旀锛屽厛鍒囧壊
answerData = answerData.split(";");
for (let i = 0; i < answerData.length; i++) {//灏嗙瓟妗堝~鍏? blanks.setAttribute("value", answerData);
blanks.dispatchEvent(inputBubblesEvent);
}
}
} else if (allTips.length == blanks.length) {
//濡傛灉濉┖鏁伴噺鍜屾彁绀烘暟閲忎竴鑷? for (let i = 0; i < allTips.length; i++) {
//灏嗙瓟妗堝~鍐欏埌瀵瑰簲鐨勭┖涓? let answer = allTips.textContent;
if (answer && answer.length > 0) {
blanks.setAttribute("value", answer);
blanks.dispatchEvent(inputBubblesEvent);
} else {
//鍙戠敓浜嗛敊璇紝鍙ソ闅忎究濉竴涓? blanks.setAttribute("value", i);
blanks.dispatchEvent(inputBubblesEvent);
}
}
} else if (allTips.length > blanks.length) {
//鑻ユ彁绀烘暟閲忔瘮濉┖鐨勬暟閲忓
//鐩存帴灏嗘墍鏈夌瓟妗堟暣鍚堝~杩涘幓
let answer = "";
for (let i = 0; i < allTips.length; allTips++) {
answer += allTips.textContent();
}
for (let j = 0; j < blanks.length; j++) {
blanks[j].setAttribute("value", answer);
blanks[j].dispatchEvent(inputBubblesEvent);
}
} else {
//涓€鑸笉浼氳窇鍒拌繖锛屽鏋滃埌杩欎簡杈撳嚭涓€涓嬶紝琛ㄧず鎯婅
console.log("灞呯劧璺戝埌浜嗚繖閲?)
}
} else if (blanks.length == 1) {//鍙湁涓€涓┖锛岀洿鎺ユ妸鎵€鏈塼ips鍚堝苟銆? let answer = "";
if (allTips.length != 0) {//濡傛灉鏈夋彁绀? for (let i = 0; i < allTips.length; i++) {
answer += allTips.textContent;
}
} else {
try {//灏濊瘯鐐瑰嚮瑙嗛鎾斁鎸夐挳,涓嶈繃鎾笉鎾兘娌″叧绯? document.querySelector('video').play();
} catch (e) { }
let key = getKey();
let answerData = await getAnswer(key);
if (answerData.status == 0 || answerData == "error") {
//娌℃湁鑾峰彇鍒扮瓟妗? answer = "涓嶇煡閬?;
//娌℃湁鍏朵粬浜哄仛杩囪繖閬撹棰戦锛屾墍浠ラ渶瑕佺瓟瀹屼繚瀛樼瓟妗堬紝杩欐牱鍏朵粬浜洪亣鍒板氨鑳藉仛瀵? shouldSaveAnswer = true;
} else {
//鏈夌瓟妗? answerData = JSON.parse(answerData.data.txt_content);
answer = answerData[0].content;
}
}
blanks[0].setAttribute("value", answer);
blanks[0].dispatchEvent(inputBubblesEvent);
break;
}
else {
//鎬曟湁娌$┖鐧界殑鎯呭喌銆? }
break;
}
case "澶氶€夐": {
results = [];
let hasButton = false;
for (let i = 0; i < allTips.length; i++) {
let tip = allTips;
let answer = tip.textContent;
if (answer && answer.length > 0) {
for (let j = 0; j < allbuttons.length; j++) {
//鑾峰彇鎸夐挳
let selectButton = allbuttons[j];
//鑾峰彇鎸夐挳鐨勪笂鐨勭瓟妗? let buttonAnswer = selectButton.textContent;
if (buttonAnswer == answer || buttonAnswer.indexOf(answer) != -1 || answer.indexOf(buttonAnswer) != -1) {
hasButton = true;
if (!$(selectButton).hasClass("chosen")) {
selectButton.click();
}
break;
}
}
}
}
if (!hasButton) {
allbuttons[0].click();
}
break;
}
case "鍗曢€夐": {
let results = [];
let answer = "";
for (let i = 0; i < allTips.length; i++) {
answer += allTips.textContent;
}
if (answer && answer.length > 0) {
let hasButton = false;
for (let i = 0; i < allbuttons.length; i++) {
let radioButton = allbuttons;
let buttonAnswer = radioButton.textContent;
//瀵规瘮绛旀
if (buttonAnswer == answer || buttonAnswer.indexOf(answer) != -1 || answer.indexOf(buttonAnswer) != -1) {
hasButton = true;
radioButton.click();
break;
}
}
if (!hasButton) {
//娌℃壘鍒版寜閽紝闅忎究閫変竴涓? allbuttons[0].click();
}
} else {
//娌$瓟妗堬紝闅忎究閫変竴涓? try {
allbuttons[0].click();
} catch(e) {
console.log(e);
}
}
break;
}
default:
break;
}
qNum++;
nextButton = await getNextButton();
if (nextButton.textContent != "鍐嶇粌涓€娆? && nextButton.textContent != "鍐嶆潵涓€缁? && nextButton.textContent != "鏌ョ湅瑙f瀽") {
nextButton.click();
if (shouldSaveAnswer) {//濡傛灉搴旇淇濆瓨绛旀
let key = getKey();//鑾峰彇key
let answerTemp = document.getElementsByClassName("answer")[0].innerText;
let reg = new RegExp(' ', "g")
let answer = "";
try {//浠庡瓧绗︿覆涓嬁鍑虹瓟妗? answer = answerTemp.split("锛?)[1];
answer = answer.replace(reg, ";");
} catch (e) {
answer = answerTemp;
}
await saveAnswer(key, answer);
shouldSaveAnswer = false;
}
} else {
//宸茬粡鍋氬畬锛岃烦鍑哄惊鐜? break;
}
}
closeWin();
}
//鑾峰彇鍏抽敭瀛?function getKey() {
//鑾峰彇棰樼洰鐨勬枃鏈唴瀹? let key = document.getElementsByClassName("q-body")[0].innerText;
//澶栭儴寮曠敤md5鍔犲瘑
key = md5(key);
console.log(key)
return key;
}
//淇濆瓨绛旀
function saveAnswer(key, value) {
return new Promise(function (resolve) {
value = [{ "title": key, "content": value }];
value = JSON.stringify(value);
$.ajax({
type: "POST",
url: AnswerSaveUrl,
data: {
txt_name: key,
txt_content: value,
password: "",
v_id: ""
},
dataType: "json",
success: function (data) {
resolve(data);
},
error: function () {
resolve("error");
}
});
})
}
//鑾峰彇绛旀
function getAnswer(key) {
return new Promise(function (resolve) {
$.ajax({
type: "POST",
url: AnswerDetailUrl,
data: {
txt_name: key,
password: ""
},
dataType: "json",
success: function (data) {
resolve(data);
},
error: function () {
resolve("error");
}
});
})
}
//鍘婚櫎绛旈楠岃瘉
function cancelVerify() {
try {
let verifyBox = document.getElementById("nc_mask");
verifyBox.id = "egg_nc_mask";
verifyBox.innerHTML = "";
verifyBox.remove();
} catch (e) {
console.log("鍘婚櫎楠岃瘉澶辫触");
}
}
//鏌ヨ浠婃棩瀹屾垚鎯呭喌
function getToday() {
return new Promise(function (resolve) {
$.ajax({
type: "GET",
url: SearchSocreUrl,
xhrFields: {
withCredentials: true //濡傛灉娌℃湁杩欎釜璇锋眰澶辫触
},
dataType: "json",
success: function (temp) {
resolve(temp.data.taskProgress);
},
error: function () {
resolve(new Array());
}
});
})
}
//鍒濆鍖栭厤缃?function initSetting() {
try {
let settingTemp = JSON.parse(GM_getValue('studySetting'));
if (settingTemp != null && Object.prototype.toString.call(settingTemp) === '[object Object]') {
// 澧炲姞鍒ゆ柇鏄惁涓烘棫鏁扮粍绫诲瀷缂撳瓨
settings = settingTemp;
} else {
settings = JSON.parse(JSON.stringify(settingsDefault));
}
} catch (e) {
//娌℃湁鍒欑洿鎺ュ垵濮嬪寲
settings = JSON.parse(JSON.stringify(settingsDefault));
}
}
//鍒涘缓鈥滄墜鍔ㄧ瓟棰樷€濇寜閽?function createManualButton() {
let title = document.getElementsByClassName("title")[0];
let manualButton = document.createElement("button");
manualButton.setAttribute("id", "manualButton");
manualButton.innerText = "鍏抽棴鑷姩绛旈";
manualButton.className = "egg_auto_btn";
//娣诲姞浜嬩欢鐩戝惉
try {// Chrome銆丗ireFox銆丱pera銆丼afari銆両E9.0鍙婂叾浠ヤ笂鐗堟湰
manualButton.addEventListener("click", clickManualButton, false);
} catch (e) {
try {// IE8.0鍙婂叾浠ヤ笅鐗堟湰
manualButton.attachEvent('onclick', clickManualButton);
} catch (e) {// 鏃╂湡娴忚鍣? console.log("涓嶅涔犱綍浠ュ己鍥絜rror: 鎵嬪姩绛旈鎸夐挳缁戝畾浜嬩欢澶辫触")
}
}
//鎻掑叆鑺傜偣
title.parentNode.insertBefore(manualButton, title.nextSibling);
}
//鐐瑰嚮鎵嬪姩瀛︿範鎸夐挳
function clickManualButton() {
let manualButton = document.getElementById("manualButton");
if (manualButton.innerText == "鍏抽棴鑷姩绛旈") {
manualButton.innerText = "寮€鍚嚜鍔ㄧ瓟棰?;
manualButton.className = "egg_manual_btn";
pause = true;
} else {
manualButton.innerText = "鍏抽棴鑷姩绛旈";
manualButton.className = "egg_auto_btn";
pause = false;
}
}
//鍒涘缓鈥滃紑濮嬪涔犫€濇寜閽拰閰嶇疆
function createStartButton() {
let base = document.createElement("div");
var baseInfo = "";
baseInfo += "<form id=\"settingData\" class=\"egg_menu\" action=\"\" target=\"_blank\" onsubmit=\"return false\"><div class=\"egg_setting_box\"><div class=\"egg_setting_item\"><label>鏂伴椈<\/label><input class=\"egg_setting_switch\" type=\"checkbox\" name=\"News\" " + (settings.News ? 'checked' : '') + "\/> <\/div> <div class=\"egg_setting_item\"> <label>瑙嗛<\/label> <input class=\"egg_setting_switch\" type=\"checkbox\" name=\"Video\" " + (settings.Video ? 'checked' : '') + "\/> <\/div> <div class=\"egg_setting_item\"> <label>姣忔棩绛旈<\/label> <input class=\"egg_setting_switch\" type=\"checkbox\" name=\"ExamPractice\" " + (settings.ExamPractice ? 'checked' : '') + "\/> <\/div> <div class=\"egg_setting_item\"> <label>涓撻」缁冧範<\/label> <input class=\"egg_setting_switch\" type=\"checkbox\" name=\"ExamPaper\" " + (settings.ExamPaper ? 'checked' : '') + "\/><\/div><hr \/><div title='Tip:寮€濮嬪涔犲悗锛岄殣钘忕浉鍏抽〉闈㈠拰鎻愮ず锛堜笉闅愯棌绛旈涓殑鍏抽棴鑷姩绛旈鎸夐挳锛? class=\"egg_setting_item\"> <label>杩愯闅愯棌<\/label> <input class=\"egg_setting_switch\" type=\"checkbox\" name=\"ShowMenu\"" + (settings.ShowMenu ? 'checked' : '') + "/></div>" +
"<div title='Tip:杩涘叆瀛︿範棣栭〉5绉掑悗鑷姩寮€濮嬪涔? class=\"egg_setting_item\"> <label>鑷姩寮€濮?\/label> <input class=\"egg_setting_switch\" type=\"checkbox\" name=\"AutoStart\"" + (settings.AutoStart ? 'checked' : '') + "/></div>"
+
"<a style=\"text-decoration: none;\" title=\"瑙嗛涓嶈嚜鍔ㄦ挱鏀撅紵鐐规鏌ョ湅瑙e喅鍔炴硶\" target=\"blank\" href=\"https://docs.qq.com/doc/DZllGcGlJUG1qT3Vx\"><div style=\"color:#5F5F5F;font-size:14px;\" class=\"egg_setting_item\"><label style=\"cursor: pointer;\">瑙嗛涓嶈嚜鍔ㄦ挱鏀?<\/label><\/div><\/a><\/div><\/form>";
base.innerHTML = baseInfo;
let body = document.getElementsByTagName("body")[0];
body.append(base)
let startButton = document.createElement("button");
startButton.setAttribute("id", "startButton");
startButton.innerText = "寮€濮嬪涔?;
startButton.className = "egg_study_btn egg_menu";
//娣诲姞浜嬩欢鐩戝惉
try {// Chrome銆丗ireFox銆丱pera銆丼afari銆両E9.0鍙婂叾浠ヤ笂鐗堟湰
startButton.addEventListener("click", start, false);
} catch (e) {
try {// IE8.0鍙婂叾浠ヤ笅鐗堟湰
startButton.attachEvent('onclick', start);
} catch (e) {// 鏃╂湡娴忚鍣? console.log("涓嶅涔犱綍浠ュ己鍥絜rror: 寮€濮嬪涔犳寜閽粦瀹氫簨浠跺け璐?)
}
}
//鎻掑叆鑺傜偣
body.append(startButton)
if (settings.AutoStart) {
setTimeout(() => {
if (startButton.innerText === "寮€濮嬪涔?) {
start()
}
}, 5000)
}
}
//淇濆瓨閰嶇疆
function saveSetting() {
let form = document.getElementById("settingData");
let formData = new FormData(form);
settings.News = (formData.get('News') != null);
settings.Video = (formData.get('Video') != null);
settings.ExamPractice = (formData.get('ExamPractice') != null);
settings.ExamWeekly = (formData.get('ExamWeekly') != null);
settings.ExamPaper = (formData.get('ExamPaper') != null);
settings.ShowMenu = (formData.get('ShowMenu') != null);//杩愯鏃舵槸鍚﹁闅愯棌
settings.AutoStart = (formData.get('AutoStart') != null);//鏄惁鑷姩鍚姩
GM_setValue('studySetting', JSON.stringify(settings));
}
//鏄惁鏄剧ず鐩綍
function showMenu(isShow = true) {
let items = document.getElementsByClassName("egg_menu");
for (let i = 0; i < items.length; i++) {
items.style.display = isShow ? "block" : "none";
}
}
//寮€濮?async function start() {
//淇濆瓨閰嶇疆
console.log("鍒濆鍖?..")
saveSetting();
let loggedBox = document.querySelectorAll("a[class='logged-link']")[0];
console.log("妫€鏌ユ槸鍚︾櫥褰?..")
if (loggedBox && loggedBox.innerText) {
let startButton = document.getElementById("startButton");
startButton.innerText = "姝e湪瀛︿範";
startButton.style.cursor = "default";
startButton.setAttribute("disabled", true);
if (settings.ShowMenu) {
showMenu(false);
}
let taskProgress = null;
let continueToDo = true;
let tasks = [false, false, false, false, false]
while (continueToDo) {
//鏌ヨ浠婂ぉ杩樻湁浠€涔堜换鍔℃病鍋氬畬
console.log("妫€鏌ヤ粖澶╄繕鏈変粈涔堜换鍔℃病鍋氬畬")
taskProgress = await getToday();
if (taskProgress != null) {
console.log("寮€濮嬪涔?)
// 鏄剧ず鐩墠寰楀垎
/*
let eggSettingItems = document.getElementsByClassName("egg_setting_item");
console.log(eggSettingItems[0].children[0].innerHTML);
eggSettingItems[0].children[0].innerHTML += ' ' + taskProgress[0].currentScore + '/' + taskProgress[0].dayMaxScore;
eggSettingItems[1].children[0].innerHTML += ' ' + ( taskProgress[1].currentScore + taskProgress[2].currentScore ) + '/' + ( taskProgress[1].dayMaxScore + taskProgress[2].dayMaxScore );
eggSettingItems[2].children[0].innerHTML += ' ' + taskProgress[5].currentScore + '/' + taskProgress[5].dayMaxScore;
eggSettingItems[3].children[0].innerHTML += ' ' + taskProgress[4].currentScore + '/' + taskProgress[4].dayMaxScore;
*/
//妫€鏌ユ柊闂? if (settings.News && taskProgress[0].currentScore != taskProgress[0].dayMaxScore) {
tasks[0] = false;//鍙杩樻湁瑕佸仛鐨勶紝灏卞綋鍋氭病瀹屾垚
newsNum = taskProgress[0].dayMaxScore - taskProgress[0].currentScore;//杩橀渶瑕佺湅澶氬皯涓柊闂? console.log("1.鐪嬫柊闂?);
await readNews();
} else {
tasks[0] = true;
}
//妫€鏌ヨ棰? let temp = parseInt(taskProgress[1].dayMaxScore - taskProgress[1].currentScore);
let temp2 = parseInt(taskProgress[2].dayMaxScore - taskProgress[2].currentScore);
if (settings.Video && (temp != 0 || temp2 != 0)) {
tasks[1] = false;//鍙杩樻湁瑕佸仛鐨勶紝灏卞綋鍋氭病瀹屾垚
videoNum = temp > temp2 ? temp : temp2;//杩橀渶瑕佺湅澶氬皯涓棰? console.log("2.鐪嬭棰?);
await watchVideo();
} else {
tasks[1] = true;
}
//妫€鏌ユ瘡鏃ョ瓟棰? if (settings.ExamPractice && taskProgress[5].currentScore != taskProgress[5].dayMaxScore) {
tasks[2] = false;//鍙杩樻湁瑕佸仛鐨勶紝灏卞綋鍋氭病瀹屾垚
console.log("3.鍋氭瘡鏃ョ瓟棰?);
await doExamPractice();
} else {
tasks[2] = true;
}
tasks[3] = true
/*
//妫€鏌ユ瘡鍛ㄧ瓟棰? if (settings.ExamWeekly && taskProgress[2].currentScore == 0) {
tasks[3] = false;//鍙杩樻湁瑕佸仛鐨勶紝灏卞綋鍋氭病瀹屾垚
console.log("4.鍋氭瘡鍛ㄧ瓟棰?);
let result = await doExamWeekly();
if (result == "noTest") {
//濡傛灉鏄叏閮藉畬鎴愪簡锛屽凡缁忔病鏈夎兘鍋氱殑浜? tasks[3] = true;
}
} else {
tasks[3] = true;
}*/
//妫€鏌ヤ笓椤圭粌涔? if (settings.ExamPaper && taskProgress[4].currentScore == 0) {
tasks[4] = false;//鍙杩樻湁瑕佸仛鐨勶紝灏卞綋鍋氭病瀹屾垚
console.log("5.鍋氫笓椤圭粌涔?);
let result = await doExamPaper();
if (result == "noTest") {
//濡傛灉鏄叏閮藉畬鎴愪簡锛屽凡缁忔病鏈夎兘鍋氱殑浜? tasks[4] = true;
}
} else {
tasks[4] = true;
}
if (tasks[0] && tasks[1] && tasks[2] && tasks[3] && tasks[4]) {
//濡傛灉妫€鏌ラ兘鍋氬畬浜嗭紝灏变笉鐢ㄧ户缁簡
continueToDo = false;
}
} else {
alert("鍙戠敓鎰忓閿欒")
continueToDo = false;
}
console.log("continueToDo : " + continueToDo)
}
console.log("宸插畬鎴?)
startButton.innerText = "宸插畬鎴?;
startButton.style.color = "#c7c7c7";
if (settings.ShowMenu) {
showMenu()
}
} else {
//鎻愰啋鐧诲綍
// alert("璇峰厛鐧诲綍");
//淇敼涓鸿烦杞埌鐧婚檰椤? let loggedButton = document.querySelectorAll("a[class='icon login-icon']")[0];
loggedButton.click()
setTimeout(() => {
closeWin()
}, 2000);
}
return false;
}
|
|