Automatic loop any videos

In your browser’s console, run the following JavaScript code. All videos (elements with <video> tags) will be set to loop automatically.

CODES:

// Script to make all videos on the page loop
(function() {
    // First, handle standard HTML5 video elements
    const videos = document.querySelectorAll('video');
    videos.forEach(video => {
        // Set native loop attribute
        video.loop = true;
        console.log('Set native loop for video:', video);
        
        // Add ended event listener as a fallback
        video.addEventListener('ended', function() {
            this.currentTime = 0;
            this.play();
            console.log('Restarted video via event listener');
        });
    });
    
    // Handle Plyr instances specifically
    if (window.Plyr) {
        console.log('Plyr detected, configuring all instances');
        document.querySelectorAll('.plyr').forEach(plyrElement => {
            const plyrInstance = plyrElement.plyr;
            if (plyrInstance) {
                plyrInstance.loop = true;
                console.log('Set loop for Plyr instance:', plyrInstance);
            }
        });
    } else {
        console.log('No Plyr global object found, checking for individual instances');
        // Try to find Plyr instances attached to DOM elements
        document.querySelectorAll('.plyr').forEach(plyrElement => {
            // Look for plyr data in the element
            const video = plyrElement.querySelector('video');
            if (video) {
                video.loop = true;
                console.log('Set loop on video within Plyr container');
            }
        });
    }
    
    console.log('✅ Loop enabled for all videos on page');
    return `Modified ${videos.length} video elements`;
})();