// ==UserScript== // @name Douban-Info-for-PTP&HDB // @namespace https://github.com/techmovie/Douban-Info-for-PTP // @version 0.5.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 // @note 2021-01-12 支持hdb剧集 // @note 2021-01-24 修改豆瓣评分样式 // @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') const isHDBShow = isHDB && !!$j('.showlinks')[0] let imdbLink = null if (isPTP) { imdbLink = $('#imdb-title-link').attr('href') } if (isHDB && !isHDBShow) { imdbLink = $j('.contentlayout h1 a').attr('href') } if (isHDBShow) { imdbLink = $j('#details .showlinks li').eq(1).find('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) { const doubanId = data[0].id if (isHDBShow) { getTvInfo(doubanId) } else { getMovieInfo(doubanId) } } } }) const getTvInfo = (tvId) => { GM_xmlhttpRequest({ url: `${DOUBAN_API_URL}/tv/${tvId}?apiKey=${API_KEY}`, onload (res) { const data = JSON.parse(res.responseText) addInfoToHdbPage(data) } }) } 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 = `