txkt-automation

有小伙伴提到这个功能,正好我自己也会用到,就整了。用于腾讯课堂的自动签到

  1. // ==UserScript==
  2. // @name txkt-automation
  3. // @namespace http://meethigher.top/blog/2020/txkt-automation/
  4. // @version 12.5
  5. // @description 有小伙伴提到这个功能,正好我自己也会用到,就整了。用于腾讯课堂的自动签到
  6. // @author Kit Chen
  7. // @match https://ke.qq.com/webcourse/index.html
  8. // @grant none
  9. // @提示 如果使用过程中出现问题,清除一下cookie就行,不用清除浏览器的所有数据,清除cookie就行
  10. // @license zhengtongxue
  11. // ==/UserScript==
  12. (function() {
  13. 'use strict';
  14. function autoAttend() {
  15. let btns;
  16. let attend = setInterval(function() {
  17. btns = document.getElementsByClassName("s-btn s-btn--primary s-btn--m");
  18. if (btns.length > 0) {
  19. console.log(new Date().toLocaleTimeString() + "--完成-->" + btns[0].innerText);
  20. btns[0].click();
  21. }
  22. }, 10000);
  23. }
  24. function showBtn() {
  25. let $switch = document.createElement("span");
  26. let $body = document.querySelector(".web");
  27. let show = true;
  28. $switch.innerText = "显示/隐藏";
  29. $switch.style = "position:absolute;top:21px;right:520px;color:#AAAAAA;border-radius:10px;cursor:pointer;z-index:3000";
  30. $switch.onclick = function() {
  31. if (show) {
  32. document.querySelector(".study-body.mr").style = "right:0;z-index:999";
  33. show = false;
  34. } else {
  35. document.querySelector(".study-body.mr").style = "right:300px;z-index:0";
  36. show = true;
  37. }
  38. }
  39. $body.appendChild($switch);
  40. }
  41. function clearRefresh() {
  42. window.localStorage.removeItem("refresh");
  43. }
  44. function autoRefresh() {
  45. window.localStorage.setItem("refresh", "no");
  46. let response = prompt("请输入上课时间的前2分钟,并点击确定按钮开始执行自动刷新!", "13:28");
  47. if (response !== null) {
  48. let arr = response.trim().split(":");
  49. let date;
  50. let timid = setInterval(function() {
  51. date = new Date();
  52. if (date.getHours() == parseInt(arr[0]) && date.getMinutes() == parseInt(arr[1])) {
  53. window.location.reload();
  54. }
  55. }, 1000);
  56. } else {
  57. clearRefresh();
  58. }
  59. }
  60. function isRefresh() {
  61. let isRefresh = window.localStorage.getItem("refresh") || "yes";
  62. console.log(isRefresh);
  63. if (isRefresh == "yes") {
  64. autoRefresh();
  65. } else {
  66. clearRefresh();
  67. }
  68. }
  69. isRefresh();
  70. autoAttend();
  71. showBtn();
  72. })();

QingJ © 2025

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