🚀云班课一键完成所有资源🚀

咕咚,蓝墨云都消失不见了,我大学生涯还没过完呢!!!我还得陪伴云班课数年!!!没有他们我该怎么办!!!不行!!!我得自力更生!!!自己动手写一个!!!

  1. // ==UserScript==
  2. // @name 🚀云班课一键完成所有资源🚀
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1.1
  5. // @description 咕咚,蓝墨云都消失不见了,我大学生涯还没过完呢!!!我还得陪伴云班课数年!!!没有他们我该怎么办!!!不行!!!我得自力更生!!!自己动手写一个!!!
  6. // @author Handsomedog
  7. // @match https://www.mosoteach.cn/web/index.php?c=res&m=index&clazz_course_id=*
  8. // @icon
  9. // @grant GM_addStyle
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. var courseId = document.getElementsByName("clazz_course_id")[0].value//课程ID
  14. var res = $('div[data-mime]')//文件数组
  15. var finished = $('span[data-is-drag]')//文件完成情况
  16. var box = document.getElementsByClassName("create-box manual-order-hide-part")//视频的盒子
  17. var studyres = document.getElementsByClassName("study-res")[0].children[0].innerHTML//已学习的资源
  18. var totalres = document.getElementsByClassName("total-res")[0].children[0].innerHTML//总共的资源
  19. var leaveres = totalres - studyres//剩余资源数
  20. var deepen = 0
  21. var nowdeep = 0
  22. $("#cc-main").append('<div class="progress"><div class="progressBar"><span class="progressBar-value">一键完成所有资源</span></div></div>')
  23. GM_addStyle(".progress {position: absolute;right:20px;top: 75px;width: 180px;height: 25px;background: #e5e5e5;border-radius: 4px;overflow: hidden;cursor:pointer;}")
  24. GM_addStyle(".progressBar { width: 180px; height: 100%; display: flex; justify-content: center; align-items: center; background: cornflowerblue; background-image: linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);background-size: 40px 40px;transition: width .6s ease;border-radius: 4px;animation: progressBar 2s linear infinite;}")
  25. GM_addStyle(".progressBar-value { font-size: 13px; font-weight: bold; color: white; margin-right: 0px;}")
  26. GM_addStyle("@keyframes progressBar { from { background-position: 40px 0; } to { background-position: 0 0; }}")
  27. var progressBar = document.getElementsByClassName("progressBar")[0]
  28. var progressBarValue = document.getElementsByClassName("progressBar-value")[0]
  29. if (leaveres == 0) {
  30. progressBarValue.innerHTML = `很厉害哦,所有资源都完成啦!!!`
  31. progressBar.style.cursor = "default"
  32. }
  33. $(".progress").click(function () {
  34. if (leaveres > 0) {
  35. deepen = (100 / leaveres).toFixed(1)
  36. progressBarValue.innerHTML = `进度:0%`
  37. progressBar.style.width = '80px'
  38. progressBar.style.justifyContent = 'flex-end'
  39. progressBarValue.style.marginRight = '5px'
  40. } else {
  41. return
  42. }
  43. setTimeout(function () {
  44. for (let i = 0; i < res.length; i++) {
  45. let type = res[i].getAttribute("data-mime")
  46. let value = res[i].getAttribute("data-value")
  47. let finish = finished[i * 2].getAttribute("data-is-drag")
  48. if (finish === 'N') {
  49. if (type === 'video') {
  50. let time = box[i].children[4].innerHTML
  51. let hour = time.substring(0, 2)
  52. let minute = time.substring(3, 5)
  53. let second = time.substring(6, 8)
  54. let alltime = Number(hour * 60 * 60) + Number(minute * 60) + Number(second)
  55. //console.log(hour, minute, second);
  56. //console.log(type, value, finish, alltime);
  57. getVideo(value, alltime)
  58. } else {
  59. getResource(value)
  60. }
  61. }
  62. }
  63. }, 500)
  64. })
  65.  
  66. function getResource (value) {
  67. $.ajax({
  68. type: 'head',
  69. url: 'index.php?c=res&m=online_preview&clazz_course_id=' + courseId + '&file_id=' + value,
  70. complete: function (res) {
  71. leaveres -= 1
  72. if (leaveres <= 0) {
  73. progressBarValue.innerHTML = `进度:100%`
  74. progressBar.style.width = '180px'
  75. location.reload()
  76. } else {
  77. nowdeep = getNowDeep(nowdeep)
  78. progressBar.style.width = Number(nowdeep) + 80 + 'px'
  79. progressBarValue.innerHTML = `进度:${nowdeep}%`
  80. }
  81.  
  82.  
  83. }
  84. });
  85. }
  86.  
  87. function getVideo (value, alltime) {
  88. $.ajax({
  89. type: 'post',
  90. dataType: 'json',
  91. url: 'index.php?c=res&m=save_watch_to',
  92. data: {
  93. clazz_course_id: courseId,
  94. res_id: value, //当前观看视频资源的id
  95. watch_to: alltime, //假数据
  96. duration: alltime,
  97. current_watch_to: 0 //假数据
  98. },
  99. success: function (res) {
  100. leaveres -= 1
  101. if (leaveres <= 0) {
  102. progressBarValue.innerHTML = `进度:100%`
  103. progressBar.style.width = '180px'
  104. location.reload()
  105. } else {
  106. nowdeep = getNowDeep(nowdeep)
  107. progressBar.style.width = Number(nowdeep) + 80 + 'px'
  108. progressBarValue.innerHTML = `进度:${nowdeep}%`
  109. }
  110.  
  111. },
  112. erorr: function (res) {
  113. console.log("不知道什么原因,视频观看失败!请到greasyfork反馈一下!");
  114. }
  115. });
  116. }
  117. function getNowDeep (nowdeep) {
  118. nowdeep = (Number(nowdeep) + Number(deepen)).toFixed(1)
  119. if (nowdeep >= 100 - deepen) {
  120. nowdeep = 100
  121. } else if (nowdeep - Math.floor(nowdeep) >= 0.5) {
  122. nowdeep = Math.ceil(nowdeep)
  123. }
  124. //console.log(nowdeep);
  125. return nowdeep
  126. }
  127. })();