传智自动播放视频

自动播放传智播客课程视频, 开发者博客:http://www.nothamor.cn

  1. // ==UserScript==
  2. // @name 传智自动播放视频
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1
  5. // @description 自动播放传智播客课程视频, 开发者博客:http://www.nothamor.cn
  6. // @author nothamor
  7. // @match *.ityxb.com/*
  8. // @homepage https://www.nothamor.cn/
  9. // @grant GM_xmlhttpRequest
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. console.log("欢迎使用传智自动播放插件, 作者博客:https://www.nothamor.cn");
  16. setTimeout(function() {
  17. let url = window.location.href;
  18. if(url.includes("http://stu.ityxb.com/writePaper/")) {
  19. auto_search();
  20. console.log("检测到为测试页面, 开始自动查询题目");
  21. }else if(url.includes("lookPaper")){
  22. auto_search();
  23. }else if(url.includes("http://stu.ityxb.com/preview/detail/")) {
  24. auto_play();
  25. console.log("检测到为视频播放页面, 开始自动播放视频");
  26. }
  27. }, 5000);
  28.  
  29. function auto_play() {
  30. const CLASS_LIST = document.getElementsByClassName("point-progress-box");
  31. const CLASS_NAME = document.getElementsByClassName("point-text ellipsis");
  32. let question_text = document.getElementsByTagName("pre")[0];
  33. let player = document.getElementsByTagName("video")[0].id;
  34. let question_text_value;
  35. document.getElementById(player).click();
  36. let counter = 0;
  37. const TIMER = setInterval(function () {
  38. let percent = CLASS_LIST[counter].innerHTML.replace(/\ +/g, "").replace(/[\r\n]/g, "");
  39. let title_name = CLASS_NAME[counter].innerHTML.replace(/\ +/g, "").replace(/[\r\n]/g, "");
  40. if (percent.includes("100%") && counter == (CLASS_LIST.length - 1)) {
  41. clearInterval(TIMER);
  42. alert("当前页面所有视频播放完成");
  43. } else if (percent.includes("100%")) {
  44. CLASS_LIST[counter + 1].click();
  45. player = document.getElementsByTagName("video")[0].id;
  46. document.getElementById(player).click();
  47. counter++;
  48. }
  49. if (title_name.includes("习题")) {
  50. question_text = document.getElementsByTagName("pre")[0];
  51. question_text_value = question_text.innerHTML;
  52. console.log(" ");
  53. GM_xmlhttpRequest({
  54. method: 'POST',
  55. url: 'http://cx.icodef.com/wyn-nb',
  56. headers: {
  57. 'Content-type': 'application/x-www-form-urlencoded',
  58. 'Authorization': '',
  59. },
  60. data: 'question=' + encodeURIComponent(question_text_value),
  61. onload: function (response) {
  62. if (response.status == 200) {
  63. let obj = $.parseJSON(response.responseText.replace(/^操作数据失败!/, '')) || {};
  64. console.log("题目:" + question_text_value + "的答案为:" + obj.data);
  65. }
  66. }
  67. });
  68. }
  69. }, 1000);
  70. }
  71. function auto_search() {
  72. const QUESTION = document.getElementsByTagName("pre");
  73. let counter = 0;
  74. const SEARCH = setInterval(function() {
  75. GM_xmlhttpRequest({
  76. method: 'POST',
  77. url: 'http://cx.icodef.com/wyn-nb',
  78. headers: {
  79. 'Content-type': 'application/x-www-form-urlencoded',
  80. 'Authorization': '',
  81. },
  82. data: 'question=' + encodeURIComponent(QUESTION[counter].innerHTML),
  83. onload: function (response) {
  84. if (response.status == 200) {
  85. let obj = $.parseJSON(response.responseText.replace(/^操作数据失败!/, '')) || {};
  86. console.log(QUESTION[counter].innerHTML + "的答案为:" + obj.data);
  87. counter++;
  88. }
  89. }
  90. });
  91.  
  92. if(counter == (QUESTION.length - 1)) {
  93. clearInterval(SEARCH);
  94. console.log("题目搜索完成");
  95. }
  96. }, 1000);
  97. }
  98. })();

QingJ © 2025

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