// ==UserScript== // @name 中国电信网上大学知识中心自动挂课 // @namespace http://tampermonkey.net/ // @version 0.3 // @description 点击知识中心右下加的启动按钮,开启无人值守自动挂课模式! // @author HuangDingYun // @match https://kc.zhixueyun.com/ // @icon https://www.google.com/s2/favicons?sz=64&domain=zhixueyun.com // @require https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/3.2.1/jquery.min.js // @grant unsafeWindow // @grant GM_openInTab // @grant GM.openInTab // @grant GM_getValue // @grant GM.getValue // @grant GM_setValue // @grant GM.setValue // @grant GM_xmlhttpRequest // @grant GM.xmlHttpRequest // @grant GM_registerMenuCommand // @grant GM_addValueChangeListener // @downloadURL none // ==/UserScript== var $ = unsafeWindow.jQuery; var classList = new Array(); var classList1 = new Array(); var nowCount = 0; var divButton = '
自动挂课
'; var mideaButton = '
播放
'; (function() { 'use strict'; setTimeout(function(){ var url=window.location.hash var urlStr=url.toString() //增加页面功能按钮 if(urlStr.match("/study/subject/detail/")){ $("#D60toolbarTab").append(divButton) }else{ //$("#D60toolbarTab").append(mideaButton) } //判断是否是课程页面 if($("div.vjs-duration-display").size()!=0){ isFinished() } },2500); setTimeout(function(){ if($("button.videojs-referse-btn").size()!=0){ playMedil() //$("button.videojs-referse-btn").get(0).click(); } },4000); // Your code here... })(); unsafeWindow.startAutoClass =function (){ //$("div.catalog-state-info").each(function(index,element){ // $(this).children("div").each(function(index,element){ // $(this).children("div.default-skin").each(function(index,element){ // if($(this).children("i.icon-reload").size()==0){ // classList.push($(this).get(0).parentNode) // } // }) // }) //}) $("div.item.current-hover").each(function(index,element){ if($(this).find("i.icon-reload").size()==0){ classList1.push($(this).attr("id")) } }) if(classList.length!=0){ openClassPage2(0) //openClassPage(0); }else{ alert("已经完成当前课题下的全部课程!") } } GM_onMessage('_.unique.name.greetings', function(src, message) { console.log('[onMessage]', src, '=>', message); nowCount++; //if(nowCount"+page) // } // page++; // } // }) // }) // }) //} function openClassPage2(nowCount){ console.log($("div#"+classList1[nowCount])) $("div#"+classList1[nowCount]).click(); } unsafeWindow.playMedil = function(){ if($("button.videojs-referse-btn").size()!=0){ //console.log($("button.videojs-referse-btn").get(0)) //console.log($("span.vjs-control-text:contains(', opens captions settings dialog')")) if($("span.vjs-control-text:contains(', opens captions settings dialog')").size()!=0){ $("span.vjs-control-text:contains(', opens captions settings dialog')").remove(); } $("span.vjs-control-text").click() } } function play(index){ setTimeout(function(){ if(index<$("span.vjs-control-text").size()){ console.log(index); $("span.vjs-control-text").get(index).click(); index++; play(index); } },2000); }