Speed Randomizer

Fun tool that will randomly change the speed of media

当前为 2025-04-07 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Speed Randomizer
  3. // @namespace http://tampermonkey.net/
  4. // @version 2025-04-07
  5. // @description Fun tool that will randomly change the speed of media
  6. // @author CCGameing
  7. // @match file://*/*
  8. // @license MIT
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. window.vid = document.querySelector("video");
  16.  
  17. var vid = window.vid;
  18.  
  19. var scriptActive = true;
  20.  
  21. var min = 0.2;
  22.  
  23. function validateMax(num) {
  24. if (num < 0 || isNaN(num)) return 0;
  25. if (num > 16) return 1;
  26. if (num < 16 && num > 0) return 2;
  27. }
  28.  
  29. var loop = true;
  30.  
  31. while (loop) {
  32. var input = prompt("How fast can the vid go? \nMin = 0.2, Max = 16, Default = 8", 8)
  33.  
  34. if (input == null) {
  35. scriptActive = false
  36. loop = false
  37. break
  38. }
  39.  
  40. var max = input - min;
  41.  
  42. switch (validateMax(max)) {
  43. case 2:
  44. alert("Using values: Min = 0.2, Max = " + (min + max))
  45. loop = false;
  46. break;
  47. case 1:
  48. max = 16 - min;
  49. alert("Using values: Min = 0.2, Max = " + (min + max));
  50. loop = false;
  51. break;
  52. case 0:
  53. alert("Please enter a number!")
  54. }
  55. }
  56.  
  57. var fileTitle = window.location.href.split('/').pop()
  58.  
  59. function update() {
  60. vid.playbackRate = min + (Math.random() * max);
  61.  
  62. document.title = "x" + (Math.round(vid.playbackRate * 100) / 100) + ": " + fileTitle
  63. console.log("Video Looped! current speed = " + vid.playbackRate)
  64. }
  65.  
  66. if (scriptActive) {
  67. update()
  68. }
  69.  
  70. vid.onended = () => {
  71. if (scriptActive) {
  72. update()
  73. }
  74. vid.play()
  75. }
  76.  
  77. vid.onpause = () => {
  78. if (scriptActive) {
  79. update()
  80. }
  81. }
  82.  
  83. // Your code here...
  84. })();