// ==UserScript== // @name 云学堂全自动刷视频 yunxuetang.cn // @namespace zhou__jianlei // @version 0.12 // @description 云学堂视频播放 文档浏览 // @author zhou__jianlei // @icon https://picobd.yxt.com/orgs/yxt_malladmin/mvcpic/image/201811/71672740d9524c53ac3d60b6a4123bca.png // @match http*://*.yunxuetang.cn/plan/*.html // @match http*://*.yunxuetang.cn/kng/*/document/* // @match http*://*.yunxuetang.cn/kng/*/video/* // @match http*://*.yunxuetang.cn/kng/plan/package/* // @match http*://*.yunxuetang.cn/kng/view/package/* // @match http*://*.yunxuetang.cn/kng/course/package/video/* // @match http*://*.yunxuetang.cn/kng/course/package/document/* // @match http*://*.yunxuetang.cn/sty/index.htm // @match http*://*.yunxuetang.cn/exam/test/examquestionpreview.htm* // @match http*://*.yunxuetang.cn/exam/test/userexam.htm* // @match http*://*.yunxuetang.cn/kng/*.htm* // @grant GM_xmlhttpRequest // @grant unsafeWindow // @require https://cdn.bootcdn.net/ajax/libs/blueimp-md5/2.18.0/js/md5.min.js // @downloadURL none // ==/UserScript== (function () { const path = window.location.pathname; const href = window.location.href; const date = new Date(); //任务列表页 if (path.match(/^\/plan.*/g)) { console.log('学习任务列表页...'); $('.w-150').each(function (index, item) { const text = $(item).children('.text-grey').eq(1).text(); console.log('任务' + (index+1) + ', 播放进度:' + text); if (text.includes('%') && text !== '100%') { console.log('点击这个未播放完成的'); window.setTimeout(function () { const str = $(item).parents('.hand').eq(0).attr('onclick') + ''; let arr = str.split("'"); console.info(arr[1]); window.open(arr[1], '_self'); }, 10 * 1000); return false; } }); } else if (path.match(/^\/kng\/.*\/document.*/g) || path.match(/^\/kng\/course\/package\/document.*/g)) { //文档页 console.log('文档页准备就绪...'); window.setInterval(function () { //检测在线 detectionOnline(); //防作弊 checkMoreOpen(); //完成度检测 detectionComplete(); }, 30 * 1000); } else if (path.match(/^\/kng\/.*\/video.*/g) || path.match(/^\/kng\/course\/package\/video.*/g)) { //视频页 console.log('视频页准备就绪...'); //每30秒检测一次 window.setInterval(function () { //检测在线 detectionOnline(); //防作弊 checkMoreOpen(); //检测播放状态 detectPlaybackStatus(); //完成度检测 detectionComplete(); }, 30 * 1000); } else if (path.match(/^\/kng\/\w*\/package.*/g)) { console.log('课程包明细页...'); let progress = $('#lblStudySchedule').text(); if (progress == '100') { let kng_href = localStorage.getItem('kng_href_key') layer.msg('已学习完成3秒后返回列表页:' + kng_href); window.setTimeout(function () { window.open(kng_href,'_self'); }, 3 * 1000) }else{ // 3秒后点击开始学习按钮 layer.msg('3秒后开始学习'); window.setTimeout(function () { $('#btnStartStudy').click(); }, 3 * 1000) } } else if (path.match(/^\/kng\/.*/g)) { console.log('列表页...' + href); localStorage.setItem('kng_href_key',href); $('.el-kng-bottom-detail').each( function (index, item) { let text = $(item).parent().children('div').eq(0).children('span').text(); console.log(text) if(text !== '已完成'){ console.log(index + ' 点击这个未完成的'); let attr = $(item).children('div').eq(0).children('.text-normal').attr('onclick') + ''; window.setTimeout(function () { if (attr) { let arr = attr.split("'"); console.info('RUL链接: ' + arr[1]); window.open(arr[1], '_self'); } }, 1000 * 5); return false; } } ) } else if (path.match(/^\/sty.*/g)) { console.log('学习任务签到'); signdata(); } //检测多开弹窗 function checkMoreOpen() { console.debug('检测多开弹窗'); if ($("#dvSingleTrack").length) { console.log("防止多开作弊 弹窗"); StartCurStudy(); } } //在线检测 function detectionOnline() { const date = new Date(); var dom = document.getElementById("dvWarningView"); console.info(date.toLocaleString() + ' 检测是否有弹窗...'); if (dom) { console.debug('弹窗出来了'); const cont = dom.getElementsByClassName("playgooncontent")[0].innerText; if (cont.indexOf("请不要走开喔") != -1) { document.getElementsByClassName("btnok")[1].click(); } else { //没遇到过这种情况 不能处理了 返回上一级 console.error('没遇到过这种情况 不能处理了, 弹窗内容:' + cont); window.setTimeout(function () { //刷新当前页吧 window.location.reload(); }, 5 * 1000) } } } //检测完成(进度100%) function detectionComplete() { const percentage = $('#ScheduleText').text(); console.log('进度百分比: ' + percentage); if (percentage == '100%') { //返回上一级 GoBack(); } } //检测播放状态 function detectPlaybackStatus() { const date = new Date(); console.info(date.toLocaleString() + ' 检测播放状态...') if (myPlayer.getState() == 'playing') { myPlayer.setPlaybackRate(2); console.log("播放中...啥也不操作了"); } else if (myPlayer.getState() == 'paused') { //暂停 console.log("暂停啦!!!"); myPlayer.play(); console.log("开始播放~"); } else if (myPlayer.getState() == 'complete') { console.log($('#lblTitle').text() + "播放完成!!!"); //返回上一级 GoBack(); } } })();