PTP2CL

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

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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);
            }
        }
    });

})();