中建一局先锋学堂知学云_挂机

挂机看知学云网课,已适配中建一局先锋学堂

  1. // ==UserScript==
  2. // @name 中建一局先锋学堂知学云_挂机
  3. // @namespace http://tampermonkey.net/
  4. // @version 3.3
  5. // @description 挂机看知学云网课,已适配中建一局先锋学堂
  6. // @author kakasearch
  7. // @match https://cscec1b.zhixueyun.com/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=cscec1b.zhixueyun.com
  9. // @require https://greasyfork.org/scripts/425166-elegant-alert-%E5%BA%93/code/elegant%20alert()%E5%BA%93.js?version=922763
  10. // @grant GM_setValue
  11. // @grant GM_getValue
  12. // @grant unsafeWindow
  13. // @antifeature ads 我们会展示捐助页面,但您可以关闭它
  14. // @license GPLV3
  15. // ==/UserScript==
  16.  
  17. (function() {
  18. 'use strict';
  19. unsafeWindow.kaka_not_donate = function(){
  20. document.querySelector("#donatediv").innerHTML='<div style="text-align: center; margin: 10px;"><p>(ಥ﹏ಥ) 好吧</p><div>'
  21. GM_setValue("donate_count",new Date().getTime())
  22. setTimeout(function(){window.location.reload()},1500)
  23. }
  24. unsafeWindow.kaka_has_donate = function(){
  25. if(document.querySelector("#donatediv")){document.querySelector("#donatediv").innerHTML= '<div style="text-align: center; margin: 10px;"><p>٩(^ᴗ^)۶ 公若不弃,某愿拜为义父</p><div>'}
  26. GM_setValue("donate_count",new Date().getTime()+ 1000*3600*24*365 )
  27. setTimeout(function(){window.location.reload()},1500)
  28. }
  29. setInterval(function(){
  30. if(/study\/errors/.test(window.location.href)){
  31. new ElegantAlertBox("准备关闭页面>__<")
  32. window.close()
  33. }
  34. },5000)
  35. if(!GM_getValue("doing")){
  36. //init
  37. GM_setValue("doing",{"name":"","time":1,"status":""})
  38. }
  39. if(!GM_getValue("donate_count")){
  40. //init
  41. GM_setValue("donate_count",new Date().getTime())
  42. }
  43. var donate_flag = true;
  44. if(GM_getValue("donate_count") && new Date().getTime()- GM_getValue("donate_count") > 1000*30*3600*24){
  45. //donate
  46. donate_flag = false ;
  47. var script = document.createElement('script');
  48. script.src = 'https://cdn.bootcdn.net/ajax/libs/layer/3.5.1/layer.min.js'; // Layer.js CDN链接
  49. document.head.appendChild(script);
  50. script.onload = function() {
  51. layer.open({
  52. type: 1,
  53. title: '捐助页面',
  54. closeBtn:0,
  55. anim: 2,
  56. area: [Number(document.body.clientWidth/2)+"px",Number(document.body.clientHeight*0.9)+"px"],
  57. shadeClose: false,
  58. offset: 'auto', // 居中显示
  59. skin: 'layui-layer-demo', // 无背景色
  60. content: `
  61. <div id = "donatediv">
  62. <img src="https://greasyfork.org/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsiZGF0YSI6ODY4NDIsInB1ciI6ImJsb2JfaWQifX0=--418d35c0003c67ad7cf985d685e9444fda96190a/jdd803evdr4tdkqp78jk2afo27z6.png?locale=zh-CN" style="max-width: 50%; display: block; margin: 0 auto;"/>
  63. <div style="text-align: center; margin: 10px;">
  64. <p style="text-align: center; margin: 10px;">如果脚本对你有帮助,可以捐助我一瓶快乐水</p>
  65. <p style="text-align: center; margin: 10px;">有了快乐水,我就可以写出更多对你有帮助的脚本</p>
  66. <button onclick="kaka_has_donate();" style="padding: 5px 10px; background-color: #50a82b; color: #fff; border: none; margin-left: 10px; border-radius: 5px;">我已捐助^_^</button>
  67. <button onclick="kaka_not_donate();" style="padding: 5px 10px; background-color: #dc3545; color: #fff; border: none; margin-left: 10px; border-radius: 5px;">我不想捐助</button>
  68. </div>
  69. </div>
  70. `,
  71. });
  72. }
  73. }
  74.  
  75. function click_course(){
  76. //查找并点击需要学习的课程
  77. for(let i of document.querySelectorAll(".item[data-resource-id]")){
  78. let status = i.querySelector(".operation").innerText
  79. let name = i.querySelector(".name-des").innerText
  80. if(/(继续学习)|(开始学习)/.test(status)){
  81. GM_setValue("doing",{"name":name,"time":new Date().getTime(),"status":status})
  82. i.click()
  83. return true
  84. }
  85. }
  86. return false
  87. }
  88. if(donate_flag){
  89. if(/study\/subject\/detail/.test(window.location.href)){
  90. // 课程主页,在当前页面实现控制做哪些课程
  91. new ElegantAlertBox("初始化中,请等待>__<")
  92. setInterval(function(){
  93. let doing_item = GM_getValue("doing")
  94. let next_flag = false
  95. if(new Date().getTime()-doing_item.time>1000*20){
  96. //超过20s没有更新状态视为过期
  97. next_flag = true
  98. new ElegantAlertBox("准备开始新的课程>__<")
  99. }else{
  100. next_flag = false
  101. new ElegantAlertBox("貌似有课程正在观看,检查中,请等待>__<")
  102. }
  103.  
  104. if (next_flag){
  105. if(click_course() ){
  106. //有需要做的课程,已经点击
  107. new ElegantAlertBox("已打开新的学习页面学习>__<")
  108. }else{
  109. new ElegantAlertBox("找不到需要学习的内容>__<")
  110. }
  111. }
  112. },5000)
  113. }else if(/study\/course\/detail/.test(window.location.href)){
  114. //视频播放页,做完后给主页一个标志,结束标签页
  115. new ElegantAlertBox("检查中,请等待>__<")
  116. setInterval(function(){
  117. let name = document.querySelector("div.title-row > div")
  118. if(name){
  119. name = name.innerText
  120. }else{return}
  121. GM_setValue("doing",{"name":name,"time":new Date().getTime(),"status":"学习中"})
  122. let state = document.querySelector("dl.focus > div.chapter-right > div.section-item.section-item11 > div:nth-child(3) > span")
  123. state = state?state.innerText:null
  124. if(state == "已完成"){
  125. new ElegantAlertBox("准备播放下一个视频>__<")
  126. let courses = document.querySelectorAll("dl")
  127. for(let i of courses){
  128. if(i.querySelector("div.chapter-right > div.section-item.section-item11 > div:nth-child(3) > span").innerText != "已完成"){
  129. i.click()
  130. return
  131. }
  132. }
  133. new ElegantAlertBox("全部学习完>__<")
  134. GM_setValue("doing",{"name":name,"time":new Date().getTime()-1000*30,"status":"已完成"})
  135. GM_setValue(name,{"name":name,"time":new Date().getTime()-1000*30,"status":"已完成"})
  136. window.close()
  137. }else{
  138. new ElegantAlertBox("还没有学习完 >__<")
  139. if(document.querySelector(".register-mask-layer") && 'display: none;' != document.querySelector(".register-mask-layer").getAttribute("style")){
  140. document.querySelector("#D210registerMask").click()
  141. }
  142. document.querySelector("video").muted="muted"
  143. document.querySelector("button.vjs-big-play-button").click() //开始播放的按钮
  144. }
  145.  
  146. },5000)
  147. }
  148. }
  149. })();