// ==UserScript== // @name Douban-Info-for-PTP // @namespace https://github.com/techmovie/Douban-Info-for-PTP // @version 0.3 // @description 在电影详情页展示部分中文信息 // @author Mekio // @match http*://passthepopcorn.me/torrents.php?id=* // @grant GM_xmlhttpRequest // @downloadURL none // ==/UserScript== (function () { 'use strict'; const API_KEY = '054022eaeae0b00e0fc068c0c0a2102a'; const DOUBAN_API_URL = 'https://frodo.douban.com/api/v2'; const DOUBAN_SEARCH_API = 'https://movie.douban.com/j/subject_suggest'; const imdbLink = $('#imdb-title-link').attr('href'); if (!imdbLink) { return } const imdbId = /tt\d+/.exec(imdbLink)[0]; GM_xmlhttpRequest({ method: 'GET', url: `${DOUBAN_SEARCH_API}?q=${imdbId}`, onload(res) { const data = JSON.parse(res.responseText); if (data.length > 0) { getMovieInfo(data[0].id) } } }) const getMovieInfo = (movieId) => { GM_xmlhttpRequest({ url: `${DOUBAN_API_URL}/movie/${movieId}?apiKey=${API_KEY}`, onload(res) { const data = JSON.parse(res.responseText); console.log(data); addInfoToPage(data); } }) } const addInfoToPage = (data) => { if (isChinese(data.title)) { $('.page__title').prepend(`[${data.title}] `) } if (data.intro) { $('#synopsis').html(data.intro) } $('#movieinfo').before(`