Modify the list by cards with images on streaming sites

You are going to need an API https://www.themoviedb.org

// ==UserScript==
// @name         Modify the list by cards with images on streaming sites
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  You are going to need an API https://www.themoviedb.org
// @author       M1tx

// @include        http*://rolrov.com/*
// @include        http*://ovoob.com/*
// @include        http*://*tomacloud.com/*
// @include        http*://*toblek.com/*
// @include        http*://*galtro.com/*
// @include        http*://*wobno.com/*
// @include        http*://*yisera.com/*
// @include        http*://*limpod.com/*
// @include        http*://*tamdor.com/*
// @include        http*://*bofiaz.com/*
// @include        http*://*radego.com/*
// @include        http*://*trozam.com/*
// @include        http*://*abiov.com/*
// @include        http*://*crebya.com/*
// @include        http*://*ivmox.com/*
// @include        http*://*botidou.com/*
// @include        http*://*urmoon.com/*
// @include        http*://*datzio.com/*
// @include        http*://*rawdid.com/*
// @include        http*://*bonoov.com/*
// @include        http*://*zetmir.com/*
// @include        http*://*xoperi.com/*
// @include        http*://*yisera.com/*
// @include        http*://*jomvu.com/*
// @include        http*://*diagrim.com/*
// @include        http*://*nirbom.com/*
// @include        http*://*remenz.com/*
// @include        http*://*filriv.com/*
// @include        http*://*gopzay.com/*
// @include        http*://*fervap.com/*
// @include        http*://*eyobim.com/*
// @include        http*://*jexoom.com/*
// @include        http*://*rodroz.com/*
// @include        http*://*xepam.com/*
// @include        http*://*motezi.com/*
// @include        http*://*peralga.com/*
// @include        http*://*nimvon.com/*
// @include        http*://*treyim.com/*
// @include        http*://*wanveo.com/*
// @include        http*://*kanmav.com/*
// @include        http*://*sajbo.com/*
// @include        http*://*xitof.com/*
// @include        http*://*vavozi.com/*
// @include        http*://*mindooz.com/*
// @include        http*://*afzor.com/*
// @include        http*://*bipvo.com/*
// @include        http*://*sowdrip.com/*
// @include        http*://*yapeol.com/*
// @include        http*://*nidoron.com/*
// @include        http*://*apolma.com/*
// @include        http*://*irumax.com/*
// @include        http*://*dolbri.com/*
// @include        http*://*mirvoy.com/*
// @include        http*://*parmiv.com/*
// @include        http*://*kapmop.com/*
// @include        http*://*vitmox.com/*
// @include        http*://*binmir.com/*
// @include        http*://*dirmox.com/*
// @include        http*://*irdoz.com/*
// @include        http*://*avtod.com/*
// @include        http*://*zinbax.com/*
// @include        http*://*treyim.com/*
// @include        http*://*sajbo.com/*
// @include        http*://*komiav.com/*
// @include        http*://*lozicon.com/*
// @include        http*://*tiwzen.com/*
// @include        http*://*xevdaz.com/*
// @include        http*://*zadiro.com/*
// @include        http*://*uquaz.com/*
// @include        http*://*lakmoa.com/*
// @include        http*://*yeswani.com/*
// @include        http*://*moyeor.com/*
// @include        http*://*trobway.com/*
// @include        http*://*pifdi.com/*
// @include        http*://*barlox.com/*
// @include        http*://*kempox.com/*
// @include        http*://*ditroz.com/*
// @include        http*://*fovri.com/*
// @include        http*://*rotwi.com/*
// @include        http*://*nidroy.com/*
// @include        http*://*dadroz.com/*
// @include        http*://*abdov.com/*
// @include        http*://*omyfo.com/*
// @include        http*://*wonior.com/*
// @include        http*://*druvaz.com/*
// @include        http*://*clavior.com/*
// @include        http*://*epiog.com/*
// @include        http*://*piopar.com/*
// @include        http*://*sivtez.com/*
// @include        http*://*zidixo.com/*
// @include        http*://*bovmi.com/*
// @include        http*://*tratov.com/*
// @include        http*://*vagdi.com/*
// @include        http*://*zawox.com/*
// @include        http*://*grizox.com/*
// @include        http*://*mildip.com/*
// @include        http*://*zavrol.com/*
// @include        http*://*okvop.com/*
// @include        http*://*pilmov.com/*
// @include        http*://*obniv.com/*
// @include        http*://*wavob.com/*
// @include        http*://*extrabb.com/*
// @include        http*://*bambip.com/*
// @include        http*://*pijpa.com/*
// @include        http*://*ovtok.com/*
// @include        http*://*ivrom.com/*
// @include        http*://*waklov.com/*
// @include        http*://*redzor.com/*
// @include        http*://*dibrav.com/*
// @include        http*://*flazto.com/*
// @include        http*://*bovrom.com/*
// @include        http*://*davrip.com/*
// @include        http*://*framib.com/*
// @include        http*://*difiam.com/*
// @include        http*://*ridzov.com/*
// @include        http*://*netdov.com/*
// @include        http*://*flozor.com/*
// @include        http*://*choupox.com/*
// @include        http*://*framib.com/*
// @include        http*://*evdod.com/*
// @include        http*://*badrip.com/*
// @include        http*://*poblom.com/*
// @include        http*://*zaniob.com/*
// @include        http*://*sardip.com/*
// @include        http*://*rigrov.com/*
// @include        http*://*justdaz.com/*
// @include        http*://*voplav.com/*
// @include        http*://*vadraz.com/*
// @include        http*://*saypap.com/*
// @include        http*://*sabtam.com/*
// @include        http*://*grebak.com/*
// @include        http*://*brikstok.com/*
// @include        http*://*tivrod.com/*
// @include        http*://*takpok.com/*
// @include        http*://*nofza.com/*
// @include        http*://*zifub.com/*
// @include        http*://*katrov.com/*
// @include        http*://*dokral.com/*
// @include        http*://*rikmod.com/*
// @include        http*://*tobrok.com/*
// @include        http*://*naxpom.com/*
// @include        http*://*grogab.com/*
// @include        http*://*nopliv.com/*
// @include        http*://*votrob.com/*
// @include        http*://*tiblor.com/*
// @include        http*://*brorov.com/*
// @include        http*://*redziv.com/*


// @grant        GM_xmlhttpRequest
// ==/UserScript==

(function() {
    'use strict';

    const apiKey = 'Your_apikey';

    function fetchMoviePoster(movieTitle, callback) {
        const url = `https://api.themoviedb.org/3/search/movie?api_key=${apiKey}&query=${encodeURIComponent(movieTitle)}`;
        console.log('Fetching poster for:', movieTitle);
        GM_xmlhttpRequest({
            method: "GET",
            url: url,
            onload: function(response) {
                const json = JSON.parse(response.responseText);
                if (json.results && json.results.length > 0) {
                    const posterPath = json.results[0].poster_path;
                    const posterUrl = `https://image.tmdb.org/t/p/w200${posterPath}`;
                    console.log('Poster URL:', posterUrl);
                    callback(posterUrl);
                } else {
                    console.log('No poster found for:', movieTitle);
                    callback(null);
                }
            }
        });
    }

    function replaceDivsWithCards() {
        const divs = document.querySelectorAll('#hann');
        divs.forEach(div => {
            const movieLink = div.querySelector('a');
            const movieTitle = movieLink.textContent.trim();
            const movieYearMatch = movieTitle.match(/\((\d{4})\)/);
            const movieYear = movieYearMatch ? movieYearMatch[1] : '';

            // Supprimer l'année et "HD" du titre du film
            const cleanMovieTitle = movieTitle.replace(/\((\d{4})\)|HD/gi, '').trim();

            fetchMoviePoster(cleanMovieTitle, posterUrl => {
                const card = document.createElement('div');
                card.className = 'movie-card';
                card.innerHTML = `
                    <a href="${movieLink.href}" class="movie-card-link">
                        <div class="movie-poster">
                            ${posterUrl ? `<img src="${posterUrl}" alt="${movieTitle}">` : ''}
                        </div>
                        <div class="movie-info">
                            <h3>${movieTitle}</h3>
                            <p>${movieYear}</p>
                        </div>
                    </a>
                `;
                div.parentNode.replaceChild(card, div);
            });
        });
    }

function addCardStyles() {
    const style = document.createElement('style');
    style.innerHTML = `
        .movie-card {
            display: inline-block;
            width: 200px;
            padding: 10px;
            box-sizing: border-box;
            vertical-align: top;
            text-align: center;
            margin: 5px;
            border: 1px solid #ccc;
            border-radius: 5px;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
            background-color: #fff;
            transition: transform 0.3s;
        }
        .movie-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
        }
        .movie-card-link {
            display: block;
            text-decoration: none;
            color: inherit;
        }
        .movie-card-link:hover {
            text-decoration: none;
        }
        .movie-poster {
            width: 100%;
            height: auto;
            position: relative;
            overflow: hidden;
            border-radius: 5px;
        }
        .movie-poster img {
            width: 100%;
            height: auto;
            display: block;
            transition: transform 0.3s;
        }
        .movie-card:hover .movie-poster img {
            transform: scale(1.1);
        }
        .movie-info {
            margin-top: 10px;
        }
        .movie-info h3 {
            font-size: 18px;
            margin-bottom: 5px;
            font-weight: bold;
            line-height: 1.3;
            color: #000000
        }
        .movie-info p {
            font-size: 14px;
            color: #777;
            margin: 0;
        }
    `;
    document.head.appendChild(style);
}



    // Appeler la fonction pour ajouter des styles CSS
    addCardStyles();

    // Appeler la fonction pour remplacer les divs par des cartes
    replaceDivsWithCards();
})();