@@ -56,14 +56,14 @@ var videoNum = 6;
5656var videos = [ ] ;
5757//配置
5858var settings = { } ;
59- var settingsDefault = {
60- News :true , //0
61- Video :true , //1
62- ExamPractice :true , //6 每日答题
63- ExamWeekly :true , //2 每周答题
64- ExamPaper :true , //5 专项练习
65- ShowMenu :false , //7 隐藏菜单
66- AutoStart :false , //是否加载脚本后自动播放
59+ var settingsDefault = {
60+ News : true , //0
61+ Video : true , //1
62+ ExamPractice : true , //6 每日答题
63+ ExamWeekly : true , //2 每周答题
64+ ExamPaper : true , //5 专项练习
65+ ShowMenu : false , //7 隐藏菜单
66+ AutoStart : false , //是否加载脚本后自动播放
6767}
6868var pause = false ; //是否暂停答题
6969//每周答题当前页码
@@ -84,12 +84,12 @@ const ratelimitms = 3000;
8484//默认情况下, chrome 只允许 window.close 关闭 window.open 打开的窗口,所以我们就要用window.open命令,在原地网页打开自身窗口再关上,就可以成功关闭了
8585function closeWin ( ) {
8686 try {
87- window . opener = window ;
88- var win = window . open ( "" , "_self" ) ;
89- win . close ( ) ;
90- top . close ( ) ;
87+ window . opener = window ;
88+ var win = window . open ( "" , "_self" ) ;
89+ win . close ( ) ;
90+ top . close ( ) ;
9191 } catch ( e ) {
92- }
92+ }
9393
9494}
9595
@@ -99,16 +99,16 @@ function closeWin() {
9999 * @param {number } MaxSecond 最长时长
100100 * @returns Promise
101101 */
102- function waitRandomBetween ( minSecond = 2 , MaxSecond = 5 ) {
103- if ( MaxSecond <= minSecond ) {
104- MaxSecond = minSecond + 3
102+ function waitRandomBetween ( minSecond = 2 , MaxSecond = 5 ) {
103+ if ( MaxSecond <= minSecond ) {
104+ MaxSecond = minSecond + 3
105105 }
106106 let waitTime = Math . random ( ) * ( MaxSecond - minSecond ) + minSecond
107- return new Promise ( ( resolve , reject ) => {
108- setTimeout ( ( ) => {
107+ return new Promise ( ( resolve , reject ) => {
108+ setTimeout ( ( ) => {
109109 console . log ( `随机等待${ waitTime } 秒` )
110110 resolve ( )
111- } , waitTime * 1000 )
111+ } , waitTime * 1000 )
112112 } )
113113}
114114
@@ -198,48 +198,48 @@ function getVideoTag() {
198198 let video = null ;
199199 let pauseButton = null ;
200200 var u = navigator . userAgent ;
201- if ( u . indexOf ( 'Mac' ) > - 1 ) { //Mac
202- if ( iframe != null && iframe . innerHTML ) {
203- //如果有iframe,说明外面的video标签是假的
204- video = iframe . contentWindow . document . getElementsByTagName ( "video" ) [ 0 ] ;
205- pauseButton = iframe . contentWindow . document . getElementsByClassName ( "prism-play-btn" ) [ 0 ] ;
206- } else {
207- //否则这个video标签是真的
208- video = document . getElementsByTagName ( "video" ) [ 0 ] ;
209- pauseButton = document . getElementsByClassName ( "prism-play-btn" ) [ 0 ] ;
210- }
211- return {
212- "video" : video ,
213- "pauseButton" : pauseButton
214- }
215- }
216- else {
217- if ( iframe ) {
218- //如果有iframe,说明外面的video标签是假的
219- video = iframe . contentWindow . document . getElementsByTagName ( "video" ) [ 0 ] ;
220- pauseButton = iframe . contentWindow . document . getElementsByClassName ( "prism-play-btn" ) [ 0 ] ;
221- } else {
222- //否则这个video标签是真的
223- video = document . getElementsByTagName ( "video" ) [ 0 ] ;
224- pauseButton = document . getElementsByClassName ( "prism-play-btn" ) [ 0 ] ;
225- }
226- return {
227- "video" : video ,
228- "pauseButton" : pauseButton
201+ if ( u . indexOf ( 'Mac' ) > - 1 ) { //Mac
202+ if ( iframe != null && iframe . innerHTML ) {
203+ //如果有iframe,说明外面的video标签是假的
204+ video = iframe . contentWindow . document . getElementsByTagName ( "video" ) [ 0 ] ;
205+ pauseButton = iframe . contentWindow . document . getElementsByClassName ( "prism-play-btn" ) [ 0 ] ;
206+ } else {
207+ //否则这个video标签是真的
208+ video = document . getElementsByTagName ( "video" ) [ 0 ] ;
209+ pauseButton = document . getElementsByClassName ( "prism-play-btn" ) [ 0 ] ;
210+ }
211+ return {
212+ "video" : video ,
213+ "pauseButton" : pauseButton
214+ }
229215 }
216+ else {
217+ if ( iframe ) {
218+ //如果有iframe,说明外面的video标签是假的
219+ video = iframe . contentWindow . document . getElementsByTagName ( "video" ) [ 0 ] ;
220+ pauseButton = iframe . contentWindow . document . getElementsByClassName ( "prism-play-btn" ) [ 0 ] ;
221+ } else {
222+ //否则这个video标签是真的
223+ video = document . getElementsByTagName ( "video" ) [ 0 ] ;
224+ pauseButton = document . getElementsByClassName ( "prism-play-btn" ) [ 0 ] ;
225+ }
226+ return {
227+ "video" : video ,
228+ "pauseButton" : pauseButton
229+ }
230230 }
231231}
232232
233233//读新闻或者看视频
234234//type:0为新闻,1为视频
235235async function reading ( type ) {
236236 //看文章或者视频
237- var time = 1 ;
238- if ( type == 0 ) {
239- time = parseInt ( Math . random ( ) * ( 100 - 80 + 1 ) + 80 , 10 ) ; //80-100秒后关闭页面,看文章
240- } else {
241- time = parseInt ( Math . random ( ) * ( 250 - 230 + 1 ) + 230 , 10 ) ; //230-250秒后关闭页面,看视频
242- }
237+ var time = 1 ;
238+ if ( type == 0 ) {
239+ time = parseInt ( Math . random ( ) * ( 100 - 80 + 1 ) + 80 , 10 ) ; //80-100秒后关闭页面,看文章
240+ } else {
241+ time = parseInt ( Math . random ( ) * ( 250 - 230 + 1 ) + 230 , 10 ) ; //230-250秒后关闭页面,看视频
242+ }
243243 let firstTime = time - 2 ;
244244 let secendTime = 12 ;
245245 let scrollLength = document . body . scrollHeight / 2 ;
@@ -313,7 +313,7 @@ async function readNews() {
313313 console . log ( "正在看第" + ( i + 1 ) + "个新闻" ) ;
314314 let newPage = GM_openInTab ( news [ i ] . url , { active : true , insert : true , setParent : true } ) ;
315315 await waitingClose ( newPage ) ;
316- await waitRandomBetween ( 1 , 3 ) ;
316+ await waitRandomBetween ( 1 , 3 ) ;
317317 }
318318}
319319//获取新闻列表
@@ -405,7 +405,7 @@ async function watchVideo() {
405405 console . log ( "正在观看第" + ( i + 1 ) + "个视频" ) ;
406406 let newPage = GM_openInTab ( videos [ i ] . url , { active : true , insert : true , setParent : true } )
407407 await waitingClose ( newPage ) ;
408- await waitRandomBetween ( 1 , 3 ) ;
408+ await waitRandomBetween ( 1 , 3 ) ;
409409 }
410410}
411411//做每日答题
@@ -423,11 +423,11 @@ function doExamPractice() {
423423}
424424
425425//fix code = 429
426- async function waitingDependStartTime ( startTime ) {
426+ async function waitingDependStartTime ( startTime ) {
427427 let remainms = Date . now ( ) - startTime ;
428428 if ( remainms < ratelimitms ) {
429- let second = ( ratelimitms - remainms ) / 1000
430- await waitRandomBetween ( second + 1 , second + 3 )
429+ let second = ( ratelimitms - remainms ) / 1000
430+ await waitRandomBetween ( second + 1 , second + 3 )
431431 }
432432}
433433//初始化专项答题总页数属性
@@ -690,7 +690,7 @@ async function doingExam() {
690690 let shouldSaveAnswer = false ;
691691 while ( true ) {
692692 //先等等再开始做题
693- await waitRandomBetween ( 2 , 5 ) ;
693+ await waitRandomBetween ( 2 , 5 ) ;
694694 await doingPause ( ) ;
695695 nextButton = await getNextButton ( ) ;
696696 if ( nextButton . textContent == "再练一次" || nextButton . textContent == "再来一组" || nextButton . textContent == "查看解析" ) {
@@ -703,7 +703,7 @@ async function doingExam() {
703703 }
704704 //所有提示
705705 var allTips = document . querySelectorAll ( "font[color=red]" ) ;
706- await waitRandomBetween ( 2 , 3 ) ;
706+ await waitRandomBetween ( 2 , 3 ) ;
707707 //选项按钮
708708 var allbuttons = document . querySelectorAll ( ".q-answer" ) ;
709709 //获取所有填空
@@ -1026,10 +1026,10 @@ function clickManualButton() {
10261026function createStartButton ( ) {
10271027 let base = document . createElement ( "div" ) ;
10281028 var baseInfo = "" ;
1029- 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=\"ExamWeekly\" " + ( settings . ExamWeekly ? '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>" +
1030- "<div title='Tip:进入学习首页5秒后自动开始学习' class=\"egg_setting_item\"> <label>自动开始<\/label> <input class=\"egg_setting_switch\" type=\"checkbox\" name=\"AutoStart\"" + ( settings . AutoStart ? 'checked' : '' ) + "/></div>"
1031- +
1032- "<a style=\"text-decoration: none;\" title=\"视频不自动播放?点此查看解决办法\" 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>" ;
1029+ 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=\"ExamWeekly\" " + ( settings . ExamWeekly ? '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>" +
1030+ "<div title='Tip:进入学习首页5秒后自动开始学习' class=\"egg_setting_item\"> <label>自动开始<\/label> <input class=\"egg_setting_switch\" type=\"checkbox\" name=\"AutoStart\"" + ( settings . AutoStart ? 'checked' : '' ) + "/></div>"
1031+ +
1032+ "<a style=\"text-decoration: none;\" title=\"视频不自动播放?点此查看解决办法\" 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>" ;
10331033 base . innerHTML = baseInfo ;
10341034 let body = document . getElementsByTagName ( "body" ) [ 0 ] ;
10351035 body . append ( base )
@@ -1050,20 +1050,20 @@ function createStartButton() {
10501050 //插入节点
10511051 body . append ( startButton )
10521052
1053- if ( settings . AutoStart ) {
1054- setTimeout ( ( ) => {
1055- if ( startButton . innerText === "开始学习" ) {
1053+ if ( settings . AutoStart ) {
1054+ setTimeout ( ( ) => {
1055+ if ( startButton . innerText === "开始学习" ) {
10561056 start ( )
10571057 }
1058- } , 5000 )
1058+ } , 5000 )
10591059 }
10601060}
10611061//保存配置
10621062function saveSetting ( ) {
10631063 let form = document . getElementById ( "settingData" ) ;
10641064 let formData = new FormData ( form ) ;
10651065 settings . News = ( formData . get ( 'News' ) != null ) ;
1066- settings . Video = ( formData . get ( 'Video' ) != null ) ;
1066+ settings . Video = ( formData . get ( 'Video' ) != null ) ;
10671067 settings . ExamPractice = ( formData . get ( 'ExamPractice' ) != null ) ;
10681068 settings . ExamWeekly = ( formData . get ( 'ExamWeekly' ) != null ) ;
10691069 settings . ExamPaper = ( formData . get ( 'ExamPaper' ) != null ) ;
@@ -1177,8 +1177,12 @@ async function start() {
11771177 showMenu ( )
11781178 }
11791179 } else {
1180- //提醒登录
1181- alert ( "请先登录" ) ;
1180+ //提醒登录
1181+ // alert("请先登录");
1182+
1183+ //修改为跳转到登陆页
1184+ let loggedButton = document . querySelectorAll ( "a[class='icon login-icon']" ) [ 0 ] ;
1185+ loggedButton . click ( )
11821186 }
11831187 return false ;
11841188}
0 commit comments