Ajout note IMDB #1
105
mode_affiches.js
105
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 = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 110 32" width="70" height="42" style="vertical-align:middle; margin-right:4px;"><rect width="110" height="32" rx="8" fill="#01d277"/><text x="55" y="22" text-anchor="middle" font-size="19" font-family="Arial" fill="#fff" font-weight="bold">TMDB</text></svg>`;
|
||||
|
||||
// Détermine le lien TMDB (film ou série)
|
||||
const voteImdb = data.note_imdb ? Number(data.note_imdb).toFixed(1) : '?';
|
||||
const votesImdb = data.vote_imdb ? ` (${data.vote_imdb})` : '';
|
||||
const imdbSvg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 110 32" width="70" height="42" style="vertical-align:middle; margin-right:4px;"><rect width="110" height="32" rx="8" fill="#01d277"/><text x="55" y="22" text-anchor="middle" font-size="19" font-family="Arial" fill="#fff" font-weight="bold">IMDB</text></svg>`;
|
||||
|
||||
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 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';
|
||||
// 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';
|
||||
|
||||
badge.innerHTML = `${tmdbSvg}<span style="font-size:19px;font-weight:bold;">${vote}</span><span style="font-size:13px;color:#ffd04e;">${votes}</span>`;
|
||||
// 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}<span style="font-size:19px;font-weight:bold;">${vote}</span><span style="font-size:13px;color:#ffd04e;">${votes}</span>`;
|
||||
badgeWrapper.appendChild(badgeTmdb);
|
||||
}
|
||||
|
||||
containerCard.appendChild(badge);
|
||||
// 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}<span style="font-size:19px;font-weight:bold;">${voteImdb}</span><span style="font-size:13px;color:#ffd04e;">${votesImdb}</span>`;
|
||||
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 = `
|
||||
@ -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);
|
||||
})();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user