PTP2CL

Ajoute un lien CinéLounge avant le lien IMDb sur PTP

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name        PTP2CL
// @namespace   https://www.cinelounge.org/
// @description Ajoute un lien CinéLounge avant le lien IMDb sur PTP
// @author      tadanobu
// @match       https://passthepopcorn.me/torrents.php*
// @version     1.2
// @grant       none
// @require     http://code.jquery.com/jquery-3.3.1.min.js
// @icon        https://www.cinelounge.org/images/logoi.png
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // --- CAS 1 : SUR LA FICHE DU FILM (Détails) ---
    var $detailImdb = $('#imdb-title-link');
    if ($detailImdb.length > 0) {
        var detailHref = $detailImdb.attr('href');
        // On capture uniquement les chiffres après 'tt'
        var detailMatch = detailHref.match(/tt(\d+)/);

        if (detailMatch) {
            var imdbId = detailMatch[1]; // Uniquement les chiffres (ex: 1654829)
            var clUrl = 'https://www.cinelounge.org/imdb2cl/' + imdbId;

            // 1. Ajout dans le titre H2
            $('.page__title').prepend(
                '<a href="' + clUrl + '" target="_blank" style="vertical-align: middle; margin-right: 12px;">' +
                '<img src="https://www.cinelounge.org/images/logoi.png" style="width: 28px; border-radius: 4px;" title="Voir sur CinéLounge" />' +
                '</a>'
            );

            // 2. Ajout dans le tableau des Ratings
            var $imdbTdIcon = $detailImdb.closest('td');
            if ($imdbTdIcon.length > 0) {
                // Création de la cellule Icône CL
                var $clTdIcon = $('<td colspan="1" style="width: 95px;">' +
                                  '<center><a target="_blank" href="' + clUrl + '">' +
                                  '<img src="https://www.cinelounge.org/images/logoi.png" style="height:56px;width:56px;" title="CinéLounge">' +
                                  '</a></center></td>');

                // Création de la cellule Texte CL (vide ou "CL" pour l'alignement)
                var $clTdText = $('<td style="width: 80px;">' +
                                  '<a href="' + clUrl + '" target="_blank" style="font-weight: bold; font-size: 14px;">CinéLounge</a>' +
                                  '</td>');

                // Insertion avant IMDb
                $imdbTdIcon.before($clTdIcon);
                $clTdIcon.after($clTdText);
            }
        }
    }

    // --- CAS 2 : SUR LES LISTES DE FILMS (Browse / Search) ---
    $('div.basic-movie-list__movie__rating-container a[href*="imdb.com/title/tt"]').each(function() {
        var $imdbLink = $(this);
        var listHref = $imdbLink.attr('href');
        var listMatch = listHref.match(/tt(\d+)/);

        if (listMatch) {
            var listImdbId = listMatch[1]; // Uniquement les chiffres
            var listClUrl = 'https://www.cinelounge.org/imdb2cl/' + listImdbId;
            var $imdbContainer = $imdbLink.closest('.basic-movie-list__movie__rating-container');

            // On vérifie qu'on n'a pas déjà ajouté le bouton (évite les doublons)
            if ($imdbContainer.length > 0 && !$imdbContainer.prev().hasClass('cl-container')) {
                var $clContainer = $('<div class="basic-movie-list__movie__rating-container cl-container"></div>');
                var $clLink = $('<a href="' + listClUrl + '" target="_blank" style="font-weight: bold;">' +
                                '<img src="https://www.cinelounge.org/images/logoi.png" ' +
                                'style="width: 14px; vertical-align: middle; margin-right: 4px;" ' +
                                'title="Fiche CinéLounge" />CL</a>');

                $clContainer.append($clLink);
                $imdbContainer.before($clContainer);
            }
        }
    });

})();