// ==UserScript== // @name 国开学习网教师登陆天数辅助 // @namespace https://greasyfork.org/zh-CN/users/707063-genexy // @version 202106022347 // @description 国家开放大学,国开学习网教师登陆天数和进入课程辅助工具,请设置浏览器允许弹窗网站(thome.ouchn.cn) // @author 流浪的蛊惑 // @match *://*.ouchn.cn/* // @grant none // @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() { 'use strict'; addXMLRequestCallback( function( xhr ) { xhr.addEventListener("load", function(){ if (xhr.readyState==4 && xhr.status==200) { if (xhr.responseURL.includes("thome.ouchn.cn")){ let dat=JSON.parse(xhr.responseText); console.log(dat); } } }); }); var nextjs=0,dlxs=true; setInterval(function(){ let dlxx=localStorage.getItem("登陆帐号"); if(dlxx!=null){ if(href.includes("passport.ouchn.cn/Account/Login")){ let zhjd=parseInt(localStorage.getItem("帐号进度")); localStorage.setItem("帐号进度",zhjd+1); let zhs=dlxx.split("\n"); if(zhjd<=zhs.length){ document.getElementById("username").value=zhs[zhjd].split(",")[0]; document.getElementById("password").value=zhs[zhjd].split(",")[1]; document.getElementById("loginbth").click(); }else{ dlxs=true; localStorage.clear(); } } }else if(dlxs){ dlxs=false; let dlk=document.getElementsByClassName("login-bg"); if(dlk.length>0){ let dlstr="
教师账号{用户名,密码}一行一个
"; dlstr+="

"; dlk[0].innerHTML=dlstr; } } if(href.includes("://thome.ouchn.cn")){ let kcjd=localStorage.getItem("课程进度"); if(kcjd!=null){ let kclj=document.getElementById("coursedesignList").getElementsByTagName("a"); if((nextjs++)>10){ nextjs=0; if(kcjd<=kclj.length){ localStorage.setItem("课程进度",parseInt(kcjd)+1); kclj[kcjd].click(); }else{ localStorage.clear(); location.href="/Home/Logout"; } } }else{ localStorage.setItem("课程进度","0"); } } if(href.includes("course/view.php")){ if((nextjs++)>8){ window.close(); } } },1000); })();