Skip to content

Commit 7f3a3d4

Browse files
committed
未登陆跳转登录页,随机等待修改为按毫秒随机
1 parent a3ac221 commit 7f3a3d4

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

techxuexi-js/version_info.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
"techxuexi_js_version": "v20220329",
33
"notice": "...",
44
"techxuexi_js_update_log": [{
5+
"version": "v20220922",
6+
"info": "添加自动开始学习,未登陆则会跳转到登录页"
7+
},{
58
"version": "v20220329",
69
"info": "修复视频播放一直正在初始化的问题"
710
},{

不学习何以强国.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// @author techxuexi ,荷包蛋。
77
// @match https://www.xuexi.cn
88
// @match https://www.xuexi.cn/*
9+
// @match https://pc.xuexi.cn/points/login.html*
910
// @match https://pc.xuexi.cn/points/exam-practice.html
1011
// @match https://pc.xuexi.cn/points/exam-weekly-detail.html?id=*
1112
// @match https://pc.xuexi.cn/points/exam-weekly-list.html
@@ -103,12 +104,13 @@ function waitRandomBetween(minSecond = 2, MaxSecond = 5) {
103104
if (MaxSecond <= minSecond) {
104105
MaxSecond = minSecond + 3
105106
}
106-
let waitTime = Math.random() * (MaxSecond - minSecond) + minSecond
107+
108+
let waitTime = Math.floor(Math.random() * (MaxSecond * 1000 - minSecond * 1000) + minSecond * 1000)
107109
return new Promise((resolve, reject) => {
108110
setTimeout(() => {
109-
console.log(`随机等待${waitTime}秒`)
111+
console.log(`随机等待${waitTime / 1000}秒`)
110112
resolve()
111-
}, waitTime * 1000)
113+
}, waitTime)
112114
})
113115
}
114116

@@ -124,7 +126,13 @@ $(document).ready(function () {
124126
createStartButton();
125127
}
126128
}, 800);
127-
} else if (typeof GM_getValue("readingUrl") != 'object' && url == GM_getValue("readingUrl")) {
129+
} else if (url.indexOf("login.html") !== -1) {
130+
console.log("检测到登录页")
131+
setTimeout(() => {
132+
window.scrollTo(0, 1000);
133+
}, 500);
134+
}
135+
else if (typeof GM_getValue("readingUrl") != 'object' && url == GM_getValue("readingUrl")) {
128136
try {
129137
let settingTemp = JSON.parse(GM_getValue('studySetting'));
130138
if (!settingTemp[7]) {
@@ -1179,10 +1187,13 @@ async function start() {
11791187
} else {
11801188
//提醒登录
11811189
// alert("请先登录");
1182-
1190+
11831191
//修改为跳转到登陆页
11841192
let loggedButton = document.querySelectorAll("a[class='icon login-icon']")[0];
11851193
loggedButton.click()
1194+
setTimeout(() => {
1195+
closeWin()
1196+
}, 2000);
11861197
}
11871198
return false;
11881199
}

0 commit comments

Comments
 (0)