2025-04-26 11:14:28 +00:00
|
|
|
// ==UserScript==
|
|
|
|
|
// @name Vérificateur de disponibilité TMDB sur UNFR
|
|
|
|
|
// @namespace https://unfr.pw
|
|
|
|
|
// @version 1.8
|
2025-04-26 11:17:54 +00:00
|
|
|
// @description Vérifie si un film ou une série est disponible sur UNFR et ajoute le lien sur le site TMDB.
|
2025-04-26 11:14:28 +00:00
|
|
|
// @author Vous
|
|
|
|
|
// @match https://www.themoviedb.org/*
|
|
|
|
|
// @grant none
|
|
|
|
|
// @icon https://unfr.pw/favicon/apple-icon-72x72.png
|
2025-04-26 11:16:52 +00:00
|
|
|
// @downloadURL https://tig.unfr.pw/redcoat/TMDB_check/raw/branch/main/TMDB_checker.user.js
|
|
|
|
|
// @updateURL https://tig.unfr.pw/redcoat/TMDB_check/raw/branch/main/TMDB_checker.user.js
|
2025-04-26 11:14:28 +00:00
|
|
|
// ==/UserScript==
|
|
|
|
|
|
|
|
|
|
(function () {
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
const ICON_URL = 'https://unfr.pw/favicon/apple-icon-72x72.png'; // <-- Utilise l'@icon défini ci-dessus
|
|
|
|
|
|
2025-04-26 11:15:02 +00:00
|
|
|
// Attendre que le titre soit chargé dans le DOM
|
2025-04-26 11:14:28 +00:00
|
|
|
function attendreTitre(callback) {
|
|
|
|
|
const intervalle = setInterval(() => {
|
|
|
|
|
const correspondance = window.location.pathname.match(/\/(movie|tv)\/(\d+)/);
|
|
|
|
|
const titre = document.querySelector('h2 a[href*="/movie/"], h2 a[href*="/tv/"]');
|
|
|
|
|
if (correspondance && titre) {
|
|
|
|
|
clearInterval(intervalle);
|
|
|
|
|
callback(correspondance[1], correspondance[2], titre);
|
|
|
|
|
}
|
|
|
|
|
}, 500);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Vérifie la disponibilité via le nouvel endpoint
|
|
|
|
|
function verifierDisponibilite(type, tmdbId, callback) {
|
|
|
|
|
const url = `https://unfr.pw/check_tmdb?check=${tmdbId}&type=${type}`;
|
|
|
|
|
fetch(url)
|
|
|
|
|
.then(response => response.json())
|
|
|
|
|
.then(data => {
|
|
|
|
|
const disponible = data.code === 1;
|
|
|
|
|
const message = data.Explain || 'Indisponible';
|
|
|
|
|
callback(disponible, message);
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {
|
|
|
|
|
callback(false, 'Erreur lors de la vérification');
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Ajoute le bouton à la page
|
|
|
|
|
function ajouterBouton(titre, disponible, message, tmdbId, type) {
|
|
|
|
|
const bouton = document.createElement('a');
|
|
|
|
|
bouton.textContent = disponible ? 'Disponible' : 'Faire une requête';
|
|
|
|
|
bouton.title = message;
|
|
|
|
|
|
|
|
|
|
const icone = document.createElement('img');
|
|
|
|
|
icone.src = ICON_URL;
|
|
|
|
|
icone.style.width = '16px';
|
|
|
|
|
icone.style.height = '16px';
|
|
|
|
|
icone.style.verticalAlign = 'middle';
|
|
|
|
|
icone.style.marginRight = '6px';
|
|
|
|
|
|
|
|
|
|
bouton.prepend(icone);
|
|
|
|
|
|
|
|
|
|
const paramId = type === 'tv' ? 'tvid' : 'movieid';
|
|
|
|
|
const urlBase = `https://unfr.pw/?d=fiche&${paramId}=${tmdbId}`;
|
|
|
|
|
bouton.href = disponible ? urlBase : urlBase + '#requete';
|
|
|
|
|
|
|
|
|
|
bouton.target = '_blank';
|
|
|
|
|
bouton.style.marginLeft = '10px';
|
|
|
|
|
bouton.style.padding = '4px 8px';
|
|
|
|
|
bouton.style.borderRadius = '6px';
|
|
|
|
|
bouton.style.fontSize = '0.9rem';
|
|
|
|
|
bouton.style.color = 'white';
|
|
|
|
|
bouton.style.backgroundColor = disponible ? 'green' : 'red';
|
|
|
|
|
bouton.style.textDecoration = 'none';
|
|
|
|
|
bouton.style.display = 'inline-flex';
|
|
|
|
|
bouton.style.alignItems = 'center';
|
|
|
|
|
|
|
|
|
|
titre.parentNode.appendChild(bouton);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Lance l'exécution
|
|
|
|
|
attendreTitre((type, tmdbId, titre) => {
|
|
|
|
|
verifierDisponibilite(type, tmdbId, (disponible, message) => {
|
|
|
|
|
ajouterBouton(titre, disponible, message, tmdbId, type);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
})();
|