// ==UserScript== // @name Douban-Info-for-PTP&HDB // @namespace https://github.com/techmovie/Douban-Info-for-PTP // @version 0.4.1 // @description 在ptp和hdb电影详情页展示部分中文信息 // @author birdplane // @match https://passthepopcorn.me/torrents.php?id=* // @match https://hdbits.org/details.php?id=* // @grant GM_addStyle // @grant GM_xmlhttpRequest // @resource emptyIcon https://www.themoviedb.org/assets/2/v4/glyphicons/basic/glyphicons-basic-4-user-grey-d8fe957375e70239d6abdd549fd7568c89281b2179b5f4470e2e12895792dfa5.svg // @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 isPTP = location.host.includes('passthepopcorn'); const isHDB = location.host.includes('hdbits'); let imdbLink = null if(isPTP){ imdbLink = $('#imdb-title-link').attr('href'); } if(isHDB){ imdbLink = $j('.contentlayout h1 a').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); if(isPTP){ addInfoToPtpPage(data); } if(isHDB){ addInfoToHdbPage(data); } } }) } const addInfoToHdbPage = (data) => { const infoContent = `