雨课堂题目提醒,腾讯课堂签到提醒

雨课堂题目检测,课堂答题后返回正确答案,腾讯课堂检测签到,弹窗提醒(所有提醒浏览器最小化也会生效)。禁止网页通知的刷新页面会重新要求权限,还不行可以自行百度“网页通知权限”。

  1. // ==UserScript==
  2. // @name 雨课堂题目提醒,腾讯课堂签到提醒
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0.0
  5. // @description 雨课堂题目检测,课堂答题后返回正确答案,腾讯课堂检测签到,弹窗提醒(所有提醒浏览器最小化也会生效)。禁止网页通知的刷新页面会重新要求权限,还不行可以自行百度“网页通知权限”。
  6. // @author bzg
  7. // @match *://*.yuketang.cn/*
  8. // @match *://ke.qq.com/webcourse*
  9. // @grant GM_getValue
  10. // @grant GM_setValue
  11. // @grant GM_registerMenuCommand
  12. // @grant GM_addStyle
  13. // @grant GM.setClipboard
  14. // @license MIT
  15. // ==/UserScript==
  16. (function() {
  17. 'use strict';
  18. GM_registerMenuCommand("查看已提醒次数", function() {
  19. alert("已提醒次数:" + (GM_getValue("remind_times") || 0))
  20. });
  21. // let tag = document.createElement('div');
  22. // tag.id = "myDiv";
  23. // tag.innerHTML = `<div style="height: 100px; width: 100px;background: blue;top: 0px;"><p>test</p></div>`;
  24. // document.body.appendChild(tag);
  25.  
  26. var status = true,
  27. shine = false,
  28. titleInit = "课堂"
  29. window.onload = function() {
  30. titleInit = document.title
  31. // 判断是否支持提醒
  32. if (window.Notification) {
  33. var permission = Notification.permission;
  34. if (permission === 'granted') {} else {
  35. Notification.requestPermission().then(function(permission) {
  36. console.log('用户是否允许通知: ', permission === 'granted' ? '允许' : '拒绝');
  37. });
  38. }
  39. } else {
  40. alert('你的浏览器不支持此消息提示功能,请使用chrome内核的浏览器!')
  41. }
  42. if (location.href.match(/ke.qq.com/)) {
  43. tencent_course();
  44. }
  45. if (location.href.match(/yuketang.cn/)) {
  46. rainingRoom();
  47. }
  48. }
  49. window.onfocus = function() {
  50. status = false;
  51. shine = false;
  52. };
  53. window.onblur = function() {
  54. status = true;
  55. shine = true;
  56. document.title = titleInit;
  57. };
  58. // for IE
  59. document.onfocusin = function() {
  60. status = false;
  61. shine = false;
  62. };
  63. document.onfocusout = function() {
  64. status = true;
  65. shine = true;
  66. document.title = titleInit;
  67. };
  68. //腾讯课堂签到
  69. function tencent_course() {
  70. var tencent_monitor = setInterval(function test() {
  71. var tencent_node = document.getElementsByClassName("sign-dialog")
  72. if (!tencent_node.length) {
  73. // console.log("no sign")
  74. return;
  75. }
  76. // 标签闪动
  77. if (shine) {
  78. var title = document.title;
  79. if (/HXDM/.test(title) === false) {
  80. document.title = '【HXDM】';
  81. } else {
  82. document.title = '【come back】';
  83. }
  84. }
  85. // 腾讯课堂签到提醒
  86. if (status) {
  87. var sign_notice = new Notification('腾讯课堂', {
  88. body: "hxdm,签到了!!!",
  89. icon: "https://lh3.googleusercontent.com/proxy/N6c9yyNg5g3Si-bkRNwbWt6FxVK-Xmra7uuqgHHwEiqrJb0xQc6pMLEH_SGOxwRDhxkB5XbekwR-i5ng1XORK13TCjk1il2uu5mx_gUZce867N5Rjis_"
  90. });
  91. sign_notice.onerror = function(err) {
  92. alert("显示通知出错,请认真听课!!!", err)
  93. console.log(err);
  94. };
  95. GM_setValue('remind_times', (GM_getValue('remind_times') || 0) + 1);
  96. status = false
  97. console.log("HXDM", GM_getValue('remind_times'))
  98. }
  99. }, 1000)
  100. }
  101. // 雨课堂题目提醒
  102. function rainingRoom() {
  103. var raining_monitor = setInterval(function test() {
  104. // 三层保险
  105. var rain_1 = document.getElementsByClassName("pl10 f16 cfff")
  106. var rain_2 = document.getElementsByClassName("box-start")
  107. var rain_3 = document.getElementsByClassName("submit-btn f18").length != 0 ? document.getElementsByClassName("submit-btn f18")[0] : { innerHTML: "none" }
  108. // 标签闪动
  109. if ((rain_1.length || rain_2.length || rain_3.innerHTML == "提交答案") && shine) {
  110. var title = document.title;
  111. if (/HXDM/.test(title) === false) {
  112. document.title = '【HXDM】';
  113. } else {
  114. document.title = '【come back】';
  115. }
  116. } else {
  117. return;
  118. }
  119. // 雨课堂做题提醒
  120. if (status) {
  121. var notification = new Notification('雨课堂', {
  122. body: "hxdm,有习题!!!",
  123. icon: "https://lh3.googleusercontent.com/proxy/N6c9yyNg5g3Si-bkRNwbWt6FxVK-Xmra7uuqgHHwEiqrJb0xQc6pMLEH_SGOxwRDhxkB5XbekwR-i5ng1XORK13TCjk1il2uu5mx_gUZce867N5Rjis_"
  124. });
  125. notification.onclick = function() {
  126. console.log('onclick');
  127. };
  128. notification.onerror = function(err) {
  129. alert("显示通知出错,请认真听课!!!", err)
  130. console.log(err);
  131. };
  132. notification.onclose = function() {
  133. console.log("close")
  134. }
  135. GM_setValue('remind_times', (GM_getValue('remind_times') || 0) + 1);
  136. console.log("HXDM", GM_getValue('remind_times'))
  137. status = false
  138. }
  139. }, 1000)
  140. XMLHttpRequest.prototype.send = new Proxy(XMLHttpRequest.prototype.send, {
  141. "apply": (target, thisArg, args) => {
  142. thisArg.addEventListener(
  143. "load", event => {
  144. const result = JSON.parse(event.target.responseText);
  145. // console.log("this:", result.data.answer)
  146. if (!result.data) { return; }
  147. if (result.data.answer) {
  148. var answer = result.data.answer,
  149. temp = [],
  150. temp2 = ""
  151. if (typeof(answer) == "object") {
  152. temp = answer;
  153. answer = "";
  154. for (var i = 0, len = Object.keys(temp).length, key = Object.keys(temp); i < len; i++) {
  155. for (var j = 0, len2 = temp[key[i]].length; j < len2; j++) {
  156. temp2 = temp2 + temp[key[i]][j] + "/"
  157. console.log(temp2)
  158. }
  159. answer = answer + '_' + (i + 1) + '_' + temp2
  160. // console.log(temp[key[i]].length,answer, temp2)
  161. temp2 = ""
  162. }
  163. }
  164. // console.log(answer)
  165. if (confirm(`正确答案是【${answer}】,得分【${result.data.score}】,是否复制正确答案?`)) {
  166. GM.setClipboard(answer);
  167. // var textArea = document.createElement('textarea');
  168. // textArea.style.position = 'fixed';
  169. // textArea.style.top = '10000000px';
  170. // textArea.value = answer;
  171. // document.body.appendChild(textArea);
  172. // textArea.select();
  173. // try {
  174. // document.execCommand('copy');
  175. // } catch (err) {
  176. // alert('该浏览器不支持点击复制到剪贴板');
  177. // }
  178. // document.body.removeChild(textArea);
  179. }
  180. }
  181. })
  182. return target.apply(thisArg, args);
  183. }
  184. })
  185. }
  186. // Your code here...
  187. })();

QingJ © 2025

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