// ==UserScript== // @name 超星学习通-讨论自动复读 // @version 0.32 // @description 进入到讨论区,填写大佬名字,点击页面上的“开始复读”按钮,自动将大佬的20道最新讨论题答案抄过来提交。如果大佬还没回答就抄第一个回答的人,如果还没人回答就下一题 // @match *://*.chaoxing.com/bbscircle/grouptopic?* // @match *://*.chaoxing.com/bbscircle/gettopicdetail?* // @author duya12345 // @require http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js // @grant GM_setValue // @grant GM_getValue // @namespace https://greasyfork.org/users/517463 // @downloadURL https://update.greasyfork.icu/scripts/401103/%E8%B6%85%E6%98%9F%E5%AD%A6%E4%B9%A0%E9%80%9A-%E8%AE%A8%E8%AE%BA%E8%87%AA%E5%8A%A8%E5%A4%8D%E8%AF%BB.user.js // @updateURL https://update.greasyfork.icu/scripts/401103/%E8%B6%85%E6%98%9F%E5%AD%A6%E4%B9%A0%E9%80%9A-%E8%AE%A8%E8%AE%BA%E8%87%AA%E5%8A%A8%E5%A4%8D%E8%AF%BB.meta.js // ==/UserScript== //本代码测试环境为谷歌浏览器,有同学反映qq浏览器上无法看到按钮,作者表示暂时找不到原因,建议更换浏览器 var $ = unsafeWindow.jQuery; var done_times = GM_getValue("done_times"); var your_name = GM_getValue("your_name");//不用填了,自动获取 var list_length = GM_getValue("list_length"); var dalao_name = GM_getValue("dalao_name");//大佬的名字,此项可以留空,即所有答案都抄第一个回答的 function if_referred_other(url)//判断是不是刚进讨论页面 { var re = /bbscircle\/grouptopic/m; if(url.match(re) != null){ return true; } return false; } function if_done(){//判断下有没有回答过 var namelist = document.getElementsByClassName("name"); console.log("有"+namelist.length+"人回答过此问题"); for(var i = 0; i < namelist.length; i++){ if(your_name == namelist[i].innerText){ return true; } } return false; } function GetBigGodsAnswer() { //抓一个大佬的答案 var req = GetRequest(); var contentid = "topic_replys_"+req.topicid; var search_str = document.getElementById(contentid).innerHTML; var re1 = new RegExp(dalao_name + "([\\s\\S]+?)", 'm');//锁定大佬 var re2 = /(?<=)([\s\S]+?)(?=<\/h3>)/m;//未锁定大佬时:任意回答;锁定大佬时:大佬的回答 var match1 = search_str.match(re2); var match2 = search_str.match(re1); if(match1 == null){//还没人回答 return "uwfigawuyhaofi3r983yhr89f[3h892ryrjq89rff"; } if(if_done(search_str) == true){//找到自己名字了 return "fuhqwaifuhuwaqfbgcuaosjfcdopwtfgn23333333";//瞎打一串不可能出现的content,交给下级判断去 } if(match2 == null){//大佬还没回答 console.log("找到大佬没有回答的题了"); return match1[0];//那就返回第一个回答的 } var match3 = match2[0].match(re2)[0]; var replace_out1 = match3.replace(/
/g, "\n"); var replace_out2 = replace_out1.replace(/ /g, " "); return replace_out2; } function GetRequest() {//获取url参数 var url = location.search; var theRequest = new Object(); if (url.indexOf("?") != -1) { var str = url.substr(1); var strs = str.split("&"); for(var i = 0; i < strs.length; i ++) { theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]); } } return theRequest; } function getAllNoticeAttachment(){//拿上传文件的,用不到,但改了怕出问题先放着 var attachment = ""; var attachmentsByName = document.getElementsByName("attachment"); if (attachmentsByName != null && attachmentsByName.length > 0) { for (var i = 0; i < attachmentsByName.length; i++) { var attachmentA = attachmentsByName[i]; if (attachmentA == null) { continue; } attachment += attachmentA.getAttribute('value') + ","; } } return attachment; } function form_rep_submit(content){//提交函数,直接抄官方的改一改 var req = GetRequest(); var img=$("#images_img_"+req.topicid).find("img"); var str=""; for(var i=0;i 0){//防止上次没跑完,导致下次进来的时候直接继续跑 done_times = 2*list_length; } if(done_times < 2*list_length){ setTimeout(function() { main(done_times); }, 800); GM_setValue("done_times", ++done_times); } })();