// ==UserScript== // @name DOUBAN Movie info for RARBG // @namespace http://rarbg.to/ // @version 0.2 // @description Adds douban movie info to RARBG.to // @author tofuliang // @match https://rarbg.to/* // @match http://rarbg.to/* // @grant GM_xmlhttpRequest // @grant GM_getValue // @grant GM_setValue // @connect api.douban.com // @downloadURL none // ==/UserScript== function isEmpty(s) { return !s || s === 'N/A'; } $('body').on('mouseenter', 'a[href^="/torrents.php?imdb="]', function() { var imdbId = $(this).attr('href').split("=").pop(); function showDouBanInfo(data){ var html =''; html +='
'; html +='
'; html +='

'+data.title+' '+data.alt_title+' ('+data.attrs.year.join(' / ')+')

'; html +='
'; html +='
'; html +='
'; html +='

'+data.rating.average+' / '+data.rating.numRaters+'

'; html +='
'; html +='
'; if(!isEmpty(data.attrs.pubdate)){ html +='

上映时间: '+data.attrs.pubdate.join(' / ')+'

';} if(!isEmpty(data.attrs.movie_duration)){ html +='

片长: '+data.attrs.movie_duration.join(' / ')+'

';} if(!isEmpty(data.attrs.title)){ html +='

别名: '+data.attrs.title.join(' / ')+'

';} if(!isEmpty(data.attrs.director)){ html +='

导演: '+data.attrs.director.join(' / ')+'

';} if(!isEmpty(data.attrs.writer)){ html +='

编剧: '+data.attrs.writer.join(' / ')+'

';} if(!isEmpty(data.attrs.cast)){ html +='

主演: '+data.attrs.cast.join(' / ')+'

';} if(!isEmpty(data.attrs.movie_type)){ html +='

类型: '+data.attrs.movie_type.join(' / ')+'

';} if(!isEmpty(data.attrs.country)){ html +='

制片国家/地区: '+data.attrs.country.join(' / ')+'

';} if(!isEmpty(data.attrs.language)){ html +='

语言: '+data.attrs.language.join(' / ')+'

';} if(!isEmpty(data.summary)){ html +='

简介: '+data.summary+'

';} html +='
'; html +='
'; overlib(html); } var data = GM_getValue('douBanInfo_'+imdbId,undefined); if(undefined !== data && +(new Date()) - data.lastModify < 86400000 ){ showDouBanInfo(data); return; } GM_xmlhttpRequest({ method: 'GET', url: 'https://api.douban.com/v2/movie/imdb/' + imdbId, onload: function(response) { var data = JSON.parse(response.responseText); if (isEmpty(data.alt)) return; data.lastModify=+(new Date()); GM_setValue('douBanInfo_'+imdbId,data); showDouBanInfo(data); } }); }); $('.lista span:contains("IMDB:")').each(function(){ var txt=$(this).text(); var rate = txt.match(/MDB: ([\d\.]+)\/\d+/); if(undefined !==rate[1] && 6.0 <= parseFloat(rate[1])){ $(this).html($(this).text().replace(rate[1],''+rate[1]+'')); } }); var thisYear = (new Date()).getFullYear(); var years=[thisYear-2,thisYear-1,thisYear]; for( var i in years){ $('a[href^="/torrent/"]:contains("'+years[i]+'")').each(function(){ $(this).html($(this).text().replace(years[i],''+years[i]+'')); }); }