2025年寒假教师研修|国家智慧教育公共服务平台|国家中小学智慧教育平台|自动刷视频

国家智慧教育公共服务平台(国家中小学智慧教育平台)自动刷视频!!!

  1. // ==UserScript==
  2. // @name 2025年寒假教师研修|国家智慧教育公共服务平台|国家中小学智慧教育平台|自动刷视频
  3. // @namespace http://tampermonkey.net/
  4. // @version 2025.01.26
  5. // @description 国家智慧教育公共服务平台(国家中小学智慧教育平台)自动刷视频!!!
  6. // @author yygdz1921
  7. // @match https://www.smartedu.cn/*
  8. // @match https://basic.smartedu.cn/*
  9. // @match https://smartedu.gdtextbook.com/education/*
  10. // @icon https://www.google.com/s2/favicons?sz=64&domain=smartedu.cn
  11. // @require https://fastly.jsdelivr.net/npm/sweetalert2@11.12.4/dist/sweetalert2.all.min.js
  12. // @resource css https://fastly.jsdelivr.net/npm/sweetalert2@11.12.4/dist/sweetalert2.min.css
  13. // @grant GM_addStyle
  14. // @grant GM_getResourceText
  15. // @run-at window-load
  16. // @license MIT
  17. // ==/UserScript==
  18.  
  19. (function () {
  20. 'use strict';
  21.  
  22. // Your code here...
  23. // 引入第三方库https://github.com/sweetalert2/sweetalert2/
  24. GM_addStyle(GM_getResourceText("css"));
  25. // 弹窗函数
  26. function msg(txt, ms = 3000) {
  27. Swal.fire({
  28. html: txt,
  29. position: "center",
  30. icon: "success",
  31. showConfirmButton: false,
  32. timer: ms,
  33. timerProgressBar: true,
  34. })
  35. }
  36. var log = console.log;
  37. // 课程
  38. var course_name = "2025年寒假教师研修";
  39. var home = "https://basic.smartedu.cn/training/2025hjpx";
  40. var course_url = [
  41. // 学习贯彻全国教育大会精神
  42. "https://basic.smartedu.cn/teacherTraining/courseDetail?courseId=2c5f7bc2-699a-4433-b650-b5e554ed15e3&tag=2025%E5%B9%B4%E5%AF%92%E5%81%87%E6%95%99%E5%B8%88%E7%A0%94%E4%BF%AE&channelId=&libraryId=bb042e69-9a11-49a1-af22-0c3fab2e92b9&breadcrumb=2025%E5%B9%B4%E5%AF%92%E5%81%87%E6%95%99%E5%B8%88%E7%A0%94%E4%BF%AE",
  43. // 深化教育综合改革
  44. "https://basic.smartedu.cn/teacherTraining/courseDetail?courseId=4b35be2e-b78c-474b-9e27-85a0bb5757bf&tag=2025%E5%B9%B4%E5%AF%92%E5%81%87%E6%95%99%E5%B8%88%E7%A0%94%E4%BF%AE&channelId=&libraryId=bb042e69-9a11-49a1-af22-0c3fab2e92b9&breadcrumb=2025%E5%B9%B4%E5%AF%92%E5%81%87%E6%95%99%E5%B8%88%E7%A0%94%E4%BF%AE",
  45. // 推进教育国际交流合作
  46. "https://basic.smartedu.cn/teacherTraining/courseDetail?courseId=5a72caa9-d09e-4af1-be30-7d970c125038&tag=2025%E5%B9%B4%E5%AF%92%E5%81%87%E6%95%99%E5%B8%88%E7%A0%94%E4%BF%AE&channelId=&libraryId=bb042e69-9a11-49a1-af22-0c3fab2e92b9&breadcrumb=2025%E5%B9%B4%E5%AF%92%E5%81%87%E6%95%99%E5%B8%88%E7%A0%94%E4%BF%AE",
  47. ]
  48. // 上述配置的课程,分别学习多少课时(看多少个视频),因为认定学时有限,每个课程不用刷完!!!
  49. // 配置-1为学完当前课程的所有视频
  50. var lessons = [9, 6, 4];
  51.  
  52.  
  53. function next() {
  54. var href = window.location.href;
  55. var index = course_url.indexOf(href);
  56. if (index > -1) {
  57. if (index + 1 < course_url.length) {
  58. window.location.href = course_url[index + 1];
  59. } else {
  60. window.location.href = home;
  61. }
  62. } else {
  63. window.location.href = course_url[0];
  64. }
  65. }
  66.  
  67.  
  68. function click(auto_next = true) {
  69. // 判读是否满足学时要求
  70. if (lessons) {
  71. var href = window.location.href;
  72. var index = course_url.indexOf(href);
  73. var lesson = lessons[index];
  74. if (lesson != undefined && lesson != -1) {
  75. let headers = document.getElementsByClassName("fish-collapse-header");
  76. for (let i = 0; i < headers.length; i++) {
  77. let header = headers[i];
  78. header.click();
  79. }
  80. let finish = document.getElementsByClassName("iconfont icon_checkbox_fill");
  81. log(`当前页面已经学完【${finish.length}】个视频,学时要求为【${lesson}】个视频,是否达标:${finish.length >= lesson}`);
  82. if (finish.length >= lesson) {
  83. next();
  84. }
  85. }
  86. }
  87. var icon = null;
  88. function find_icon() {
  89. // 进行中
  90. icon = document.getElementsByClassName("iconfont icon_processing_fill")[0];
  91. // 未开始
  92. if (!icon) {
  93. icon = document.getElementsByClassName("iconfont icon_checkbox_linear")[0];
  94. }
  95. }
  96. // 查找默认列表
  97. find_icon();
  98. // 展开其他列表
  99. if (!icon) {
  100. let headers = document.getElementsByClassName("fish-collapse-header");
  101. for (let i = 0; i < headers.length; i++) {
  102. let header = headers[i];
  103. header.click();
  104. find_icon();
  105. if (icon) {
  106. break;
  107. }
  108. }
  109. }
  110. // 有没学完的
  111. if (icon) {
  112. icon.click();
  113. } else {
  114. if (auto_next) {
  115. next();
  116. } else {
  117. Swal.fire("当前页面所有视频已经播放完!", "", "success");
  118. }
  119. }
  120. }
  121.  
  122.  
  123. function play(v = null) {
  124. if (!v) {
  125. v = document.getElementsByTagName("video")[0];
  126. }
  127. if (v) {
  128. //v.dispatchEvent(new Event("ended"));
  129. v.muted = true;
  130. //v.playbackRate = 2;
  131. v.play();
  132. //v.currentTime = v.duration;
  133. }
  134. log(`play: v==>${v}`);
  135. // 关闭提示(必须完整看完整个视频才可以获得该视频的学时。)
  136. let btn = document.getElementsByClassName("fish-btn fish-btn-primary")[0];
  137. if (btn && btn.innerText.includes("知道了")) {
  138. btn.click();
  139. log(`关闭提示: btn==>${btn}`);
  140. }
  141. }
  142.  
  143. var pageNumber = null;
  144. var pageCount = null;
  145. function read() {
  146. log(`PDF文档阅读: pageNumber==>${pageNumber}, pageCount==>${pageCount}`);
  147. if (pageCount) {
  148. var pc = pageCount;
  149. // 最后一页
  150. log("PDF文档跳到最后一页:", pc);
  151. window.postMessage({
  152. type: "pdfPlayerPageChangeing",
  153. data: {
  154. pageNumber: pc,
  155. pageCount: pc,
  156. }
  157. }, "*");
  158. // 第一页
  159. setTimeout(function () {
  160. log("PDF文档调到第一页...");
  161. window.postMessage({
  162. type: "pdfPlayerPageChangeing",
  163. data: {
  164. pageNumber: 1,
  165. pageCount: pc,
  166. }
  167. }, "*");
  168. }, 1000);
  169. // 重置
  170. pageCount = null;
  171. }
  172. }
  173.  
  174.  
  175. // 答题
  176. function answer() {
  177. let count = 0;
  178. const intervalId = setInterval(() => {
  179. log("自动答题检测...");
  180. // 选A
  181. var a = document.getElementsByClassName("nqti-check")[0];
  182. if (a) {
  183. a.click();
  184. // 下一题、确定
  185. for (let i = 0; i < 2; i++) {
  186. var btn = document.querySelector("div.index-module_footer_3r1Yy > button");
  187. if (btn) {
  188. btn.click();
  189. }
  190. }
  191. }
  192. count++;
  193. if (count === 3) {
  194. clearInterval(intervalId);
  195. }
  196. }, 1000);
  197. }
  198.  
  199.  
  200. // 广东特色
  201. function gd_class() {
  202. let ms = 10000;
  203. msg("欢迎进入“2024年广东暑期教师研修”专题。", ms = ms);
  204. let tid = setInterval(function() {
  205. let all_finish = true;
  206. let flags = document.getElementsByClassName("flag");
  207. for(let i = 0; i < flags.length; i++){
  208. let flag = flags[i];
  209. let display = flag.getElementsByClassName("icon-finish inline-block")[0].style.display
  210. if (display === "none"){
  211. all_finish = false;
  212. let v = document.getElementsByTagName("video")[0];
  213. if (v) {
  214. flag.click();
  215. setTimeout(function(){
  216. v = document.getElementsByTagName("video")[0];
  217. if (v){
  218. //v.playbackRate = 16;
  219. //v.play();
  220. v.currentTime = v.duration;
  221. }
  222. }, 3000);
  223. }
  224. break;
  225. }
  226. }
  227. if(all_finish){
  228. clearInterval(tid);
  229. msg("“2024年广东暑期教师研修”专题已学习完毕!", ms = ms * 10);
  230. }
  231. else {
  232. let p = document.getElementsByClassName("el-progress__text")[0].innerText;
  233. msg(`挂机中,当前进度【${p}】`, ms = ms);
  234. }
  235. }, ms);
  236. }
  237.  
  238.  
  239. function main() {
  240. log("main...");
  241. // 等待页面加载,延时开始
  242. var delay = 1000 * 10
  243. var href = window.location.href;
  244. if (course_url.includes(href)) {
  245. msg(`等待网页资源加载, 约【${delay / 1000}】秒后开始自动播放视频`, delay);
  246. setInterval(function () {
  247. click();
  248. play();
  249. read();
  250. answer();
  251. }, delay);
  252. } else if (href.includes(`https://smartedu.gdtextbook.com/education/`)) {
  253. log(`“2024年广东暑期教师研修”专题iframe的跨域处理`);
  254. } else {
  255. Swal.fire({
  256. //background: "#url(https://baotangguo.cn:8081/)",
  257. icon: "warning",
  258. title: "开始刷视频?",
  259. //text: "好好学习,天天向上!",
  260. /*
  261. html: `<button id="myButton1" class="swal2-confirm swal2-styled" style="width: 450px;">国家中小学智慧教育平台应用专项培训<br>(“2024年广东暑期教师研修”专题)<br>进入视频播放页后按键盘【G】</button>`,
  262. willOpen: () => {
  263. // 添加事件监听器
  264. const button1 = Swal.getHtmlContainer().querySelector('#myButton1');
  265. button1.addEventListener("click", () => {
  266. Swal.fire(`进入视频播放页后按键盘【G】`);
  267. });
  268. },
  269. */
  270. showDenyButton: true,
  271. showCancelButton: true,
  272. confirmButtonColor: "green",
  273. confirmButtonText: `<div style="width: 450px;">刷脚本配置的课程,当前为:<br><b>${course_name}</b></div>`,
  274. denyButtonColor: "blue",
  275. denyButtonText: '<div style="width: 450px;">只刷当前页的视频</div>',
  276. cancelButtonColor: "red",
  277. cancelButtonText: '<div style="width: 450px;">退出</div>',
  278. }).then((result) => {
  279. /* Read more about isConfirmed, isDenied below */
  280. if (result.isConfirmed) {
  281. msg("走你~");
  282. next();
  283. } else if (result.isDenied) {
  284. msg(`【${delay / 1000}】秒后开始自动播放视频`, delay);
  285. setInterval(function () {
  286. click(false);
  287. play();
  288. read();
  289. answer();
  290. }, delay);
  291. }
  292. })
  293. }
  294. }
  295.  
  296.  
  297. if (document.readyState === "complete") {
  298. // DOM 已经加载完成
  299. main();
  300. } else {
  301. // DOM 还未加载完成
  302. window.addEventListener("load", main);
  303. }
  304. document.addEventListener("keydown", function (event) {
  305. log("keydown", event.code);
  306. if (event.code === "KeyG") {
  307. gd_class();
  308. } else if (event.code === "KeyT") {
  309. msg("测试");
  310. }
  311. });
  312. window.addEventListener("message", function (event) {
  313. log("message", event);
  314. var data = event.data;
  315. log("data.type==>", data.type);
  316. if (data.type === "pdfPlayerInitPage") {
  317. pageNumber = data.data.pageNumber;
  318. pageCount = data.data.pageCount;
  319. log(`PDF文档初始化: pageNumber==>${pageNumber}, pageCount==>${pageCount}`);
  320. }
  321. });
  322. })();