R34 Rewind Disable

Блокировка перемотки по краям.

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

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

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.

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

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!)

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.

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

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

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

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

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

// ==UserScript==
// @name         R34 Rewind Disable
// @namespace    http://tampermonkey.net/
// @version      2.5
// @description  Блокировка перемотки по краям.
// @author       Gemini
// @match        https://rule34video.com/video/*
// @grant        none
// @run-at       document-start
// @icon         https://www.google.com/s2/favicons?sz=64&domain=rule34video.com
// @all-frames   true
// ==/UserScript==

(function() {
    'use strict';
    
    const TARGET_CLASS = 'fp-player';
    const IGNORE_CLASS = 'fp-controls';
    const SEEK_ZONE_THRESHOLD = 0.33;
    let videoElement = null;

    /**
     * Вычисляет относительную координату X клика/тапа внутри элемента.
     */
    function getRelativeX(event, element) {
        const rect = element.getBoundingClientRect();
        
        // Получаем координату X либо из мыши, либо из первого касания
        const clientX = event.clientX || (event.changedTouches && event.changedTouches[0] ? event.changedTouches[0].clientX : null);
        
        if (clientX === null || !rect.width) {
            return null;
        }

        return (clientX - rect.left) / rect.width;
    }

    /**
     * Обработчик для блокировки перемотки на краях, с вызовом паузы/воспроизведения.
     */
    function handleSeekBlock(e) {
        // Пропускаем клики по элементам управления (.fp-controls).
        if (e.target.closest('.' + IGNORE_CLASS)) {
            return;
        }
        
        const relativeX = getRelativeX(e, this); 
        
        if (relativeX === null) {
            return;
        }

        // Если клик/тап в левой (0-33%) или правой (67-100%) трети, блокируем перемотку.
        if (relativeX <= SEEK_ZONE_THRESHOLD || relativeX >= (1 - SEEK_ZONE_THRESHOLD)) {
            
            // 1. 🛑 Блокируем оригинальное событие
            e.stopImmediatePropagation();
            e.preventDefault();
            
            // 2. 🟢 Принудительно вызываем нативную паузу/воспроизведение (используем кэш)
            if (videoElement) {
                if (videoElement.paused) {
                    videoElement.play();
                } else {
                    videoElement.pause();
                }
            }
        }
        
        // Если клик в центральной трети, позволяем событию пройти, чтобы плеер сам обработал паузу.
    }

    function applyFix(element) {
        if (element.hasAttribute('data-r34-final-fix')) return;

        // Поиск и кэширование элемента при первом применении фикса
        if (!videoElement) {
            videoElement = document.querySelector('video');
        }

        // Блокируем одиночный КЛИК (мышь) и ТАП (сенсор)
        element.addEventListener('click', handleSeekBlock, true);
        element.addEventListener('touchend', handleSeekBlock, true);

        element.setAttribute('data-r34-final-fix', 'true');
    }

    // Наблюдатель за появлением .fp-player
    const observer = new MutationObserver(function(mutations) {
        document.querySelectorAll('.' + TARGET_CLASS).forEach(applyFix);
    });

    function start() {
        if (document.body) {
            observer.observe(document.body, { childList: true, subtree: true });
            document.querySelectorAll('.' + TARGET_CLASS).forEach(applyFix);
        } else {
            window.addEventListener('DOMContentLoaded', start);
        }
    }
    
    start();
})();