aq100lite

安全生产快速学习

  1. // ==UserScript==
  2. // @name aq100lite
  3. // @namespace https://bjdc.100anquan.com/
  4. // @version 1.0
  5. // @description 安全生产快速学习
  6. // @author Shining
  7. // @match https://*.100anquan.com/*
  8. // @match http://*.100anquan.com/*
  9. // @grant unsafeWindow
  10. // @grant GM_log
  11. // @grant GM_xmlhttpRequest
  12. // @grant GM_setValue
  13. // @grant GM_getValue
  14. // @grant GM_openInTab
  15. // @connect 100anquan.com
  16. // @run-at document-end
  17. // ==/使用网页自带的@require https://libs.baidu.com/jquery/1.8.3/jquery.min.js
  18. // ==/不require引入jquery时
  19. // ==/不引入jquery,$设置的是原网页的jquery,如果设置为document-start时:因为提前注入,无法使用原网页的jquery,会提示找不到$
  20. // ==/unsafeWindow 沙盒模式
  21. // ==/document-end 文件加载后运行插件
  22. // ==/UserScript==
  23. var tooberUrl = unsafeWindow.location.href;
  24. var $ = unsafeWindow.$;
  25. GM_log(tooberUrl);
  26. var orgProjectId = 0; //https://bjdc.100anquan.com/project/projectV2/21381/Detai
  27. window.onload = function() {
  28. if (tooberUrl == "https://bjdc.100anquan.com/" || tooberUrl.indexOf("loginGeneralV2/") != -1) {
  29. GM_log("进入首页");
  30. var logFun = unsafeWindow.GetLoginInfo;
  31. unsafeWindow.GetLoginInfo = function() {
  32. GM_log("登录事件");
  33. //----拦截方法1
  34. //可以logFun.toString()
  35. //替换字符串后,再见eval
  36. //var funStr = logFun.toString();
  37. //GM_log(funStr);
  38. //return unsafeWindow.eval(funStr);
  39. //----拦截方法2
  40. var accountName = $("#txtLogonUserCode");
  41. if (accountName.length > 0 != undefined && accountName.val() != "") {
  42. var user = {
  43. userName: accountName.val()
  44. };
  45. GM_setValue("aq100_user", user);
  46. }
  47. GM_log(accountName);
  48. logFun();
  49. }
  50. }
  51. if (tooberUrl.indexOf("/course/courseEleView?") != -1) {
  52. //因为@run-at document-start,在此设置页面加载完才运行
  53. GM_log("学习项");
  54. //注意前端函数
  55. unsafeWindow.hackTime = hackTime;
  56. //------手动按钮----
  57. $("#Menu").before('<input id="hackBtn" style="background-color:yellow;font-size:20px" type="button" style="height:60px" onclick="hackTime()" value="【破解学习】">');
  58. //自动执行
  59. window.setInterval(function() {
  60. hackTime();
  61. },
  62. 1000);
  63. } else if (tooberUrl.indexOf("/directExam/examIndexAutoV2") != -1) {
  64. //HTML directExam();
  65. //https://bjdc.100anquan.com/directExam/freePracticeV2/2141/4456/stochastic
  66. //(单/多选、判断题都有的考试地) https://bjdc.100anquan.com/directExam/examIndexAutoV2?examId=1523&examPaperId=19461&orgProjectId=2900
  67. GM_log("考试");
  68. var subBtn = $("div[onclick='subTest()']");
  69. if (subBtn.length > 0) {
  70. if ($("div").length > 0) {
  71. $("div").eq(0).before('<h1 style="text-align:center;background-color:black;color:white">已为您答完,您可以校对【答案】,或直接点击【交卷】完成考试。</h1>');
  72. }
  73. }
  74. $("ul").each(function() {
  75. var ul = $(this);
  76. var dl = ul.parent().parent().parent().parent().attr("id");
  77. GM_log(dl);
  78. var sty = [];
  79. if (dl != undefined) {
  80. sty = dl.split("_");
  81. }
  82. ul.find("li").each(function() {
  83. var attr = $(this).attr('onclick');
  84. if (typeof attr !== typeof undefined && attr !== false) {
  85. if (attr.indexOf("chooseAnswer(") != -1) {
  86. //单选题chooseAnswer
  87. //chooseAnswer('4','205549','0','0'); //最后一位是'1'是正确的
  88. if (endWidth(attr, "'1');")) {
  89. $(this).append('&nbsp;&nbsp;&nbsp;&nbsp;<strong style="background-color:green;font-size:20px;color:white">【✔】</strong>');
  90. $(this).click(); //自动点击正确
  91. if (sty.length >= 2) {
  92. $("#SHOWSTYLE_" + sty[1]).removeClass().addClass("li_2");
  93. }
  94. }
  95. } else if (attr.indexOf("chooseJudgeAnswer(") != -1) {
  96. //判断题chooseJudgeAnswer
  97. //chooseJudgeAnswer('T','332956','1')
  98. //选择题以1结尾的应该选择正确,以0结尾的应该选择错误
  99. if (endWidth(attr, "'1');")) {
  100. if (ul.find(".hkmsg").length <= 0) { //避免重复添加
  101. ul.find("li").eq(0).append('&nbsp;&nbsp;&nbsp;&nbsp;<strong class="hkMsg" style="background-color:green;font-size:20px;color:white">【✔】</strong>');
  102. ul.find("li").eq(0).click(); //自动点击正确
  103. if (sty.length >= 2) {
  104. //$("#SHOWSTYLE_" + sty[1]).removeClass().addClass("li_2");
  105. $("#SHOWSTYLE_" + sty[1]).removeClass();
  106. $("#SHOWSTYLE_" + sty[1]).css({
  107. "border": "1px solid #44d441",
  108. "background": "#ddfddc",
  109. "color": "blue"
  110. });
  111. }
  112. }
  113. } else {
  114. if (ul.find(".hkmsg").length <= 0) {
  115. ul.find("li").eq(1).append('&nbsp;&nbsp;&nbsp;&nbsp;<strong class="hkMsg" style="background-color:green;font-size:20px;color:white">【✔】</strong>');
  116. ul.find("li").eq(1).click(); //自动点击错误
  117. if (sty.length >= 2) {
  118. //$("#SHOWSTYLE_" + sty[1]).removeClass().addClass("li_2");
  119. $("#SHOWSTYLE_" + sty[1]).removeClass();
  120. $("#SHOWSTYLE_" + sty[1]).css({
  121. "border": "1px solid #44d441",
  122. "background": "#ddfddc",
  123. "color": "blue"
  124. });
  125. }
  126. }
  127. }
  128. } else if (attr.indexOf("chooseMoreAnswer(") != -1) {
  129. //多选题chooseAnswer
  130. //chooseMoreAnswer('1','244380','0','1'); //最后一位是'1'是正确的
  131. if (endWidth(attr, "'1');")) {
  132. $(this).append('&nbsp;&nbsp;&nbsp;&nbsp;<strong style="background-color:green;font-size:20px;color:white">【✔】</strong>');
  133. $(this).click(); //自动点击正确
  134. if (sty.length >= 2) {
  135. //$("#SHOWSTYLE_" + sty[1]).removeClass().addClass("li_2");
  136. $("#SHOWSTYLE_" + sty[1]).removeClass();
  137. $("#SHOWSTYLE_" + sty[1]).css({
  138. "border": "1px solid #44d441",
  139. "background": "#ddfddc",
  140. "color": "red"
  141. });
  142. }
  143. }
  144. }
  145. }
  146. });
  147. });
  148. } else if (tooberUrl.indexOf("/directExam/examInfoTestv2") != -1) {
  149. //HTML directExam();
  150. //强行考试https://bjdc.100anquan.com/directExam/freePracticeV2/2141/4456/stochastic
  151. GM_log("强行考试");
  152. //也可以加button强引网址考试
  153. //onclick
  154. $(".tj_btn").before('<button style="background-color:yellow;font-size:20px" onclick="directExam();">强行考试</button>');
  155. } else if (tooberUrl.indexOf("/loginV2/userLogin") != -1) {
  156. GM_log("跳过弱密码修改");
  157. if ($("html").html().indexOf("鉴于您的密码过于简单") != -1) {
  158. unsafeWindow.window.location.href = "https://bjdc.100anquan.com/index";
  159. }
  160. }else if(tooberUrl.indexOf("/daxing/exam/examPractice?studyCourseId=") != -1){
  161. //小考
  162. //https://bjdc.100anquan.com/daxing/exam/examPractice?studyCourseId=13593&studyCourseElementId=35906&orgProjectId=21381&eleIndex=1&allIndex=0
  163. $('input[value="1"]').each(function() {
  164. $(this).click();
  165. });
  166. }else if (tooberUrl.indexOf("/course/personStudyPage/") != -1) {
  167. //https://bjdc.100anquan.com/daxing/course/personStudyPage/3292/21762
  168. ////查看考试地址https://bjdc.100anquan.com/directExam/examInfoTestv2/2141?orgProjectId=4456
  169. GM_log("学习列表");
  170. var projectId= orgProjectId //"21381";//■■■课程ID■■■
  171. //hook掉判断学习时间函数,原函数里面也有一个错误 [url] 未定义
  172. unsafeWindow.judgeScoreXinjiang = function(courseId, obj, elementId, wareIndex) {
  173. GM_log("hook judgeScoreXinjiang");
  174. //21381//21314
  175. unsafeWindow.window.location.href = "/daxing/course/courseEleView?elementId=" + elementId + "&courseId=" + courseId + "&wareIndex=" + wareIndex + "&orgProjectId="+projectId;
  176. return;
  177. };
  178. function abc(arr){
  179. //https://bjdc.100anquan.com/daxing/course/courseEleView?elementId=35889&courseId=13593&wareIndex=2&orgProjectId=21381
  180. var element = unsafeWindow.window.location.href;
  181. var array = element.match(/\d+/g);
  182. var courseId = array[2];
  183. var elementId = arr[0].replace(new RegExp("'",("gm")),"");
  184. var wareIndex = arr[1].replace(new RegExp("'",("gm")),"");
  185.  
  186. GM_log(elementId);
  187. GM_log(courseId);
  188. GM_log(wareIndex);
  189. var uuu ="https://bjdc.100anquan.com/daxing/course/courseEleView?elementId="+elementId+"&courseId="+courseId+"&wareIndex="+wareIndex+"&orgProjectId="+projectId;
  190. GM_openInTab(uuu);
  191. }
  192. unsafeWindow.fast = function(){
  193. $('[value="进入学习"]').each(function() {
  194. var arr = $(this).attr("onclick");
  195. //eval("refreshPage(this,'35889','2');");
  196. var array = arr.match(/'\d+'/g);
  197. abc(array);
  198. });
  199. $('[value="继续学习"]').each(function() {
  200. var arr = $(this).attr("onclick");
  201. //eval("refreshPage(this,'35889','2');");
  202. var array = arr.match(/'\d+'/g);
  203. abc(array);
  204. });
  205. }
  206. //gotoExam('1987','4460')
  207. //var btn = $("input[onclick^='gotoExam(']");
  208. //if(btn.length >0){
  209. //判断jquery元素是否存在不能判断undefined需要判断length
  210. //var arr = btn.eq(0).attr("onclick").match(/\d+/g);
  211. //var url = "https://bjdc.100anquan.com/directExam/examInfoTestv2/" + arr[0] +"?orgProjectId=" + arr[1];
  212. //GM_log("hack " + url);
  213. //}
  214. var tables = $("table");
  215. if (tables.length >= 1) {
  216. $(".table_a").eq(0).before('<button style="background-color:yellow;font-size:20px" onclick="fast();">快速学习</button>');
  217. }
  218.  
  219. //***自动申请学时
  220. // 寻找是否有进入学习的按钮refreshPage(this,'31664','1');
  221. var arr = $("input[onclick^='refreshPage(']");
  222. if (arr.length > 0) {
  223. var flag = false;
  224. var okNum = 0; //已学习的项
  225. arr.each(function() {
  226. var str = $(this).val();
  227. if (str == "已学习") {
  228. okNum++;
  229. }
  230. });
  231. if (okNum == arr.length) {
  232. // 拦截修改autoPayScore里的alert,修改为申请成功才返回
  233. // 避免重复刷新后又执行autoPayScore
  234. var autoPayScore = unsafeWindow.autoPayScore;
  235. var autoPayScoreStr = unsafeWindow.autoPayScore.toString();
  236. autoPayScoreStr = autoPayScoreStr.replace('location = location;', '');
  237. autoPayScoreStr = autoPayScoreStr.replace('alert("申请成功!")', 'alert("申请学时成功!");location = location;');
  238. if ($("input[onclick='autoPayScore()']").length > 0) {
  239. GM_log("未申请学时,将自动申请");
  240. //unsafeWindow.autoPayScore();
  241. //拦截以后
  242. //eval里的autoPayScoreStr字符串不是能直接执行的script
  243. //而是定义的 function autoPayScore()方法;
  244. //需要在eval后面追加立即执行字符串
  245. unsafeWindow.eval(autoPayScoreStr + "autoPayScore();");
  246.  
  247. } else {
  248. GM_log("已申请学时");
  249. }
  250. $("title").html("■已学完■");
  251. }
  252. }
  253. } else if (tooberUrl.indexOf("/project/projectV2/") != -1) {
  254. //https://bjdc.100anquan.com/project/projectV2/4010/Detai
  255. //破解后 https://bjdc.100anquan.com/person/personOrgSubjectList?orgProjectId=4515
  256. var array = tooberUrl.match(/\/\d+\//g);
  257. orgProjectId = array[0].replace(new RegExp("/",("gm")),"");
  258. GM_log("课程列表"+orgProjectId);
  259. var regBtn = $("button[onclick^='registration(']").eq(0);
  260. if (regBtn != undefined) {
  261. var onc = regBtn.attr("onclick");
  262. //registration('0.0','2020-02-25 10:59:40.0')
  263. if (onc != undefined && onc.indexOf("registration('0.0'") == -1) {
  264. //收费的
  265. var substr = tooberUrl.match(/\/(\d+)\//);
  266. if (substr.length >= 1) {
  267. var num = substr[0].replace(/\//g, '');
  268. var script = "javascrtpt:window.location.href='https://bjdc.100anquan.com/person/personOrgSubjectList?orgProjectId=" + num + "'";
  269. regBtn.parent().before('<br/><button class="btn-primary" style="margin-right:100px;" onclick="' + script + '">破解学习</button>');
  270. }
  271. }
  272. }
  273. }
  274. //else if(tooberUrl.indexOf("/course/personStudyPage/") != -1){
  275. // // personStudyPage/4456/18881 orgProjectId/courseId
  276. // // refreshPage(this,'59851','1');
  277. // // goto https://bjdc.100anquan.com/daxing/course/courseEleView?elementId=59851&courseId=18881&wareIndex=1&orgProjectId=4456
  278. // unsafeWindow.getItem = getItem //同名函数注入到前台
  279. // $(".btn_ab").each(function(){
  280. // var onc = $(this).attr("onclick");
  281. // if(onc.indexOf("refreshPage") != -1){
  282. // var arr = tooberUrl.split("\/");
  283. // var orgProjectId = arr[arr.length - 2];
  284. // var courseId = arr[arr.length - 1];
  285. // var elementId = onc.split(",")[1].replace(/'/g,"");
  286. // var wareIndex = onc.split(",")[2].replace(/'|\);/g,"");
  287. // $(this).before('<input name="button2" type="button" class="btn_ab" id="button2" onclick="getItem('+elementId+','+courseId+','+wareIndex+','+orgProjectId+');" value="学习完毕">');
  288. // }
  289. // });
  290. //}
  291.  
  292. function endWidth(str, target) {
  293. var start = str.length - target.length;
  294. var arr = str.substr(start, target.length);
  295. if (arr == target) {
  296. return true;
  297. }
  298. return false;
  299. }
  300. function getItem(elementId, courseId, wareIndex, orgProjectId) {
  301. var url = "https://bjdc.100anquan.com/daxing/course/courseEleView?elementId=" + elementId + "&courseId=" + courseId + "&wareIndex=" + wareIndex + "&orgProjectId=" + orgProjectId;
  302. get(url,
  303. function(html) {
  304. GM_log(html);
  305. });
  306. }
  307. function get(url, call) {
  308. GM_xmlhttpRequest({
  309. method: 'GET',
  310. url: url,
  311. headers: {},
  312. onload: function(responseDetails) {
  313. var html = responseDetails.responseText;
  314. call(html);
  315. }
  316. });
  317. }
  318. function hackTime(nextOnClick) {
  319. $("#stayInVideoTime").val(10000);
  320. unsafeWindow.ajaxSendData();
  321. unsafeWindow.returnForward();
  322. }
  323. function hackTime1(nextOnClick) {
  324. var isFlash = false; //判断是否是flash控件播放
  325. var player = unsafeWindow.window.cc_js_Player;
  326. if (player == undefined) {
  327. isFlash = true;
  328. }
  329. var time = 0;
  330. if (!isFlash) {
  331. time = Math.round(unsafeWindow.window.cc_js_Player.getDuration());
  332. } else {
  333. time = Math.round(unsafeWindow.player.j2s_getDuration());
  334. }
  335. if (!isNaN(time) && time > 0) {
  336. $("#stayInVideoTime").val(time);
  337. unsafeWindow.ajaxSendData();
  338. $("#hackBtn").val("已学完【" + time + "】秒");
  339. $("#hackBtn").css({
  340. 'background-color': 'green',
  341. 'color': 'white'
  342. });
  343. $('#hackBtn').attr("disabled", "disabled");
  344. unsafeWindow.returnForward();
  345.  
  346. } else {
  347. var timestamp = new Date().getSeconds();
  348. $("#hackBtn").val("网慢无法加载时按【F5】键刷新,视频加载中【" + timestamp + "】");
  349. $("#hackBtn").css({
  350. 'background-color': 'red',
  351. 'color': 'white'
  352. });
  353. }
  354. try {
  355. if (!isFlash) {
  356. unsafeWindow.window.cc_js_Player.pause();
  357. } else {
  358. GM_log("FLASH NOT FUNCTION PAUSE();");
  359. }
  360. } catch(err) {
  361. GM_log(err);
  362. }
  363. }
  364. }