顺德教师在线研修系统学习助手

2020年顺德区2020年中小学(幼儿园)教师专业科目网络培训

  1. // ==UserScript==
  2. // @name 顺德教师在线研修系统学习助手
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.12
  5. // @description 2020年顺德区2020年中小学(幼儿园)教师专业科目网络培训
  6. // @author longlong
  7. // @match http://zy.jsyx.sdedu.net/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. var option = document.createElement("div");
  13. option.style="background-size: 100%; width: 90px; height: 90px; border-radius: 45px;position:fixed;left:60px;top:200px; z-index:999;"
  14. //添加点击事件
  15. //option.setAttribute("onClick","StartOrStop()");
  16. //option.setAttribute("onclick",function(){StartOrStop()});
  17. option.setAttribute("id","rains");
  18. option.innerText = "开关";
  19. document.body.insertBefore(option, document.body.firstElementChild);
  20. var timer;
  21. var flag=0;
  22. var flag1=0;
  23. var nexttime=0;
  24. var chongfutime=0;
  25. var startstatus = 0;
  26. var next_elapsed_time="00:00";
  27. //次数
  28. var number = 0;
  29. var playtime=2000;
  30. //获取当前活动
  31. //var NowAction=NowFun
  32. //setInterval(start, 3000); //每5秒钟执行一次
  33. document.getElementById("rains").addEventListener("click", StartOrStop);
  34. StartOrStop()
  35. function StartOrStop(){
  36. //获取播放状态
  37. var play = document.getElementsByClassName("fp-play")[0];
  38. if (startstatus == 0){
  39. //开始脚本
  40. timer = setInterval(start, 3000);
  41. //点击开始按钮
  42. play.click();
  43. startstatus = 1;
  44. var rains = document.getElementById("rains");
  45. rains.innerText = "已开";
  46. rains.style.color = "white";
  47. flag1=1
  48. }else if (startstatus == 1) {
  49. //停止脚本
  50. clearInterval(timer);
  51. //已经播放 暂停播放
  52. play.click();
  53. startstatus = 0;
  54. var rains = document.getElementById("rains");
  55. rains.innerText = "已关";
  56. rains.style.color = "red";
  57. flag1=0
  58. }
  59. }
  60. function start(){
  61. if(number % 200 == 0){
  62. console.clear();
  63. }
  64. number += 1;
  65. //首先判断是否播放状态,暂停则点播放
  66. if(playorpause()=="pause"){
  67. document.getElementsByClassName("fp-play")[0].click();
  68. }
  69. //如果没有已看分钟数,说明不是视频页,直接点击下一节
  70. if (document.getElementsByClassName("fp-elapsed")[0]!=null){
  71. next_elapsed_time = document.getElementsByClassName("fp-elapsed")[0].innerText; //有分钟数,则得到已看分钟数
  72. }else{
  73. document.getElementsByClassName("btn next crt")[0].click(); //点击下一节
  74. nexttime=nexttime+1; //计个数,没什么用
  75. console.log(flag1+"ddd");
  76. }
  77. //获取播放进度
  78. if (playtime==parseInt(document.getElementsByClassName("fp-progress")[0].style.width)){
  79. //点击播放
  80. }
  81. playtime=parseInt(document.getElementsByClassName("fp-progress")[0].style.width)
  82. //console.log(playtime,document.getElementsByClassName("fp-progress")[0].style.width)
  83.  
  84. //获取进度条、需要时间、已看时间
  85. var mubiaotime=document.getElementsByClassName('g-study-prompt')[0].innerText
  86. let numArr = mubiaotime.match(/\d+/g);
  87. if (document.getElementById("viewTimeTxt")!=null){
  88. var areadytime=document.getElementById("viewTimeTxt");
  89. }else{
  90. document.getElementsByClassName("btn next crt")[0].click();
  91. nexttime=nexttime+1;
  92. }
  93.  
  94. //获取答题框状态
  95. var dialog = document.getElementsByClassName("mylayer-btn mylayer-btn3 type0")[0];
  96. //点击关闭按钮关闭答题框
  97. if(dialog != undefined){
  98. console.log("发现有对话框,关闭之");
  99. //document.getElementsByClassName("mylayer-btn mylayer-btn3 type0")[0].click();
  100. dialog.click();
  101. }
  102. //获取当前活动,如果下一节,活动名称是不一样的
  103. //判断播放进度是否完成
  104. if(areadytime.innerHTML >= parseInt(numArr[0])){
  105. //点击下一节
  106. if (flag==0){
  107. console.log("点击下一活动");
  108. document.getElementsByClassName("btn next crt")[0].click();
  109. console.log(flag1+"eee");
  110. nexttime=nexttime+1;
  111. flag=1;
  112. }
  113. //获取当前活动,如果下一节,活动名称是不一样的
  114. }
  115. //这是已播放时间
  116. console.log("执行第"+ number + "次,已看了"+ nexttime+ "节");
  117. }
  118. function playorpause(){ //判断播放状态
  119. if (document.getElementById("player")!=null){ //如果存在视频播放器,有些页面是文档,没有视频
  120. if(document.getElementById("player").className.indexOf("is-paused")!=-1){ //播放状态,不等于-1是暂停状态
  121. return "pause"
  122. }else{return "play"}
  123. }else{return "false"}
  124. }
  125. })();