Speed Randomizer

Fun tool that will randomly change the speed of media

اعتبارا من 07-04-2025. شاهد أحدث إصدار.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name         Speed Randomizer
// @namespace    http://tampermonkey.net/
// @version      2025-04-07
// @description  Fun tool that will randomly change the speed of media
// @author       CCGameing
// @match        file://*/*
// @license      MIT
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    window.vid = document.querySelector("video");

    var vid = window.vid;

    var scriptActive = true;

    var min = 0.2;

    function validateMax(num) {
        if (num < 0 || isNaN(num)) return 0;
        if (num > 16) return 1;
        if (num < 16 && num > 0) return 2;
    }

    var loop = true;

    while (loop) {
        var input = prompt("How fast can the vid go? \nMin = 0.2, Max = 16, Default = 8", 8)

        if (input == null) {
            scriptActive = false
            loop = false
            break
        }

        var max = input - min;

        switch (validateMax(max)) {
            case 2:
                alert("Using values: Min = 0.2, Max = " + (min + max))
                loop = false;
                break;
            case 1:
                max = 16 - min;
                alert("Using values: Min = 0.2, Max = " + (min + max));
                loop = false;
                break;
            case 0:
                alert("Please enter a number!")
        }
    }

    var fileTitle = window.location.href.split('/').pop()

    function update() {
        vid.playbackRate = min + (Math.random() * max);

        document.title = "x" + (Math.round(vid.playbackRate * 100) / 100) + ": " + fileTitle
        console.log("Video Looped! current speed = " + vid.playbackRate)
    }

    if (scriptActive) {
        update()
    }

    vid.onended = () => {
        if (scriptActive) {
            update()
        }
        vid.play()
    }

    vid.onpause = () => {
        if (scriptActive) {
            update()
        }
    }

    // Your code here...
})();