Greasy Fork is available in English.

Auto Loop and Autoplay for All Video Players

Enables loop and autoplay on all video players online

Verze ze dne 11. 02. 2025. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         Auto Loop and Autoplay for All Video Players
// @namespace    http://tampermonkey.net/
// @version      1.5
// @description  Enables loop and autoplay on all video players online
// @author       Dj Dragkan
// @match        *://*/*
// @icon         https://upload.wikimedia.org/wikipedia/commons/4/42/YouTube_icon_%282013-2017%29.png
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    function enableLoopAndAutoplay(video) {
        if (video && !video.dataset.loopEnabled) {
            // Enable loop
            video.loop = true;
            video.dataset.loopEnabled = "true";
            console.log("Loop enabled on:", video);
        }

        // Enable autoplay after the first playback finishes
        video.addEventListener('ended', () => {
            video.autoplay = true;
            video.play();
            console.log("Autoplay enabled on:", video);
        });
    }

    function checkVideos() {
        let videos = document.querySelectorAll("video");
        videos.forEach(enableLoopAndAutoplay);
    }

    // Observer to detect new videos on the page
    const observer = new MutationObserver(checkVideos);
    observer.observe(document.body, { childList: true, subtree: true });

    // Enable loop and autoplay on videos already present
    checkVideos();
})();