Rule34Video Auto-Player Ultimate

Auto-advance videos with full state control

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         Rule34Video Auto-Player Ultimate
// @namespace    http://tampermonkey.net/
// @version      1.4
// @description  Auto-advance videos with full state control
// @author       YourName
// @match        https://rule34video.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let isProcessing = false;
    let checkInterval;
    const config = {
        checkInterval: 100,     // Progress check frequency
        nextDelay: 1000,         // Delay before next click
        actionDelay: 2000,       // Post-navigation wait
        playDelay: 250,          // Play->fullscreen delay
        retryInterval: 250,      // State check interval
        maxRetries: 4096            // Max retry attempts per state
    };

    function parseTime(timeStr) {
        const [mins, secs] = timeStr.split(':').map(Number);
        return mins * 60 + secs;
    }

    function enforcePlayerState() {
        let retries = 0;
        const stateChecker = setInterval(() => {
            const player = document.getElementById('kt_player');
            const playButton = document.querySelector('.fp-play');
            const fsButton = document.querySelector('.fp-screen');

            if (!player) {
                clearInterval(stateChecker);
                return;
            }

            // Check and enforce playing state
            if (!player.classList.contains('is-playing') && playButton) {
                playButton.click();
            }

            // Check and enforce fullscreen state
            if (!player.classList.contains('is-fullscreen') && fsButton) {
                fsButton.click();
            }

            // Stop checking when both states are present or max retries reached
            if ((player.classList.contains('is-playing') &&
                 player.classList.contains('is-fullscreen')) ||
                retries >= config.maxRetries) {
                clearInterval(stateChecker);
            }

            retries++;
        }, config.retryInterval);
    }

    function performPlayActions() {
        const playButton = document.querySelector('.fp-play');
        if (playButton) {
            playButton.click();

            setTimeout(() => {
                const fsButton = document.querySelector('.fp-screen');
                if (fsButton) {
                    fsButton.click();
                    enforcePlayerState();
                }
            }, config.playDelay);
        }
    }

    function triggerNextSequence() {
        if (isProcessing) return;
        isProcessing = true;

        setTimeout(() => {
            const nextBtn = document.querySelector('a.link-video.next.js-url-next');
            if (nextBtn) {
                nextBtn.click();

                setTimeout(() => {
                    performPlayActions();
                    isProcessing = false;
                }, config.actionDelay);
            }
        }, config.nextDelay);
    }

    function checkPlaybackProgress() {
        const elapsedElem = document.querySelector('.fp-time-elapsed');
        const durationElem = document.querySelector('.fp-time-duration');

        if (!elapsedElem || !durationElem) return;

        const elapsed = parseTime(elapsedElem.textContent);
        const duration = parseTime(durationElem.textContent);

        if (duration > 0 && elapsed >= duration - 1) {
            clearInterval(checkInterval);
            triggerNextSequence();
        }
    }

    function init() {
        clearInterval(checkInterval);
        checkInterval = setInterval(checkPlaybackProgress, config.checkInterval);
    }

    // Initial setup
    init();

    // Handle SPA navigation
    new MutationObserver((mutations) => {
        if (document.querySelector('.fp-time-duration')) {
            init();
        }
    }).observe(document.body, {
        childList: true,
        subtree: true
    });
})();