Auto Loop and Autoplay for All Video Players

Enables loop and autoplay on all video players online

Stan na 11-02-2025. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==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();
})();