m.YouTube.com more playback speeds

Adds 2.25x 2.5x 2.75x 3x speed buttons below the video

当前为 2023-10-12 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name m.YouTube.com more playback speeds
  3. // @namespace m-youtube-com-more-playback-speeds
  4. // @version 1.0
  5. // @description Adds 2.25x 2.5x 2.75x 3x speed buttons below the video
  6. // @author hlorand.hu
  7. // @match https://m.youtube.com/watch*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net
  9. // @grant none
  10. // @license https://creativecommons.org/licenses/by-nc-sa/4.0/
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. //'use strict';
  15.  
  16. window.addEventListener('load', function () {
  17.  
  18. const speeds = ["3.5","3.25","3.0","2.75","2.5","2.25","2.0","1.75","1.5"];
  19.  
  20. speeds.forEach((speed)=>{
  21. let button = document.createElement('button');
  22. button.textContent = speed;
  23. button.className = "speedbutton";
  24.  
  25. button.style.margin = "5px";
  26. button.style.padding = "5px";
  27. button.style.backgroundColor = "blue";
  28. button.style.position = "relative";
  29.  
  30. button.onclick = function() {
  31. video = document.querySelector("video");
  32.  
  33. if(video && video.readyState >= 2) {
  34.  
  35. video.playbackRate = this.textContent;
  36.  
  37. video.mozPreservesPitch = video.webkitPreservesPitch = video.preservePitch = true;
  38.  
  39. document.querySelectorAll(".speedbutton").forEach((btn)=>{
  40. btn.style.backgroundColor = "blue";
  41. });
  42. this.style.backgroundColor = "darkorange";
  43. }
  44. };
  45.  
  46. let div = document.querySelector('.related-chips-slot-wrapper');
  47. div.insertBefore(button, div.firstChild);
  48. });
  49.  
  50. }); // end addEventListener
  51.  
  52. })();