Xhamster - AUTO Video Infinite LOOP (IA) v.9

Video Auto Infinite Replay (With Help of IA DuckduckGo)

// ==UserScript==
// @name            Xhamster - AUTO Video Infinite LOOP (IA) v.9
// @version         v.9.0
// @description	    Video Auto Infinite Replay (With Help of IA DuckduckGo)
// @icon            https://external-content.duckduckgo.com/ip3/fr.xhamster.com.ico
//
// @namespace       https://greasyfork.org/fr/users/7434-janvier56
// @homepage        https://greasyfork.org/fr/users/7434-janvier56

// @match           https://*.xhamster.com/videos/*
// @grant           none
// ==/UserScript==

(function() {
    'use strict';

    // Get the video element
    var video = document.querySelector('video');
    if (!video) {
        video = document.querySelector('iframe').contentDocument.querySelector('video');
    }
    console.log('Video element:', video);

    // Remove the overlay menu
    var overlayMenu = document.querySelector('html:not(.tablet) .xplayer.overlay-menu-opened .xp-aftershot');
    console.log('Overlay menu:', overlayMenu);
    if (overlayMenu) {
        overlayMenu.remove();
    }

    // Add an event listener to loop the video
    if (video) {
        video.addEventListener('ended', function() {
            console.log('Video ended, looping...');
            video.currentTime = 0;
            video.play();
        });
    } else {
        console.log('Video element not found');
    }
})();