Greasy Fork镜像 支持简体中文。

超星学习通-讨论自动复读

进入到讨论区,填写大佬名字,点击页面上的“开始复读”按钮,自动将大佬的20道最新讨论题答案抄过来提交。如果大佬还没回答就抄第一个回答的人,如果还没人回答就下一题

目前為 2020-04-21 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name 超星学习通-讨论自动复读
  3. // @version 0.30
  4. // @description 进入到讨论区,填写大佬名字,点击页面上的“开始复读”按钮,自动将大佬的20道最新讨论题答案抄过来提交。如果大佬还没回答就抄第一个回答的人,如果还没人回答就下一题
  5. // @match *://*.chaoxing.com/bbscircle/grouptopic?*
  6. // @match *://*.chaoxing.com/bbscircle/gettopicdetail?*
  7. // @author duya12345
  8. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js
  9. // @grant GM_setValue
  10. // @grant GM_getValue
  11. // @namespace https://gf.qytechs.cn/users/517463
  12. // ==/UserScript==
  13.  
  14. //本代码测试环境为谷歌浏览器,有同学反映qq浏览器上无法看到按钮,作者表示暂时找不到原因,建议更换浏览器
  15.  
  16. var $ = unsafeWindow.jQuery;
  17. var done_times = GM_getValue("done_times");
  18. var your_name = GM_getValue("your_name");//不用填了,自动获取
  19. var list_length = GM_getValue("list_length");
  20. var dalao_name = GM_getValue("dalao_name");//大佬的名字,此项可以留空,即所有答案都抄第一个回答的
  21.  
  22. function if_done(){//判断下有没有回答过
  23. var namelist = document.getElementsByClassName("name");
  24. console.log("有"+namelist.length+"人回答过此问题");
  25. for(var i = 0; i < namelist.length; i++){
  26. if(your_name == namelist[i].innerText){
  27. return true;
  28. }
  29. }
  30. return false;
  31. }
  32.  
  33. function GetBigGodsAnswer() { //抓一个大佬的答案
  34. var req = GetRequest();
  35. var contentid = "topic_replys_"+req.topicid;
  36. var search_str = document.getElementById(contentid).innerHTML;
  37. var re1 = new RegExp(dalao_name + "([\\s\\S]+?)</h3>", 'm');//锁定大佬
  38. var re2 = /(?<=<h3([\s\S]+?)>)([\s\S]+?)(?=<\/h3>)/m;//未锁定大佬时:任意回答;锁定大佬时:大佬的回答
  39.  
  40. var match1 = search_str.match(re2);
  41. var match2 = search_str.match(re1);
  42. if(match1 == null){//还没人回答
  43. return "uwfigawuyhaofi3r983yhr89f[3h892ryrjq89rff";
  44. }
  45. if(if_done(search_str) == true){//找到自己名字了
  46. return "fuhqwaifuhuwaqfbgcuaosjfcdopwtfgn23333333";//瞎打一串不可能出现的content,交给下级判断去
  47. }
  48. if(match2 == null){//大佬还没回答
  49. console.log("找到大佬没有回答的题了");
  50. return match1[0];//那就返回第一个回答的
  51. }
  52. var match3 = match2[0].match(re2)[0];
  53. var replace_out1 = match3.replace(/<br>/g, "\n");
  54. var replace_out2 = replace_out1.replace(/&nbsp;/g, " ");
  55. return replace_out2;
  56. }
  57.  
  58. function GetRequest() {//获取url参数
  59. var url = location.search;
  60. var theRequest = new Object();
  61. if (url.indexOf("?") != -1) {
  62. var str = url.substr(1);
  63. var strs = str.split("&");
  64. for(var i = 0; i < strs.length; i ++) {
  65. theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
  66. }
  67. }
  68. return theRequest;
  69. }
  70.  
  71. function getAllNoticeAttachment(){//拿上传文件的,用不到,但改了怕出问题先放着
  72. var attachment = "";
  73. var attachmentsByName = document.getElementsByName("attachment");
  74. if (attachmentsByName != null && attachmentsByName.length > 0) {
  75. for (var i = 0; i < attachmentsByName.length; i++) {
  76. var attachmentA = attachmentsByName[i];
  77. if (attachmentA == null) {
  78. continue;
  79. }
  80. attachment += attachmentA.getAttribute('value') + ",";
  81. }
  82. }
  83. return attachment;
  84. }
  85.  
  86. function form_rep_submit(content){//提交函数,直接抄官方的改一改
  87. var req = GetRequest();
  88. var img=$("#images_img_"+req.topicid).find("img");
  89. var str="";
  90. for(var i=0;i<img.size();i++){
  91. var imgsrc=img[i];
  92. if(i==img.size()){
  93. str=str+imgsrc.src.replace("100_100","origin");
  94. }else{
  95. str=str+imgsrc.src.replace("100_100","origin")+",";
  96. }
  97. }
  98. if(content=="fuhqwaifuhuwaqfbgcuaosjfcdopwtfgn23333333"){
  99. console.log("系统检测到此问题已回答");
  100. return false;
  101. }
  102. else if(content=="uwfigawuyhaofi3r983yhr89f[3h892ryrjq89rff"){
  103. console.log("还没人回答,再等等吧");
  104. return false;
  105. }
  106. var allAttachment = getAllNoticeAttachment();
  107. $.ajax({
  108. type: "post",
  109. url : "/bbscircle/addreply",
  110. dataType:'html',
  111. data: {
  112. clazzid : req.clazzid,
  113. topicId : req.topicid,
  114. content : content,
  115. files : str,
  116. cpi : req.cpi,
  117. ut : req.ut,
  118. attachmentFile:allAttachment,
  119. openc : req.openc
  120. },
  121. success: function(data){
  122. if (data.indexOf('error') == 0) {
  123. alert(data.replace('error;',''));
  124. return false;
  125. }
  126. var div=$("#more_reply_"+req.topicId);
  127. data = data.replace(/(^\s*)|(\s*$)/g,"");
  128. if(document.getElementById("lastInfo")){
  129. $("#lastInfo").before(data);
  130. }else{
  131. var doc = document.getElementById("topic_replys_"+req.topicId);
  132. doc.innerHTML += data;
  133. }
  134. $("#"+req.topicId).val("");
  135. console.log('成功复读');
  136. return true;
  137. },
  138. error: function(data){
  139. console.log('???');
  140. return false;
  141. }
  142. });
  143. }
  144.  
  145. function content_list(i){
  146. var see_all = document.getElementsByClassName("lookall")[parseInt(i/2)];
  147. if(see_all != null){
  148. see_all.click();
  149. }
  150. else{
  151. console.log("找不到按钮1");
  152. }
  153. }
  154.  
  155. function content_detail(){
  156. var more_button = document.getElementById("more_reply");
  157. if(more_button != null){
  158. console.log("pressed");
  159. more_button.click();//点一下加载更多
  160. }
  161. else{
  162. console.log("找不到按钮2");
  163. }
  164. window.onload = function(){
  165. var flag = form_rep_submit(GetBigGodsAnswer());
  166. setTimeout(function(){
  167. window.history.back();
  168. if(flag == true){
  169. window.history.back();
  170. }
  171. }, 1000);
  172. }
  173. }
  174.  
  175. function main(i){
  176. var url = window.location.pathname;
  177. if(url == "/bbscircle/grouptopic"){
  178. content_list(i);
  179. }
  180. else{
  181. content_detail();
  182. }
  183. }
  184.  
  185. function create_input(){
  186. var my_div = document.createElement("div");
  187. my_div.setAttribute("id", "my_div");
  188. my_div.innerText = "填入大佬名字(如果有的话):";
  189. var inner_pos = document.getElementsByClassName("title1118")[0];
  190. inner_pos.after(my_div);
  191.  
  192. var name_text = document.createElement("input");
  193. name_text.setAttribute("type", "input")
  194. name_text.setAttribute("id", "name_text");
  195. my_div.append(name_text);
  196. }
  197.  
  198. function create_button(){
  199. var button = document.createElement("input");
  200. button.setAttribute("type", "button");
  201. button.setAttribute("value", "开始复读");
  202. button.setAttribute("id", "start_button");
  203. button.style.width = "80px";
  204. button.style.height = "30px";
  205. button.style.align = "center";
  206. button.style.marginLeft = "0px";
  207. button.style.marginBottom = "0px";
  208. button.style.background = "#b46300";
  209. button.style.border = "1px solid #b46300";
  210. button.style.color = "white";
  211. var inner_pos = document.getElementById("name_text");
  212. inner_pos.after(button);
  213. $("#start_button").click(function() {
  214. button_click();
  215. });
  216. }
  217.  
  218. function button_click() {
  219. GM_setValue("done_times", 0);
  220. your_name = document.getElementsByClassName("zt_u_name")[0].innerText;
  221. GM_setValue("your_name", your_name);
  222. list_length = document.getElementsByClassName("lookall").length;
  223. GM_setValue("list_length", list_length);
  224. dalao_name = document.getElementById("name_text").value;
  225. GM_setValue("dalao_name", dalao_name);
  226. location.reload();
  227. }
  228.  
  229. (function() {
  230. 'use strict';
  231. if(window.location.pathname == "/bbscircle/grouptopic"){//done_times == list_length*2
  232. create_input();
  233. create_button();
  234. }
  235. if(done_times < list_length*2){
  236. setTimeout(function() {
  237. main(done_times);
  238. }, 800);
  239. GM_setValue("done_times", ++done_times);
  240. }
  241. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址