您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
在电影详情页展示部分中文信息
当前为
// ==UserScript== // @name TMDB-Info-for-PTP // @namespace https://github.com/techmovie/TMDB-Info-for-PTP // @version 0.2 // @description 在电影详情页展示部分中文信息 // @author Mekio // @match http*://passthepopcorn.me/torrents.php?id=* // @grant none // ==/UserScript== (function () { 'use strict'; const API_KEY = 'YOUR TMDB API_KEY'; const TMDB_URL = 'https://api.themoviedb.org/3'; const imdbLink = $('#imdb-title-link').attr('href'); if (!imdbLink) { return } const imdbId = /tt\d+/.exec(imdbLink)[0]; $.ajax({ url: `${TMDB_URL}/find/${imdbId}`, dataType: 'jsonp', data: { api_key: API_KEY, external_source: 'imdb_id' }, success(data) { if (data.movie_results.length > 0) { getMovieInfo(data.movie_results[0].id) } } }) const getMovieInfo = (movieId) => { $.ajax({ url: `${TMDB_URL}/movie/${movieId}`, dataType: 'jsonp', data: { api_key: API_KEY, language: 'zh-CN', append_to_response: 'credits,images' }, success(data) { addInfoToPage(data); } }) } const addInfoToPage = (data) => { const genres = data.genres.map(item => item.name) if (isChinese(data.title)) { $('.page__title').prepend(`<a target='_blank' href="https://www.themoviedb.org/movie/${data.id}">[${data.title}] </a>`) } if (data.overview) { $('#synopsis').html(data.overview) } if (genres.length > 0) { $('#movieinfo .panel__body').prepend(` <div><strong>类型:</strong> ${genres.join('/')}</div>`) } if (data.credits && data.credits.cast.length) { const casts = data.credits.cast.map(item => { const imageEl = item.profile_path ? ` <image style="width: 100%;" src="https://image.tmdb.org/t/p/w138_and_h175_face${item.profile_path}"></image>` : `<div style="background-image: url('https://www.themoviedb.org/assets/2/v4/glyphicons/basic/glyphicons-basic-4-user-grey-d8fe957375e70239d6abdd549fd7568c89281b2179b5f4470e2e12895792dfa5.svg'); width: auto; display: flex; align-content: center; align-items: center; flex-wrap: wrap; overflow: hidden; height: 100%; background-position: center center; background-repeat: no-repeat; background-color: #dbdbdb; box-sizing: border-box; background-size: 50%; text-overflow: ellipsis;"></div>` return `<li style="margin-top: 10px; margin-bottom: 10px; flex-shrink: 0; display: inline-block; margin-left: 10px; margin-right: 4px; width: 138px; background-color: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); padding-bottom: 10px; border-radius: 6px; overflow: hidden;"> <a target="_blank" href="https://www.themoviedb.org/person/${item.id}" style="width: 138px;height: 175px;display:block;"> ${imageEl} </a> <div style="color: #000;font-weight: bold;padding: 10px 10px 0;" class="actor-name"> <a target="_blank" style="color: #000;font-weight: bold" href="https://www.themoviedb.org/person/${item.id}">${item.name}</a></div> <div style="padding: 0 10px;font-size: 14px;color: #000;" class="role-name">${item.character}</div> </li>` }) const castPanelEl = `<div class="panel"> <div class="panel__heading"><span class="panel__heading__title">主演</span></div> <div class="panel__body"> <ul style="width: 100%;overflow-x: auto;display: flex;padding-left:0;word-break: break-all;"> ${casts.join('')} </ul> </div> </div>`; $('#synopsis-and-trailer').next('.panel').after(castPanelEl); } } const isChinese = (title) => { return /[\u4e00-\u9fa5]+/.test(title) } })();