From 9041a426b0a3de38d187921de074a7e339384517 Mon Sep 17 00:00:00 2001 From: UNFR Date: Sat, 12 Jul 2025 09:46:24 +0000 Subject: [PATCH] Ajout note IMDB MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ajout de la note IMDB et affichage des note uniquement si différente de 0 --- mode_affiches.js | 123 +++++++++++++++++++++++++++++++---------------- 1 file changed, 82 insertions(+), 41 deletions(-) diff --git a/mode_affiches.js b/mode_affiches.js index c5d0cf2..2e17702 100644 --- a/mode_affiches.js +++ b/mode_affiches.js @@ -1,6 +1,6 @@ // ==UserScript== // @name UseNet Enhanced -// @version 6.28 +// @version 6.29 // @date 12.07.25 // @description Userscript pour transformer la liste de releases sur un indexeur privé en galerie d'affiches responsive // @author Aerya | https://upandclear.org @@ -14,7 +14,6 @@ (function () { 'use strict'; - const TMDB_API_KEY = '1234'; // Mettez votre clé ici ! const TMDB_CACHE_TTL = 24 * 60 * 60 * 1000; // 1 jour const CATEGORIES = [ @@ -45,7 +44,7 @@ function saveTmdbCache(cache) { localStorage.setItem(TMDB_CACHE_KEY, JSON.stringify(cache)); } function fetchTmdb(type, tmdbId) { - if (!TMDB_API_KEY || !tmdbId) return Promise.resolve(null); + if (!tmdbId) return Promise.resolve(null); const cache = getTmdbCache(); const key = `${type}_${tmdbId}`; const now = Date.now(); @@ -53,8 +52,8 @@ return Promise.resolve(cache[key].data); } let url = ''; - if (type === 'movie') url = `https://api.themoviedb.org/3/movie/${tmdbId}?api_key=${TMDB_API_KEY}&language=fr-FR`; - else if (type === 'tv') url = `https://api.themoviedb.org/3/tv/${tmdbId}?api_key=${TMDB_API_KEY}&language=fr-FR`; + if (type === 'movie') url = `https://unfr.pw/proxy_tmdb?type=movie&id=${tmdbId}`; + else if (type === 'tv') url = `https://unfr.pw/proxy_tmdb?type=tv&id=${tmdbId}`; return fetch(url) .then(r => r.json()) .then(data => { @@ -148,44 +147,88 @@ containerCard.style.position = 'relative'; containerCard.style.display = 'block'; - // Badge note TMDB (optionnel) + // Badge notes TMDB/IMDB (vertical, propre, pas de badge vide) if (showTmdb) { - fetchTmdb(group.movieType, group.tmdbId).then(data => { - if (!data) return; - const vote = data.vote_average ? Number(data.vote_average).toFixed(1) : '?'; - const votes = data.vote_count ? ` (${data.vote_count})` : ''; - const tmdbSvg = `TMDB`; + fetchTmdb(group.movieType, group.tmdbId).then(data => { + if (!data) return; - // Détermine le lien TMDB (film ou série) - let tmdbUrl = ''; - if (group.movieType === 'movie') tmdbUrl = `https://www.themoviedb.org/movie/${group.tmdbId}`; - else if (group.movieType === 'tv') tmdbUrl = `https://www.themoviedb.org/tv/${group.tmdbId}`; + const vote = data.vote_average ? Number(data.vote_average).toFixed(1) : '?'; + const votes = data.vote_count ? ` (${data.vote_count})` : ''; + const tmdbSvg = `TMDB`; - const badge = document.createElement('a'); - badge.href = tmdbUrl; - badge.target = '_blank'; - badge.rel = 'noopener noreferrer'; - badge.title = "Voir sur TMDB"; - badge.style.position = 'absolute'; - badge.style.top = '7px'; - badge.style.left = '8px'; - badge.style.background = '#032541de'; - badge.style.color = '#ffd04e'; - badge.style.fontWeight = 'bold'; - badge.style.borderRadius = '8px'; - badge.style.padding = '2px 11px 2px 3px'; - badge.style.fontSize = '18px'; - badge.style.boxShadow = '0 2px 8px #222c'; - badge.style.zIndex = 15; - badge.style.display = 'flex'; - badge.style.alignItems = 'center'; - badge.style.textDecoration = 'none'; + const voteImdb = data.note_imdb ? Number(data.note_imdb).toFixed(1) : '?'; + const votesImdb = data.vote_imdb ? ` (${data.vote_imdb})` : ''; + const imdbSvg = `IMDB`; - badge.innerHTML = `${tmdbSvg}${vote}${votes}`; + let tmdbUrl = ''; + if (group.movieType === 'movie') tmdbUrl = `https://www.themoviedb.org/movie/${group.tmdbId}`; + else if (group.movieType === 'tv') tmdbUrl = `https://www.themoviedb.org/tv/${group.tmdbId}`; - containerCard.appendChild(badge); - }); + // Conteneur vertical des badges + const badgeWrapper = document.createElement('div'); + badgeWrapper.style.position = 'absolute'; + badgeWrapper.style.top = '7px'; + badgeWrapper.style.left = '8px'; + badgeWrapper.style.display = 'flex'; + badgeWrapper.style.flexDirection = 'column'; + badgeWrapper.style.gap = '3px'; + badgeWrapper.style.zIndex = 15; + badgeWrapper.style.pointerEvents = 'none'; + // TMDB badge + if ( + typeof data.vote_average !== 'undefined' && + data.vote_average !== null && + data.vote_average !== 0 + ) { + const badgeTmdb = document.createElement('a'); + badgeTmdb.href = tmdbUrl; + badgeTmdb.target = '_blank'; + badgeTmdb.rel = 'noopener noreferrer'; + badgeTmdb.title = "Voir sur TMDB"; + badgeTmdb.style.background = '#032541de'; + badgeTmdb.style.color = '#ffd04e'; + badgeTmdb.style.fontWeight = 'bold'; + badgeTmdb.style.borderRadius = '8px'; + badgeTmdb.style.padding = '2px 11px 2px 3px'; + badgeTmdb.style.fontSize = '18px'; + badgeTmdb.style.boxShadow = '0 2px 8px #222c'; + badgeTmdb.style.display = 'flex'; + badgeTmdb.style.alignItems = 'center'; + badgeTmdb.style.gap = '6px'; + badgeTmdb.style.pointerEvents = 'auto'; + badgeTmdb.innerHTML = `${tmdbSvg}${vote}${votes}`; + badgeWrapper.appendChild(badgeTmdb); + } + + // IMDB badge + if ( + typeof data.note_imdb !== 'undefined' && + data.note_imdb !== null && + data.note_imdb !== 0 + ) { + const badgeImdb = document.createElement('span'); + badgeImdb.style.background = '#032541de'; + badgeImdb.style.color = '#ffd04e'; + badgeImdb.style.fontWeight = 'bold'; + badgeImdb.style.borderRadius = '8px'; + badgeImdb.style.padding = '2px 11px 2px 3px'; + badgeImdb.style.fontSize = '18px'; + badgeImdb.style.boxShadow = '0 2px 8px #222c'; + badgeImdb.style.display = 'flex'; + badgeImdb.style.alignItems = 'center'; + badgeImdb.style.gap = '6px'; + badgeImdb.innerHTML = `${imdbSvg}${voteImdb}${votesImdb}`; + badgeImdb.style.pointerEvents = 'auto'; + badgeWrapper.appendChild(badgeImdb); + } + + + // Ajoute les badges seulement s'il y en a + if (badgeWrapper.children.length > 0) { + containerCard.appendChild(badgeWrapper); + } + }); } // Clone affiche @@ -215,13 +258,11 @@ tooltip.style.display = 'none'; tooltip.style.pointerEvents = 'auto'; - // Responsive : recalcule la largeur à l’ouverture si resize function adjustOverlayWidth() { tooltip.style.width = Math.min(window.innerWidth - 40, 1150) + 'px'; } window.addEventListener('resize', adjustOverlayWidth); - // Header overlay let typeLabel = 'film', typeGender = 'le'; if (group.movieType === 'tv') { typeLabel = 'série'; typeGender = 'la'; } tooltip.innerHTML = ` @@ -233,7 +274,7 @@ | + style="color:#ffd04e; font-size:${rlzFontSize - 1}px; font-weight:600; text-decoration:none;"> Voir toutes les releases pour ${typeGender} ${typeLabel} @@ -288,7 +329,6 @@ setTimeout(() => { tooltip.style.minHeight = ''; tooltip.style.height = ''; tooltip.style.maxHeight = 'none'; }, 10); - // Toggle overlay au clic sur affiche let isOpen = false; cloneImg.addEventListener('click', (e) => { e.stopPropagation(); @@ -493,3 +533,4 @@ if (document.readyState !== 'loading') start(); else document.addEventListener('DOMContentLoaded', start); })(); + -- 2.39.5