U校园增加时长(LuckyM)

生命短暂而美好,没时间纠结,没时间计较

目前为 2024-06-10 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name U校园增加时长(LuckyM)
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1.3
  5. // @description 生命短暂而美好,没时间纠结,没时间计较
  6. // @author handsometaoa
  7. // @match https://ucontent.unipus.cn/_pc_default/pc.html?cid=*
  8. // @grant none
  9. // @license GPL-3.0
  10. // @compatible chrome
  11. // ==/UserScript==
  12.  
  13. // 表示每个页面停留[minMinute分minSeconds秒,maxMinute分钟maxSeconds秒],可以自己设置
  14. var minMinute = 4; // 最小分钟
  15. var minSeconds = 30; // 最小秒数
  16. var maxMinute = 5; // 最大分钟
  17. var maxSeconds = 30; // 最大秒数
  18.  
  19. // 计算实际停留时间,防止每个页面停留时间相同
  20. function realTime() {
  21. let rate = Math.random();
  22. return (minMinute * 60 + minSeconds + ((maxMinute - minMinute) * 60 + maxSeconds - minSeconds) * rate) * 1000;
  23. }
  24.  
  25. // 自动点击必修弹窗和麦克风弹窗 3000表示延迟3秒,因为弹窗有延迟,主要看反应速度。
  26. setTimeout(() => {
  27. // 关闭必修提示弹窗
  28. var x = document.getElementsByClassName("dialog-header-pc--close-yD7oN");
  29. if (x.length > 0) {
  30. x[0].click();
  31. }
  32. var dialogHeader = document.querySelector("div.dialog-header-pc--dialog-header-2qsXD");
  33. if (dialogHeader) {
  34. dialogHeader.parentElement.querySelector('button').click();
  35. }
  36. }, 3000);
  37.  
  38. // 自动播放视频
  39. function playVideo() {
  40. var videos = document.querySelectorAll('video');
  41. videos.forEach(video => {
  42. video.play();
  43. });
  44. }
  45.  
  46. // 跳转下一节
  47. function switch_next(selector, classFlag) {
  48. let flag = false;
  49. for (let [index, unit] of document.querySelectorAll(selector).entries()) {
  50. if (flag) {
  51. unit.click();
  52. // 防止必修弹窗失效,跳转便刷新页面,1000表示跳转1秒后刷新页面
  53. setTimeout(() => {
  54. location.reload();
  55. }, 1000);
  56. flag = false;
  57. break;
  58. }
  59. if (unit.classList.contains(classFlag)) {
  60. flag = true;
  61. }
  62. }
  63. }
  64.  
  65. setTimeout(() => {
  66. playVideo();
  67. }, 4000); // 在页面加载后4秒开始播放视频
  68.  
  69. setTimeout(() => {
  70. switch_next('.layoutHeaderStyle--circleTabsBox-jQdMo a', 'selected');
  71. switch_next('#header .TabsBox li', 'active');
  72. switch_next('#sidemenu li.group', 'active');
  73. }, realTime());

QingJ © 2025

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