安全微伴

通过在h5上模拟点击,调用结束课程请求等方法实现自动化刷课,具有一定隐蔽性,不会被发现

  1. // ==UserScript==
  2. // @name 安全微伴
  3. // @version 0.5
  4. // @description 通过在h5上模拟点击,调用结束课程请求等方法实现自动化刷课,具有一定隐蔽性,不会被发现
  5. // @author 九尾妖渚
  6. // @match *://weiban.mycourse.cn/*
  7. // @match https://mcwk.mycourse.cn/*
  8. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  9. // @grant none
  10. // @run-at document-end
  11. // @namespace https://greatest.deepsurf.us/users/822791
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. const addHistoryEvent = function(type) {
  18. var originalMethod = history[type];
  19. return function() {
  20. var recallMethod = originalMethod.apply(this, arguments);
  21. var e = new Event(type);
  22. e.arguments = arguments;
  23. window.dispatchEvent(e);
  24. return recallMethod;
  25. };
  26. };
  27. history.pushState = addHistoryEvent('pushState');
  28. history.replaceState = addHistoryEvent('replaceState');
  29.  
  30. var getVal = function(fun1, fun2){
  31. let id = setInterval(()=>{
  32. var val = fun1();
  33. if (val.length) {
  34. clearInterval(id);
  35. fun2(val);
  36. }
  37. }, 100)
  38. }
  39. var start = function(e) {
  40. $(function(){
  41. setTimeout(()=>{
  42. //console.log(window.location);
  43. // 第一阶段 在主页
  44. if (window.location.hash === '#/') {
  45. getVal(()=>{return $("div.task-block-new")}, (res)=>{
  46. //console.log(res);
  47. setTimeout(()=>{
  48. res[0].click();
  49. }, 200);
  50.  
  51. })
  52. }
  53. // 第二阶段 在学习任务
  54. var reg = /course.*projectId.*projectType.*special.*title.*/
  55. if (window.location.hash.match(reg)) {
  56. // 先检测出还需要完成的任务
  57. getVal(()=>{return $("li.folder-item")},(res)=>{
  58. res = res.filter(function(index){
  59. var child = this.querySelector('.state');
  60. var str = child.innerHTML;
  61. if (str.substring(0, str.indexOf("/")) === str.substring(str.indexOf("/") + 1, str.length)) {
  62. return false;
  63. }
  64. return true;
  65. })
  66. //console.log(res);
  67. getVal(()=>{return res.find('.folder-extra a')}, (res2)=>{
  68. res2[0].click();
  69. })
  70. })
  71. };
  72. // 第三阶段 在学习任务列表
  73. reg = /course.*list.*projectType.*subjectType.*categoryCode.*projectId.*categoryName.*/
  74. if (window.location.hash.match(reg)) {
  75. getVal(()=>{return $("li.course")},(res)=>{
  76. res = res.filter(function(index){
  77. var child = this.querySelector('.course-content h3 i');
  78. return !child;
  79. })
  80. //console.log(res);
  81. if (res.length == 0) {
  82. getVal(()=>{return $("a.mint-tab-item.is-selected")}, (res2)=>{
  83. res2[0].click();
  84. })
  85. }
  86. else res[0].click();
  87. })
  88. }
  89.  
  90. // 第四阶段 在iframe中 同域解决方法
  91. /*if (window.location.hash.match(reg)) {
  92. getVal(()=>{return $("iframe")},(res)=>{
  93. res[0].contentWindow.finishWxCours();
  94. })
  95.  
  96. } */
  97. }, 1000)
  98.  
  99. });
  100. }
  101. window.addEventListener('pushState', start);
  102. window.addEventListener('popstate', start);
  103. //console.log("脚本执行");
  104. // 第四阶段 此时在异域iframe中
  105. if (window.location.href.indexOf("mcwk.mycourse.cn/course/") != -1) {
  106. // console.log(window.location.href);
  107. $(function(){
  108. setTimeout(()=>{
  109. try{console.log(exportRoot.currentFrame)}catch(e){}
  110. try {
  111. var userid = getQueryString("userCourseId");
  112. var jiaoxuejihuaid = getQueryString("tenantCode");
  113. var finishWxHost = document.referrer.replace("http://","").replace("https://","").split("/")[0];
  114. if(document.referrer=="" || document.referrer==null || document.referrer==undefined){
  115. finishWxHost = "weiban.mycourse.cn"
  116. }
  117.  
  118. var webUrl = window.location.href;
  119. var finishWxUrl=getRecordUrl(webUrl);
  120. if(finishWxHost.indexOf("218.25.139.161") > 0){
  121. //finishWxUrl = "http://"+finishWxHost+"/pharos/usercourse/finish.do";
  122. finishWxUrl = "https://"+finishWxHost+"/pharos/usercourse/finish.do";
  123. }
  124.  
  125. var finishData = {"userCourseId": userid, "tenantCode": jiaoxuejihuaid};
  126.  
  127. $.ajax({
  128. async: false,
  129. url: finishWxUrl,
  130. type: "GET",
  131. dataType: "jsonp",
  132. data: finishData,
  133. timeout: 5000,
  134.  
  135. success : function (data) {
  136. backToList();
  137. },
  138. error: function (XMLHttpRequest, textStatus, errorThrown) {
  139. }
  140. });
  141. } catch (e) {
  142. alert("报了啥错误" + e)
  143. }
  144.  
  145. }, 10000)
  146.  
  147. })
  148.  
  149. }
  150. else if (window.location.href.indexOf("weiban.mycourse.cn/") != -1) {
  151. //console.log(window.location.href);
  152. $(function(){
  153. start();
  154. })
  155. }
  156.  
  157. // Your code here...
  158. })();