Rule34 + Realbooru AutoPlay + Loop

Autoplay and loop videos on Rule34 and Realbooru

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

You will need to install an extension such as Tampermonkey or Violentmonkey 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         Rule34 + Realbooru AutoPlay + Loop
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Autoplay and loop videos on Rule34 and Realbooru
// @match        https://rule34.xxx/*
// @match        https://www.rule34.xxx/*
// @match        https://realbooru.com/*
// @match        https://www.realbooru.com/*
// @grant        none
// @license      DallasGWS
// ==/UserScript==

(function () {
    'use strict';

    function log(...msg) {
        console.log('[Bo​oru-Auto]', ...msg);
    }

    function autoplay(video) {
        const play = () => {
            if (!video.isConnected) return;

            video.play().catch(() => {
                setTimeout(play, 200);
            });
        };

        play();
    }

    function setup(video) {
        if (!video || video.dataset.autoplaySetup === 'true') return;

        video.dataset.autoplaySetup = 'true';

        log('Video found:', video);

        // Enable looping
        video.loop = true;

        // Autoplay
        autoplay(video);
    }

    function findVideos() {
        return document.querySelectorAll('video');
    }

    function checkVideos() {
        findVideos().forEach(setup);
    }

    // Initial load
    checkVideos();

    // Detect videos loaded later
    const observer = new MutationObserver(() => {
        checkVideos();
    });

    observer.observe(document.documentElement, {
        childList: true,
        subtree: true
    });

    // Also check periodically in case the site's player replaces
    // the video without generating a useful mutation.
    setInterval(checkVideos, 1000);

})();