百度网盘视频倍速

自由调整百度网盘在线播放视频倍速

目前为 2020-04-01 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name 百度网盘视频倍速
  3. // @namespace http://www.skji.net/
  4. // @version 1.0
  5. // @description 自由调整百度网盘在线播放视频倍速
  6. // @author E6ther
  7. // @homepage https://github.com/E6ther/BaiduPan-VideoRate
  8. // @supportURL https://github.com/E6ther/BaiduPan-VideoRate/issues
  9. // @match *://pan.baidu.com/*
  10. // @grant none
  11. // @run-at document-end
  12. // ==/UserScript==
  13.  
  14. (function () {
  15. 'use strict';
  16.  
  17. let platRateCSS = {
  18. "playRateMainCSS": {
  19. "background-color": "rgba(0, 70, 128, 0.1)",
  20. "border": "1px solid rgba(0, 70, 128, 0.12)",
  21. "width": "25px",
  22. "height": "25px",
  23. "border-radius": "13px",
  24.  
  25. "transition": "all 0.2s",
  26.  
  27. "position": "absolute",
  28. "top": "18%",
  29. "right": "2px",
  30. "z-index": "999999"
  31. },
  32. "playRateMainHCSS": {
  33. "background-color": "rgba(0, 70, 128, 0.5)",
  34. "border": "1px solid rgba(0, 70, 128, 0.52)",
  35. "width": "120px",
  36. "height": "100px",
  37. "border-radius": "13px",
  38.  
  39. "transition": "all 0.1s",
  40.  
  41. "position": "absolute",
  42. "top": "18%",
  43. "right": "2px",
  44. "z-index": "999999"
  45. },
  46. "playRateJiCSS": {
  47. "color": "rgba(0, 70, 128, 0.3)",
  48. "font-weight": "bold",
  49. "position": "absolute",
  50. "top": "50%",
  51. "left": "50%",
  52. "transform": "translate(-50%,-50%)"
  53. },
  54. "playRateContentCSS": {
  55. "position": "absolute",
  56. "top": "50%",
  57. "left": "50%",
  58. "transform": "translate(-50%,-50%)"
  59. },
  60. "playRateTextCSS": {
  61. "color": "rgba(255, 255, 255, 1)",
  62. "font-size": "16px",
  63. "text-align": "center",
  64. "-webkit-user-select": "none",
  65. "-moz-user-select": "none",
  66. "-ms-user-select": "none",
  67. "user-select": "none"
  68.  
  69. },
  70. "playRateInputRangeCSS": {
  71. "width": "100px",
  72. "margin": "5px 0 0 0"
  73. },
  74. "playRateInputContentCSS": {
  75. "display": "flex",
  76. "align-items": "center",
  77. "justify-content": "space-between"
  78. },
  79. "playRateInputCSS": {
  80. "border": "1px solid rgba(0, 70, 128, 0.57)",
  81. "outline": "none",
  82. "border-radius": "3px",
  83. "padding": "1px",
  84. "width": "48px",
  85. "height": "23px",
  86. "box-sizing": "border-box"
  87. },
  88. "playRateInputInitCSS": {
  89. "border": "1px solid rgba(0, 70, 128, 0.57)",
  90. "background-color": "rgba(0, 70, 128, 0.1)",
  91. "color": "rgba(255, 255, 255, 1)",
  92. "border-radius": "3px",
  93. "padding": "0 7px",
  94. "height": "23px",
  95. "box-sizing": "border-box"
  96. }
  97. }
  98.  
  99.  
  100. let Rate = localStorage.getItem("Rate"); // 播放速度
  101. if (!Rate) {
  102. Rate = 1;
  103. }
  104.  
  105. let RateLevel;
  106.  
  107.  
  108. let video_main = $(".video-main");
  109.  
  110. if (video_main[0]) {
  111. console.log("百度网盘视频倍速 - 已获取到视频");
  112.  
  113. let myVar = setInterval(function () {
  114. if (window.videojs) {
  115. let video = window.videojs.getPlayers("video-player").html5player;
  116.  
  117. if (video) {
  118.  
  119. videojs.getPlayers("video-player").html5player.tech_.setPlaybackRate(Rate);
  120. clearInterval(myVar);
  121. console.log("百度网盘视频倍速 - 调整倍速成功")
  122.  
  123. playRateControl();
  124. }
  125. }
  126. }, 1000);
  127.  
  128.  
  129. } else {
  130. console.log("百度网盘视频倍速 - 未获取到视频");
  131. }
  132.  
  133. function playRateControl() {
  134.  
  135. let body = $("body");
  136. let playRateMain = $("<div></div>");
  137. let playRateJi = $("<div>及</div>");
  138. let playRateContent = $("<div></div>");
  139. let palyRateText = $("<div></div>");
  140. let playRateInput = $("<input />");
  141. let playRateInputContent = $("<div></div>");
  142. let playRateInputRange = $("<input />");
  143. let playRateInputInit = $("<input />");
  144.  
  145. SetCSS();
  146.  
  147. SetAttr();
  148.  
  149. AddElements();
  150.  
  151. EventListen();
  152.  
  153. ContolHide();
  154.  
  155. judgeRate();
  156.  
  157. function SetCSS() {
  158. playRateJi.css(platRateCSS.playRateJiCSS);
  159. playRateContent.css(platRateCSS.playRateContentCSS);
  160. palyRateText.css(platRateCSS.playRateTextCSS);
  161. playRateInputRange.css(platRateCSS.playRateInputRangeCSS);
  162. playRateInputContent.css(platRateCSS.playRateInputContentCSS)
  163. playRateInput.css(platRateCSS.playRateInputCSS);
  164. playRateInputInit.css(platRateCSS.playRateInputInitCSS);
  165. };
  166.  
  167. function SetAttr() {
  168. playRateMain.attr({"id": "playRateMain"});
  169. playRateContent.attr({"id": "playRateContent"});
  170. playRateInput.attr({"type": "number", "step": 0.1, "min": 0, "max": 4, "value": Rate});
  171. playRateInputRange.attr({"type": "range", "step": 0.1, "min": 0.5, "max": 2.5, "value": Rate});
  172. playRateInputInit.attr({"type": "button"});
  173.  
  174. palyRateText.html("请选择速率");
  175. };
  176.  
  177. function AddElements() {
  178. playRateContent.append(palyRateText);
  179. playRateContent.append(playRateInputRange);
  180. playRateContent.append(playRateInputContent);
  181. playRateInputContent.append(playRateInput);
  182. playRateInputContent.append(playRateInputInit);
  183.  
  184. playRateMain.append(playRateJi);
  185. playRateMain.append(playRateContent);
  186. body.append(playRateMain);
  187. }
  188.  
  189. function EventListen() {
  190. playRateInputRange.bind("input propertychange", function () {
  191. Rate = playRateInputRange.val();
  192. ChangeRate();
  193. });
  194.  
  195. playRateInput.bind("input propertychange", function () {
  196. Rate = playRateInput.val();
  197. ChangeRate();
  198. });
  199.  
  200. playRateInputInit.click(function () {
  201. Rate = RateLevel;
  202. ChangeRate();
  203. });
  204.  
  205.  
  206. playRateMain.hover(function () {
  207. ContolShow();
  208. }, function () {
  209. ContolHide();
  210. });
  211. };
  212.  
  213. function ChangeRate() {
  214. judgeRate();
  215. playRateInputRange.val(Rate);
  216. playRateInput.val(Rate);
  217. videojs.getPlayers("video-player").html5player.tech_.setPlaybackRate(Rate);
  218. window.localStorage.setItem("Rate", Rate);
  219. };
  220.  
  221. function judgeRate() {
  222. if (Rate == 1) {
  223. playRateInputInit.val("x1.5");
  224. RateLevel = 1.5;
  225. } else if (Rate == 1.5) {
  226. playRateInputInit.val("x2");
  227. RateLevel = 2;
  228. } else {
  229. playRateInputInit.val("默认");
  230. RateLevel = 1;
  231. }
  232. }
  233.  
  234. function ContolShow() {
  235. playRateJi.hide();
  236. playRateContent.show();
  237. playRateMain.css(platRateCSS.playRateMainHCSS);
  238. };
  239.  
  240. function ContolHide() {
  241. playRateJi.show();
  242. playRateContent.hide();
  243. playRateMain.css(platRateCSS.playRateMainCSS);
  244. };
  245. }
  246.  
  247. })();

QingJ © 2025

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