雨课堂视频回放插件

提升雨课堂视频回放体验,例如按A或S快进快退,按空格暂停,快放速率自定义,下载视频。

  1. // ==UserScript==
  2. // @name 雨课堂视频回放插件
  3. // @namespace http://bebr2.com/
  4. // @version 0.1
  5. // @description 提升雨课堂视频回放体验,例如按A或S快进快退,按空格暂停,快放速率自定义,下载视频。
  6. // @author BeBr2
  7. // @match https://pro.yuketang.cn/*
  8. // @license MIT
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13. var video = null;
  14. function load_js() {
  15. var input = document.createElement("input");
  16.  
  17. video.playbackRate = 1;
  18. var vrate = 1;
  19. document.onkeydown = function (e) {
  20. if (e.keyCode == 65) {
  21.  
  22. if(video.currentTime >= 10){
  23. video.currentTime -= 10;}
  24. else{
  25. video.currentTime = 0;}
  26.  
  27. } else if (e.keyCode == 68) {
  28. video.currentTime += 10;
  29. } else if (e.keyCode == 32) {
  30. video.paused ? video.play() : video.pause();
  31. } else if (e.keyCode == 13) {
  32. if (input == document.activeElement) {
  33. if(input.value > 0) {
  34. video.playbackRate = input.value;
  35. vrate = input.value;
  36. }
  37. }
  38. }
  39. }
  40.  
  41. function change_rate() {
  42. video.playbackRate = vrate;
  43. }
  44. setInterval(change_rate, 800);
  45.  
  46. var video_src = video.src;
  47.  
  48.  
  49. var button = document.createElement("button");
  50. button.className = "downloadbutton";
  51. button.textContent = "下载视频";
  52. button.style.height = "80px";
  53. button.style.color = "white"
  54. button.style.background = "#1C223B"
  55. button.addEventListener("click", clickBotton);
  56. function clickBotton(){
  57. if(video_src.substr(0,4) != "blob") {
  58. window.location.href=video_src;
  59. }else{alert("blob文件较难下载,请将blob视频转.m3u8,再使用其他插件下载!")};
  60. }
  61. button.onmouseover=function () {
  62. this.style.background = "gray";
  63. }
  64. button.onmouseout=function () {
  65. this.style.background = "#1C223B";
  66. }
  67. var side_bar = document.getElementsByClassName('left__menu')[0].getElementsByClassName('top')[0];
  68. side_bar.appendChild(button);
  69.  
  70. var speed_bar = document.getElementsByClassName('setting__wrap small')[0];
  71. if(speed_bar) {
  72. speed_bar.remove();
  73. }
  74.  
  75.  
  76.  
  77. input.placeholder = "请输入倍速";
  78. input.style.height = "30px";
  79. input.className = "speedinput";
  80. input.id = "speedinput";
  81. input.type = "number"
  82. input.oninput = function () {
  83. if(this.value.length>5) this.value=this.value.slice(0,5)
  84. };
  85. side_bar.appendChild(input);
  86. }
  87.  
  88. function delete_ele() {
  89. video = null;
  90. var my_button = document.getElementsByClassName('left__menu')[0].getElementsByClassName('top')[0].getElementsByClassName('downloadbutton')[0];
  91. var my_input = document.getElementsByClassName('left__menu')[0].getElementsByClassName('top')[0].getElementsByClassName('speedinput')[0];
  92. if(my_button){my_button.remove()}
  93. if(my_input){my_input.remove()}
  94. }
  95.  
  96. console.log("提升雨课堂视频回放的观看体验! --by BeBr2");
  97. var ii = 0;
  98. var url = window.location.href;
  99. console.log(url);
  100. function get_video() {
  101. if(ii != -1) {
  102. video = document.querySelector("video");
  103. }
  104. if(ii < 20 && ii >= 0) {
  105. ii += 1;
  106. }
  107.  
  108. if(ii == 20) {
  109. console.log("页面找不到视频!");
  110. ii += 1;
  111. return;
  112. }
  113. if (video && ii != -1) {
  114. load_js();
  115. url = window.location.href;
  116. ii = -1;
  117. }
  118. if(url != window.location.href) {
  119. delete_ele();
  120. video = document.querySelector("video");
  121. if(video) {
  122. load_js();
  123. ii = -1;
  124. } else {
  125. ii = 0;
  126. }
  127. url = window.location.href;
  128. }
  129. }
  130.  
  131. setInterval(get_video, 2000);
  132.  
  133.  
  134. })();

QingJ © 2025

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