// ==UserScript== // @name 学习通自动讨论 // @namespace https://scriptcat.org/users/27321 // @version 2.3.1 // @description 自动讨论,仅在讨论界面生效,用于自动讨论学习通网络选修课的50讨论 // @author 万事可乐 // @match https://*/bbscircle/grouptopic* // @match https://mooc2-ans.chaoxing.com/mycourse/stu?*s // @icon https://groupweb.chaoxing.com/favicon.ico // @grant none // ==/UserScript== (function() { 'use strict'; var times=50 //自动讨论次数,默认50条 var clicktime=1500 //每次页面加载后发送讨论的延迟,不建议太小,单位为毫秒 // code here... var tips = document.getElementsByClassName("title1118")[0] var tip=document.createElement('div') tips.appendChild(tip) tip.innerText="当前设置为自动讨论 "+times+" 条" tip.style="font-size:18px;color:rgb(230 15 15)" document.querySelector("body > div.main1118 > div:nth-child(3)").id="temp" var temp = document.getElementById('temp') var count=0 var string=window.location.href.substring(location.href.indexOf("#")+1,window.location.href.length) if(location.href.indexOf("#")!=-1){ count=Number(string) } function 讨论(){ window.alert = function() {//阻止弹窗 return false; } window.location.href=window.location.href.replace("#"+string,"#"+(count+1)) //因网站刷新后脚本重新载入,所以用网址存储次数 document.querySelector("#c_title").value=count+1; setTimeout(function(){ document.querySelector("#addGroupTopicForm > div > div.listBtn > a.qdBtn.fr").click() location.reload() },clicktime)//延迟,不建议太小 } function addback(){ var back=document.createElement('button') temp.appendChild(back) back.style="font-size:20px;width: 100px;height:40px;margin:6px;margin-left: 100px" back.innerText="重置" back.onclick=function(){ document.querySelector("body > div.main1118 > div.title1118 > a:nth-child(4) > span").click() } } if(location.href.indexOf("#")==-1){ var button=document.createElement('button') temp.appendChild(button) button.style="font-size:20px;width: 200px;height:40px" button.innerText="开始讨论" button.onclick=function(){ location.href=location.href+"#0" location.reload() } } else if(count