// ==UserScript== // @name 国开学习网教师登陆天数辅助 // @namespace https://greasyfork.org/zh-CN/users/707063-genexy // @version 202310231916 // @description 国家开放大学,国开学习网教师登陆天数和进入课程辅助工具,请设置浏览器允许弹窗网站(menhu.pt.ouchn.cn) // @author 流浪的蛊惑 // @connect ai.baidu.com // @match *://*.ouchn.cn/* // @grant GM_xmlhttpRequest // @license MIT // @downloadURL none // ==/UserScript== var href = location.href; function addXMLRequestCallback(callback){//监听请求 var oldSend, i; if( XMLHttpRequest.callbacks ) { XMLHttpRequest.callbacks.push( callback ); } else { XMLHttpRequest.callbacks = [callback]; oldSend = XMLHttpRequest.prototype.send; XMLHttpRequest.prototype.send = function(){//监听发送 for( i = 0; i < XMLHttpRequest.callbacks.length; i++ ) { XMLHttpRequest.callbacks[i]( this ); } oldSend.apply(this, arguments); } XMLHttpRequest.prototype.wrappedSetRequestHeader=XMLHttpRequest.prototype.setRequestHeader; XMLHttpRequest.prototype.setRequestHeader = function(header, value) {//监听自定义主机头 this.wrappedSetRequestHeader(header, value); if(!this.headers) { this.headers = {}; } if(!this.headers[header]) { this.headers[header] = []; } this.headers[header].push(value); } } } function getBase64Image(image,ext){ var canvas = document.createElement("canvas"); canvas.width = image.width; canvas.height = image.height; var context = canvas.getContext("2d"); context.drawImage(image,0,0,image.width,image.height); // 这里是不支持跨域的 var base64 = canvas.toDataURL("image/"+ext); return base64; } var listkc=null function getkclb(){//获取当前课程列表 GM_xmlhttpRequest({ method: "post", url: "/ouchnapp/wap/course/jskc-pc", headers: { "Content-Type": "application/x-www-form-urlencoded" }, data: "tab=&page=1&page_size=200", onload: function(res){ let rec=JSON.parse(res.responseText); listkc=rec.d.list; } }); } (function() { 'use strict'; addXMLRequestCallback( function( xhr ) { xhr.addEventListener("load", function(){ if (xhr.readyState==4 && xhr.status==200) { if (xhr.responseURL.includes("/am/validatecode/verify.do")){//验证验证码 let dat=JSON.parse(xhr.responseText); console.log(dat); if(dat.state=="failed"){ document.getElementById("kaptchaImage").click(); let zhjd=parseInt(localStorage.getItem("帐号进度")); localStorage.setItem("帐号进度",zhjd-1); delay=0; } } if (xhr.responseURL.includes("/ouchnapp/wap/course/jskc-pc")){//科目获取 getkclb(); } } }); }); let delay=0,nextjs=0,dlxs=true; setInterval(function(){ let dlxx=localStorage.getItem("登陆帐号"); if(dlxx!=null){ if(href.includes("/am/UI/Login")){ if(delay==1){//延时获取验证码 let imgdat=getBase64Image(document.getElementById("kaptchaImage"),"png"); GM_xmlhttpRequest({ method: "post", url: "https://ai.baidu.com/aidemo", headers: { "Content-Type": "application/x-www-form-urlencoded", "referer":"https://ai.baidu.com/tech/ocr_others/webimage" }, data: "type="+encodeURIComponent("https://aip.baidubce.com/rest/2.0/ocr/v1/webimage")+"&image="+encodeURIComponent(imgdat), onload: function(res){ let rec=JSON.parse(res.responseText); console.log(rec); if(rec.errno==0){ if(rec.data.words_result_num>0){ document.getElementById("validateCode").value=rec.data.words_result[0].words;//验证码 let zhjd=parseInt(localStorage.getItem("帐号进度")); let zhs=dlxx.split("\n"); if(zhjd教师账号{用户名,密码}一行一个
"; dlstr+="

"; dlk.innerHTML=dlstr; } } if(href.includes("/site/ouchnPc/index")){ let kcjd=localStorage.getItem("课程进度"); if(kcjd!=null){ nextjs++; if(nextjs>15){ nextjs=0; document.getElementsByClassName("ouchnPc_index_title")[0].getElementsByTagName("a")[0].click(); localStorage.setItem("课程进度",parseInt(kcjd)+1); } if(nextjs==1){ if(kcjd"+listkc[kcjd].title+""; }else{ localStorage.clear(); setTimeout(()=>{window.open("https://lms.ouchn.cn/logout")},8000); setTimeout(()=>{document.getElementsByClassName("left_logout")[0].click()},10000); } } }else{ localStorage.setItem("课程进度","0"); } } if(href.includes("lms.ouchn.cn/course/")){ if((nextjs++)>8){ window.close(); } } if(href.includes("/auth/realms/guokai/protocol/cas/login")){ if((nextjs++)>3){ window.close(); } } },1000); })();