HDrezka 1.75x Speed Toggle Button

Add custom speed toggle button for HDrezka media player

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği yüklemek için Tampermonkey gibi bir uzantı yüklemeniz gerekir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

Bu stili yüklemek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için Stylus gibi bir uzantı kurmanız gerekir.

Bu stili yükleyebilmek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı kurmanız gerekir.

Bu stili yükleyebilmek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name            HDrezka 1.75x Speed Toggle Button
// @name:en         HDrezka 1.75x Speed Toggle Button
// @name:uk         HDrezka 1.75x Speed Toggle Button
// @name:ru         HDrezka 1.75x Speed Toggle Button
// @author          zlost666
// @namespace       http://tampermonkey.net/
// @version         1.0
// @license         MIT
// @description     Add custom speed toggle button for HDrezka media player
// @description:uk  Add custom speed toggle button for HDrezka media player
// @description:ru  Add custom speed toggle button for HDrezka media player
// @include         http*://*rezka*/*
// @include         http*://hdrezka*/*
// @include         http*://rezka*/*
// @include         http*://hdrezka.me/*
// @include         http*://hdrezka.co/*
// @include         http*://rezka.ag/*
// @include         http*://rezkify.com/*
// @include         http*://rezkery.com/*
// @include         http*://kinopub.me/*
// @grant           none
// ==/UserScript==

(function() {
    'use strict';

    let isSpeedSet = false;

    // Function to create and add the custom speed button
    function addSpeedButton() {
        let videoPlayer = document.querySelector('video');

        if (videoPlayer) {
            let button = document.createElement('button');
            button.innerText = '1.75x';
            button.style.position = 'fixed';
            button.style.top = '20px';
            button.style.left = '50%';
            button.style.transform = 'translateX(-50%)';
            button.style.zIndex = 1000;
            button.style.padding = '5px';
            button.style.backgroundColor = 'rgba(0,0,0,0.5)';
            button.style.color = 'white';
            button.style.border = 'none';
            button.style.cursor = 'pointer';

            button.addEventListener('click', function() {
                if (isSpeedSet) {
                    videoPlayer.playbackRate = 1;
                    button.style.backgroundColor = 'rgba(0,0,0,0.5)';
                    button.innerText = '1.75x';
                } else {
                    videoPlayer.playbackRate = 1.75;
                    button.style.backgroundColor = 'rgba(0,150,0,0.5)';
                    button.innerText = 'Normal';
                }
                isSpeedSet = !isSpeedSet;
            });

            document.body.appendChild(button);
        } else {
            console.warn('HDrezka video player not found.');
        }
    }

    // Add the button when the page loads
    window.addEventListener('load', function() {
        setTimeout(addSpeedButton, 1000);
    });

    // Add the button when a new video is loaded
    document.addEventListener('DOMNodeInserted', function(event) {
        if (event.target && event.target.tagName === 'VIDEO') {
            addSpeedButton();
        }
    });

    console.log('HDrezka Custom Speed Toggle Button script loaded.');
})();