Show Metacritic.com ratings (Safari)

Show metacritic metascore and user ratings on: Bandcamp, Apple Itunes (Music), Amazon (Music,Movies,TV Shows), IMDb (Movies), Google Play (Music, Movies), TV.com, Steam, Gamespot (PS4, XONE, PC), Rotten Tomatoes, Serienjunkies, BoxOfficeMojo, allmovie.com, movie.com, Wikipedia (en), themoviedb.org, letterboxd, TVmaze, TVGuide, followshows.com, TheTVDB.com, ConsequenceOfSound, Pitchfork, Last.fm

目前為 2016-01-03 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Show Metacritic.com ratings (Safari)
  3. // @description Show metacritic metascore and user ratings on: Bandcamp, Apple Itunes (Music), Amazon (Music,Movies,TV Shows), IMDb (Movies), Google Play (Music, Movies), TV.com, Steam, Gamespot (PS4, XONE, PC), Rotten Tomatoes, Serienjunkies, BoxOfficeMojo, allmovie.com, movie.com, Wikipedia (en), themoviedb.org, letterboxd, TVmaze, TVGuide, followshows.com, TheTVDB.com, ConsequenceOfSound, Pitchfork, Last.fm
  4. // @namespace cuzi
  5. // @oujs:author cuzi
  6. // @grant GM_xmlhttpRequest
  7. // @grant GM_setValue
  8. // @grant GM_getValue
  9. // @grant unsafeWindow
  10. // @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js
  11. // @license GNUGPL
  12. // @version 12
  13. // @include https://*.bandcamp.com/*
  14. // @include https://itunes.apple.com/*/album/*
  15. // @include https://play.google.com/store/music/album/*
  16. // @include https://play.google.com/store/movies/details/*
  17. // @include http://www.amazon.com/*
  18. // @include https://www.amazon.com/*
  19. // @include http://www.amazon.co.uk/*
  20. // @include https://www.amazon.co.uk/*
  21. // @include http://www.amazon.fr/*
  22. // @include https://www.amazon.fr/*
  23. // @include http://www.amazon.de/*
  24. // @include https://www.amazon.de/*
  25. // @include http://www.amazon.es/*
  26. // @include https://www.amazon.es/*
  27. // @include http://www.amazon.ca/*
  28. // @include https://www.amazon.ca/*
  29. // @include http://www.amazon.in/*
  30. // @include https://www.amazon.in/*
  31. // @include http://www.amazon.it/*
  32. // @include https://www.amazon.it/*
  33. // @include http://www.amazon.co.jp/*
  34. // @include https://www.amazon.co.jp/*
  35. // @include http://www.amazon.com.mx/*
  36. // @include https://www.amazon.com.mx/*
  37. // @include http://www.amazon.com.au/*
  38. // @include https://www.amazon.com.au/*
  39. // @include http://www.imdb.com/title/*
  40. // @include https://www.imdb.com/title/*
  41. // @include http://store.steampowered.com/app/*
  42. // @include https://store.steampowered.com/app/*
  43. // @include http://www.gamespot.com/*
  44. // @include https://www.gamespot.com/*
  45. // @include http://www.serienjunkies.de/*
  46. // @include https://www.serienjunkies.de/*
  47. // @include http://www.tv.com/shows/*
  48. // @include http://www.rottentomatoes.com/m/*
  49. // @include https://www.rottentomatoes.com/m/*
  50. // @include http://www.rottentomatoes.com/tv/*
  51. // @include https://www.rottentomatoes.com/tv/*
  52. // @include http://www.boxofficemojo.com/movies/*
  53. // @include http://www.allmovie.com/movie/*
  54. // @include https://en.wikipedia.org/*
  55. // @include http://www.movies.com/*/m*
  56. // @include https://www.themoviedb.org/movie/*
  57. // @include https://www.themoviedb.org/tv/*
  58. // @include http://letterboxd.com/film/*
  59. // @include https://letterboxd.com/film/*
  60. // @include http://www.tvmaze.com/shows/*
  61. // @include http://www.tvguide.com/tvshows/*
  62. // @include https://www.tvguide.com/tvshows/*
  63. // @include http://followshows.com/show/*
  64. // @include https://followshows.com/show/*
  65. // @include http://thetvdb.com/*tab=series*
  66. // @include https://thetvdb.com/*tab=series*
  67. // @include http://consequenceofsound.net/*
  68. // @include http://pitchfork.com/reviews/albums/*
  69. // @include http://www.last.fm/music/*/*
  70. // ==/UserScript==
  71.  
  72.  
  73. // ###### For Safari
  74. if (!String.prototype.startsWith) {
  75. String.prototype.startsWith = function(searchString, position) {
  76. position = position || 0;
  77. return this.indexOf(searchString, position) === position;
  78. };
  79. }
  80. // ###### For Safari
  81. if (!String.prototype.normalize) {
  82. String.prototype.normalize = function(s) {
  83. return ""+this;
  84. };
  85. }
  86.  
  87.  
  88. var baseURL = "http://www.metacritic.com/";
  89.  
  90. var baseURL_music = "http://www.metacritic.com/music/";
  91. var baseURL_movie = "http://www.metacritic.com/movie/";
  92. var baseURL_pcgame = "http://www.metacritic.com/game/pc/";
  93. var baseURL_ps4 = "http://www.metacritic.com/game/playstation-4/";
  94. var baseURL_xone = "http://www.metacritic.com/game/xbox-one/";
  95. var baseURL_tv = "http://www.metacritic.com/tv/";
  96.  
  97. var baseURL_search = "http://www.metacritic.com/search/{type}/{query}/results";
  98. var baseURL_autosearch = "http://www.metacritic.com/autosearch";
  99.  
  100. var baseURL_database = "https://php-cuzi.rhcloud.com/r.php";
  101. var baseURL_whitelist = "https://php-cuzi.rhcloud.com/whitelist.php";
  102. var baseURL_blacklist = "https://php-cuzi.rhcloud.com/blacklist.php";
  103.  
  104. var mybrowser = "other";
  105. if(~navigator.userAgent.indexOf("Chrome") || ~navigator.userAgent.indexOf("Safari")) {
  106. mybrowser = "chrome";
  107. }
  108.  
  109. // http://www.designcouch.com/home/why/2013/05/23/dead-simple-pure-css-loading-spinner/
  110. var CSS = "#mcdiv123 .grespinner{height:16px;width:16px;margin:0 auto;position:relative;-webkit-animation:rotation .6s infinite linear;-moz-animation:rotation .6s infinite linear;-o-animation:rotation .6s infinite linear;animation:rotation .6s infinite linear;border-left:6px solid rgba(0,174,239,.15);border-right:6px solid rgba(0,174,239,.15);border-bottom:6px solid rgba(0,174,239,.15);border-top:6px solid rgba(0,174,239,.8);border-radius:100%}@-webkit-keyframes rotation{from{-webkit-transform:rotate(0)}to{-webkit-transform:rotate(359deg)}}@-moz-keyframes rotation{from{-moz-transform:rotate(0)}to{-moz-transform:rotate(359deg)}}@-o-keyframes rotation{from{-o-transform:rotate(0)}to{-o-transform:rotate(359deg)}}@keyframes rotation{from{transform:rotate(0)}to{transform:rotate(359deg)}}#mcdiv123searchresults .result{font:12px arial,helvetica,serif;border-top-width:1px;border-top-color:#ccc;border-top-style:solid;padding:5px}#mcdiv123searchresults .result .result_type{display:inline}#mcdiv123searchresults .result .result_wrap{float:left;width:100%}#mcdiv123searchresults .result .has_score{padding-left:42px}#mcdiv123searchresults .result .basic_stats{height:1%;overflow:hidden}#mcdiv123searchresults .result h3{font-size:14px;font-weight:700}#mcdiv123searchresults .result a{color:#09f;font-weight:700;text-decoration:none}#mcdiv123searchresults .metascore_w.game.seventyfive,#mcdiv123searchresults .metascore_w.positive,#mcdiv123searchresults .metascore_w.score_favorable,#mcdiv123searchresults .metascore_w.score_outstanding,#mcdiv123searchresults .metascore_w.sixtyone{background-color:#6c3}#mcdiv123searchresults .metascore_w.forty,#mcdiv123searchresults .metascore_w.game.fifty,#mcdiv123searchresults .metascore_w.mixed,#mcdiv123searchresults .metascore_w.score_mixed{background-color:#fc3}#mcdiv123searchresults .metascore_w.negative,#mcdiv123searchresults .metascore_w.score_terrible,#mcdiv123searchresults .metascore_w.score_unfavorable{background-color:red}#mcdiv123searchresults a.metascore_w,#mcdiv123searchresults span.metascore_w{display:inline-block}#mcdiv123searchresults .result .metascore_w{color:#fff!important;font-family:Arial,Helvetica,sans-serif;font-size:17px;font-style:normal!important;font-weight:700!important;height:2em;line-height:2em;text-align:center;vertical-align:middle;width:2em;float:left;margin:0 0 0 -42px}#mcdiv123searchresults .result .more_stats{font-size:10px;color:#444}#mcdiv123searchresults .result .release_date .data{font-weight:700;color:#000}#mcdiv123searchresults ol,#mcdiv123searchresults ul{list-style:none}#mcdiv123searchresults .result li.stat{background:0 0;display:inline;float:left;margin:0;padding:0 6px 0 0;white-space:nowrap}#mcdiv123searchresults .result .deck{margin:3px 0 0}#mcdiv123searchresults .result .basic_stat{display:inline;float:right;overflow:hidden;width:100%}";
  111.  
  112. function getHostname(url) {
  113. with(document.createElement("a")) {
  114. href = url;
  115. return hostname;
  116. }
  117. }
  118. function name2metacritic(s) {
  119. return s.normalize('NFKD').replace(/\//g,"").replace(/[\u0300-\u036F]/g, '').replace(/&/g,"and").replace(/\W+/g, " ").toLowerCase().trim().replace(/\W+/g,"-");
  120. }
  121. function minutesSince(time) {
  122. var seconds = ((new Date()).getTime() - time.getTime()) / 1000;
  123. return seconds>60?parseInt(seconds/60)+" min ago":"now";
  124. }
  125. function randomStringId() {
  126. var id10 = function() { return Math.floor((1 + Math.random()) * 0x10000000000).toString(16).substring(1); };
  127. return id10()+id10()+id10()+id10()+id10()+id10();
  128. }
  129. function fixMetacriticURLs(html) {
  130. return html.replace(/<a /g,'<a target="_blank" ').replace(/href="\//g,'href="'+baseURL).replace(/src="\//g,'src="'+baseURL);
  131. }
  132. function searchType2metacritic(type) {
  133. return ({
  134. 'movie' : 'movie',
  135. 'pcgame' : 'game',
  136. 'xonegame' : 'game',
  137. 'ps4game' : 'game',
  138. 'music' : 'album',
  139. 'tv' : 'tv'
  140. })[type];
  141. }
  142. function metacritic2searchType(type) {
  143. return ({
  144. "Album" : "music",
  145. "TV" : "tv",
  146. "Movie" : "movie",
  147. "PC Game" : "pcgame",
  148. "PS4 Game" : "ps4game",
  149. "XONE Game" : "onegame",
  150. "WIIU Game" : "xxxxx",
  151. "3DS Game" : "xxxx"
  152. })[type];
  153. }
  154.  
  155.  
  156. function metaScore(score, word) {
  157. var fg,bg,t;
  158. if(score == null) {
  159. fg = "black";
  160. bg = "#ccc";
  161. t = "tbd";
  162. } else if(score >= 75) {
  163. fg = "white";
  164. bg = "#6c3";
  165. t = parseInt(score);
  166. } else if(score < 40) {
  167. fg = "white";
  168. bg = "#f00";
  169. t = parseInt(score);
  170. } else {
  171. fg = "white";
  172. bg = "#fc3";
  173. t = parseInt(score);
  174. }
  175. return '<span title="'+(word?word:'')+'" style="display: inline-block; color: '+fg+';background:'+bg+';font-family: Arial,Helvetica,sans-serif;font-size: 17px;font-style: normal;font-weight: bold;height: 2em;width: 2em;line-height: 2em;text-align: center;vertical-align: middle;">'+t+'</span>';
  176. }
  177.  
  178. function filterUniversalUrl(url) {
  179. try {
  180. url = url.match(/http.+/)[0];
  181. } catch(e) { }
  182. try {
  183. url = url.replace(/https?:\/\/(www.)?/,"");
  184. } catch(e) { }
  185. if(url.startsWith("somehost")) {// TODO
  186. return url; // Do not remove parameters
  187. } else {
  188. return url.split("?")[0].split("&")[0]; // Remove parameters
  189. }
  190. }
  191.  
  192. function addToMap(url, metaurl) {
  193. var data = JSON.parse(GM_getValue("map","{}"));
  194. var url = filterUniversalUrl(url);
  195. var metaurl = metaurl.replace(/^http:\/\/(www.)?metacritic\.com\//,"");
  196.  
  197. data[url] = metaurl;
  198. GM_setValue("map", JSON.stringify(data));
  199. (new Image()).src = baseURL_whitelist + "?docurl="+encodeURIComponent(url)+"&metaurl="+encodeURIComponent(metaurl)+"&ref="+encodeURIComponent(randomStringId());
  200. return [url, metaurl];
  201. }
  202.  
  203. function addToBlacklist(url, metaurl) {
  204. var data = JSON.parse(GM_getValue("black","{}"));
  205. var url = filterUniversalUrl(url);
  206. var metaurl = metaurl.replace(/^http:\/\/(www.)?metacritic\.com\//,"");
  207.  
  208. data[url] = metaurl;
  209. GM_setValue("black", JSON.stringify(data));
  210. (new Image()).src = baseURL_blacklist + "?docurl="+encodeURIComponent(url)+"&metaurl="+encodeURIComponent(metaurl)+"&ref="+encodeURIComponent(randomStringId());
  211. return [url, metaurl];
  212. }
  213.  
  214. function isBlacklistedUrl(docurl, metaurl) {
  215. docurl = filterUniversalUrl(docurl);
  216. docurl = docurl.replace(/https?:\/\/(www.)?/,"");
  217. metaurl = metaurl.replace(/^http:\/\/(www.)?metacritic\.com\//,"");
  218. metaurl = metaurl.replace(/\/\//g,"/").replace(/\/\//g,"/");; // remove double slash
  219. var data = JSON.parse(GM_getValue("black","{}"));
  220. if(docurl in data) {
  221. if(data[docurl] == metaurl) {
  222. return true;
  223. }
  224. }
  225. return false;
  226. }
  227.  
  228. function isBlacklisted(metaurl) {
  229. return isBlacklistedUrl("" + document.location.host.replace(/^www\./,"") + document.location.pathname + document.location.search, metaurl);
  230. }
  231.  
  232.  
  233.  
  234. function listenForHotkeys(code, cb) {
  235. // Call cb() as soon as the code sequence was typed
  236. var i = 0;
  237. $(document).bind("keydown.listenForHotkeys",function(ev) {
  238. if(document.activeElement == document.body) {
  239. if(ev.key != code[i]) {
  240. i = 0;
  241. } else {
  242. i++;
  243. if(i == code.length) {
  244. ev.preventDefault();
  245. $(document).unbind("keydown.listenForHotkeys");
  246. cb();
  247. }
  248. }
  249. }
  250. });
  251. }
  252.  
  253.  
  254. function metacritic_hoverInfo(url, docurl, cb, errorcb) {
  255. // Get the metacritic hover info. Requests are cached.
  256. var handleresponse = function(response, cached) {
  257. if(response.status == 200 && cb) {
  258. if(~response.responseText.indexOf('"jsonRedirect"')) { // {"viewer":{},"mixpanelToken":"6e219fd....","mixpanelDistinctId":"255.255.255.255","omnitureDebug":0,"jsonRedirect":"\/movie\/national-lampoons-vacation"}
  259. var j = JSON.parse(response.responseText);
  260. current.url = baseURL + j["jsonRedirect"];
  261. delete cache[url]; // Delete original url from cache. The redirect URL will then be saved in metacritic_hoverInfo(...)
  262. metacritic_hoverInfo(baseURL + j["jsonRedirect"], false, cb, errorcb);
  263. } else {
  264. cb(response.responseText, new Date(response.time));
  265. }
  266. } else if(response.status != 200 && errorcb) {
  267. errorcb(response.responseText, new Date(response.time));
  268. if(!cached)
  269. console.log("Show metacritic ratings: Error:"+response.status+"\n"+url);
  270. }
  271. };
  272. var cache = JSON.parse(GM_getValue("hovercache","{}"));
  273. for(var prop in cache) {
  274. // Delete cached values, that are older than 2 hours
  275. if((new Date()).getTime() - (new Date(cache[prop].time)).getTime() > 2*60*60*1000) {
  276. delete cache[prop];
  277. }
  278. }
  279. if(url in cache) {
  280. handleresponse(cache[url], true);
  281. } else {
  282. var requestURL = url;
  283. var requestParams = "hoverinfo=1";
  284. if(docurl && docurl.indexOf("metacritic.com") == -1 && docurl.indexOf(baseURL_database) == -1) {
  285. // Ask database for correct metacritic entry:
  286. requestURL = baseURL_database;
  287. requestParams = "m=" + encodeURIComponent(docurl) + "&a=" + encodeURIComponent(url);
  288. }
  289. GM_xmlhttpRequest({
  290. method: "POST",
  291. url: requestURL,
  292. data: requestParams,
  293. headers: {
  294. "Referer" : url,
  295. "Content-Type" : "application/x-www-form-urlencoded; charset=UTF-8",
  296. "Host" : getHostname(requestURL), // This is important, otherwise Metacritic refuses to answer!
  297. "User-Agent" : "MetacriticUserscript "+navigator.userAgent,
  298. "X-Requested-With" : "XMLHttpRequest"
  299. },
  300. onload: function(response) {
  301. response.time = (new Date()).toJSON();
  302. cache[url] = response;
  303. GM_setValue("hovercache",JSON.stringify(cache));
  304. handleresponse(response, false);
  305. },
  306. onerror: function(response) {
  307. console.log("Show metacritic ratings: Hover info error: "+response.status+"\nURL: "+requestURL+"\nResponse:\n"+response.responseText);
  308. },
  309. });
  310. }
  311. }
  312. function metacritic_searchResults(url, cb, errorcb) {
  313. // Get metacritic search results. Requests are cached.
  314. var handleresponse = function(response, cached) {
  315. if(response.results.length && cb) {
  316. cb(response.results, new Date(response.time));
  317. } else if(response.results.length == 0 && errorcb) {
  318. errorcb(response.results, new Date(response.time));
  319. }
  320. };
  321. var cache = JSON.parse(GM_getValue("searchcache","{}"));
  322. for(var prop in cache) {
  323. // Delete cached values, that are older than 2 hours
  324. if((new Date()).getTime() - (new Date(cache[prop].time)).getTime() > 2*60*60*1000) {
  325. delete cache[prop];
  326. }
  327. }
  328. if(url in cache) {
  329. handleresponse(cache[url], true);
  330. } else {
  331. GM_xmlhttpRequest({
  332. method: "GET",
  333. url: url,
  334. headers: {
  335. "Referer" : url,
  336. "Content-Type" : "application/x-www-form-urlencoded; charset=UTF-8",
  337. "Host" : "www.metacritic.com",
  338. "User-Agent" : "MetacriticUserscript "+navigator.userAgent,
  339. },
  340. onload: function(response) {
  341. var results = [];
  342. if(!~response.responseText.indexOf("No search results found.")) {
  343. var d = $('<html>').html(response.responseText);
  344. d.find("ul.search_results.module .result").each(function() {
  345. results.push(this.innerHTML);
  346. });
  347. }
  348.  
  349. response = {
  350. time : (new Date()).toJSON(),
  351. results : results,
  352. };
  353. cache[url] = response;
  354. GM_setValue("searchcache",JSON.stringify(cache));
  355. handleresponse(response, false);
  356. },
  357. onerror: function(response) {
  358. console.log("Show metacritic ratings: Search error: "+response.status+"\n"+url);
  359. handleresponse({
  360. time : (new Date()).toJSON(),
  361. results : [],
  362. }, false);
  363. }
  364. });
  365. }
  366. }
  367.  
  368. function metacritic_showHoverInfo(url, docurl) {
  369. if(!url) {
  370. return;
  371. }
  372. metacritic_hoverInfo(url, docurl?docurl:false,
  373. // On Success
  374. function(html, time) {
  375. $("#mcdiv123").remove();
  376. var div = $('<div id="mcdiv123"></div>').appendTo(document.body);
  377. div.css({
  378. position:"fixed",
  379. bottom :0,
  380. left: 0,
  381. minWidth: 300,
  382. backgroundColor: "#fff",
  383. border: "2px solid #bbb",
  384. borderRadius:" 6px",
  385. boxShadow: "0 0 3px 3px rgba(100, 100, 100, 0.2)",
  386. color: "#000",
  387. padding:" 3px",
  388. zIndex: "5010001",
  389. });
  390. // Functions for communication between page and iframe
  391. // Mozilla can access parent.document
  392. // Chrome can use postMessage()
  393. var functions = {
  394. "other" : {
  395. "parent": function() {},
  396. "frame" : function sizecorrection() {
  397. var f = parent.document.getElementById('mciframe123');
  398. for(var i =0; f.clientHeight < document.body.scrollHeight && i < 100; i++) {
  399. f.style.width = parseInt(f.style.width)+10+"px";
  400. }
  401. if(f.clientHeight < document.body.scrollHeight) {
  402. f.style.height = parseInt(f.style.height)+15+"px";
  403. f.style.width = "300px";
  404. sizecorrection();
  405. }
  406. }
  407. },
  408. "chrome" : {
  409. "parent" : function() {
  410. var f = parent.document.getElementById('mciframe123');
  411. window.addEventListener("message", function(e){
  412. if("mcimessage1" in e.data) {
  413. f.style.width = parseInt(f.style.width)+10+"px";
  414. } else if("mcimessage2" in e.data) {
  415. f.style.height = parseInt(f.style.height)+15+"px";
  416. f.style.width = "300px";
  417. } else {
  418. return;
  419. }
  420. f.contentWindow.postMessage({
  421. "mcimessage3" : true,
  422. "mciframe123_clientHeight" : f.clientHeight,
  423. "mciframe123_clientWidth" : f.clientWidth,
  424. },'*');
  425. });
  426. },
  427. "frame" : function() {
  428. var i = 0;
  429. window.addEventListener("message", function(e){
  430. if(!("mcimessage3" in e.data)) return;
  431. if(e.data.mciframe123_clientHeight < document.body.scrollHeight && i < 100) {
  432. parent.postMessage({"mcimessage1":1},'*');
  433. i++;
  434. }
  435. if(i >= 100) {
  436. parent.postMessage({"mcimessage2":1},'*')
  437. i = 0;
  438. }
  439. });
  440. parent.postMessage({"mcimessage1":1},'*');
  441. }
  442. }
  443. };
  444. var framesrc = 'data:text/html,';
  445. framesrc += encodeURIComponent('<!DOCTYPE html>\
  446. <html lang="en">\
  447. <head>\
  448. <meta charset="utf-8">\
  449. <title>Metacritic info</title>\
  450. <style>body { margin:0px; padding:0px; background:white; }'+"\
  451. .clr { clear: both}#hover_div { background-color: #fff; color: #666; font-family:Arial,Helvetica,sans-serif; font-size:12px; font-weight:400; font-style:normal;}.hoverinfo .hover_left { float: left}.hoverinfo .product_image_wrapper { color: #999; font-size: 6px; font-weight: normal; min-height: 98px; min-width: 98px;}.hoverinfo .product_image_wrapper a { color: #999; font-size: 6px; font-weight: normal;}a * { cursor: pointer}a { color: #09f; font-weight: bold;}a:link, a:visited { text-decoration: none;}a:hover { text-decoration: underline;}.hoverinfo .hover_right { float: left; margin-left: 15px; max-width: 395px;}.hoverinfo .product_title { color: #333; font-family: georgia,serif; font-size: 24px; line-height: 26px; margin-bottom: 10px;}.hoverinfo .product_title a { color:#333; font-family: georgia,serif; font-size: 24px;}.hoverinfo .summary_detail.publisher, .hoverinfo .summary_detail.release_data { float: left}.hoverinfo .summary_detail { font-size: 11px; margin-bottom: 10px;}.hoverinfo .summary_detail.product_credits a { color: #999; font-weight: normal; }.hoverinfo .hr { background-color: #ccc; height: 2px; margin: 15px 0 10px;}.hoverinfo .hover_scores { width: 100%; border-collapse: collapse; border-spacing: 0;}.hoverinfo .hover_scores td.num { width: 39px}.hoverinfo .hover_scores td { vertical-align: middle}caption, th, td { font-weight: normal; text-align: left;}.metascore_anchor, a.metascore_w { text-decoration: none !important}span.metascore_w, a.metascore_w { display: inline-block}.metascore_w { background-color: transparent; color: #fff !important; font-family: Arial,Helvetica,sans-serif; font-size: 17px; font-style: normal !important; font-weight: bold !important; height: 2em; line-height: 2em; text-align: center; vertical-align: middle; width: 2em;}.metascore, .metascore a, .avguserscore, .avguserscore a { color: #fff}.critscore, .critscore a, .userscore, .userscore a { color: #333}.score_tbd { background: #eaeaea; color: #333; font-size: 14px;}.score_tbd a { color: #333}.negative, .score_terrible, .score_unfavorable, .carousel_set a.product_terrible:hover, .carousel_set a.product_unfavorable:hover { background-color: #f00}.mixed, .neutral, .score_mixed, .carousel_set a.product_mixed:hover { background-color: #fc3; color: #333;}.score_mixed a { color: #333}.positive, .score_favorable, .score_outstanding, .carousel_set a.product_favorable:hover, .carousel_set a.product_outstanding:hover { background-color: #6c3}.critscore_terrible, .critscore_unfavorable { border-color: #f00}.critscore_mixed { border-color: #fc3}.critscore_favorable, .critscore_outstanding { border-color: #6c3}.metascore .score_total, .userscore .score_total { display: none; visibility: hidden;}.hoverinfo .metascore_label, .hoverinfo .userscore_label { font-size: 12px; font-weight: bold; line-height: 16px; margin-top: 2%;}.hoverinfo .metascore_review_count, .hoverinfo .userscore_review_count { font-size: 11px}.hoverinfo .hover_scores td { vertical-align: middle}.hoverinfo .hover_scores td.num { width: 39px}.hoverinfo .hover_scores td.usr.num { padding-left: 20px}.metascore_anchor, a.metascore_w { text-decoration: none !important}.metascore_w.user { border-radius: 55%; color: #fff;}.metascore_anchor, a.metascore_w { text-decoration: none!important}.metascore_anchor:hover { text-decoration: none!important}.metascore_w:hover { text-decoration: none!important}span.metascore_w, a.metascore_w { display: inline-block}.metascore_w.xlarge, .metascore_w.xl { font-size: 42px}.metascore_w.large, .metascore_w.lrg { font-size: 25px}.m .metascore_w.medium, .m .metascore_w.med { font-size: 19px}.metascore_w.med_small { font-size: 14px}.metascore_w.small, .metascore_w.sm { font-size: 12px}.metascore_w.tiny { height: 1.9em; font-size: 11px; line-height: 1.9em;}.metascore_w.user { border-radius: 55%; color: #fff;}.metascore_w.user.small, .metascore_w.user.sm { font-size: 11px}.metascore_w.tbd, .metascore_w.score_tbd { color: #000!important; background-color: #ccc;}.metascore_w.tbd.hide_tbd, .metascore_w.score_tbd.hide_tbd { visibility: hidden}.metascore_w.tbd.no_tbd, .metascore_w.score_tbd.no_tbd { display: none}.metascore_w.noscore::before, .metascore_w.score_noscore::before { content: '\2022\2022\2022'}.metascore_w.noscore, .metascore_w.score_noscore { color: #fff!important; background-color: #ccc;}.metascore_w.rip, .metascore_w.score_rip { border-radius: 4px; color: #fff!important; background-color: #999;}.metascore_w.negative, .metascore_w.score_terrible, .metascore_w.score_unfavorable { background-color: #f00}.metascore_w.mixed, .metascore_w.forty, .metascore_w.game.fifty, .metascore_w.score_mixed { background-color: #fc3}.metascore_w.positive, .metascore_w.sixtyone, .metascore_w.game.seventyfive, .metascore_w.score_favorable, .metascore_w.score_outstanding { background-color: #6c3}.metascore_w.indiv { height: 1.9em; width: 1.9em; font-size: 15px; line-height: 1.9em;}.metascore_w.indiv.large, .metascore_w.indiv.lrg { font-size: 24px}.m .metascore_w.indiv.medium, .m .metascore_w.indiv.med { font-size: 16px}.metascore_w.indiv.small, .metascore_w.indiv.sm { font-size: 11px}.metascore_w.indiv.perfect { padding-right: 1px}.promo_amazon .esite_btn { margin: 3px 0 0 7px;}.esite_amazon { background-color: #fdc354; border: 1px solid #aaa;}.esite_label_wrapper { display:none;}.esite_btn { border-radius: 4px; color: #222; font-size: 12px; height: 40px; line-height: 40px; width: 120px;}"+'\
  452. </style>\
  453. <script>\
  454. function on_load() {\
  455. ('+functions[mybrowser].frame.toString()+')();\
  456. }\
  457. </script>\
  458. </head>\
  459. <body onload="on_load();">\
  460. <div style="border:0px solid; display:block; position:relative; border-radius:0px; padding:0px; margin:0px; box-shadow:none;" class="hover_div" id="hover_div">\
  461. <div class="hover_content">'+fixMetacriticURLs(html)+'</div>\
  462. </div>\
  463. </body>\
  464. </html>');
  465.  
  466. var frame = $("<iframe></iframe>").appendTo(div);
  467. frame.attr("id","mciframe123");
  468. frame.attr("src",framesrc);
  469. frame.attr("scrolling","auto");
  470. frame.css({
  471. width: 300,
  472. height: 170,
  473. border: "none"
  474. });
  475. functions[mybrowser].parent();
  476. var sub = $("<div></div>").appendTo(div);
  477. $('<time style="color:#b6b6b6; font-size: 11px;" datetime="'+time+'" title="'+time.toLocaleFormat()+'">'+minutesSince(time)+'</time>').appendTo(sub);
  478. $('<a style="color:#b6b6b6; font-size: 11px;" target="_blank" href="'+url+'" title="Open Metacritic">'+decodeURI(url.replace("http://www.","@"))+'</a>').appendTo(sub);
  479. $('<span title="Hide me" style="cursor:pointer; float:right; color:#b6b6b6; font-size: 11px;">&#128128;</span>').appendTo(sub).click(function() {
  480. document.body.removeChild(this.parentNode.parentNode);
  481. });
  482. $('<span title="This is the correct entry" style="cursor:pointer; float:right; color:green; font-size: 11px;">&check;</span>').data("url", url).appendTo(sub).click(function() {
  483. var docurl = document.location.href;
  484. var metaurl = $(this).data("url");
  485. var r = addToMap(docurl,metaurl);
  486. alert("Saved to correct list!\n\n"+r[0]+"\n"+r[1]);
  487. });
  488. $('<span title="This is NOT the correct entry" style="cursor:pointer; float:right; color:crimson; font-size: 11px;">&cross;</span>').data("url", url).appendTo(sub).click(function() {
  489. if(!confirm("This is NOT the correct entry!\n\nAdd to blacklist?")) return;
  490. var docurl = document.location.href;
  491. var metaurl = $(this).data("url");
  492. var r = addToBlacklist(docurl,metaurl);
  493. alert("Saved to blacklist!\n\n"+r[0]+"\n"+r[1]);
  494. // Open search
  495. metacritic_searchcontainer(null, current.searchTerm);
  496. metacritic_search(null, current.searchTerm);
  497. });
  498.  
  499. },
  500. // On error i.e. no result on metacritic.com
  501. function(html, time) {
  502. // Make search available
  503. metacritic_waitForHotkeys();
  504. var handleresponse = function(response) {
  505. var data;
  506. try {
  507. data = JSON.parse(response.responseText);
  508. } catch(e) {
  509. console.log("Error in JSON: search_term="+current.searchTerm);
  510. console.log(e);
  511. }
  512. if(data && data.autoComplete && data.autoComplete.length) {
  513. // Remove data with wrong type
  514. var newdata = [];
  515. data.autoComplete.forEach(function(result) {
  516. if(metacritic2searchType(result.refType) == current.type) {
  517. newdata.push(result);
  518. }
  519. });
  520. data.autoComplete = newdata;
  521. if(data.autoComplete.length == 0) {
  522. // No results
  523. console.log("No results (after filtering by type) for search_term="+current.searchTerm);
  524. } else if(data.autoComplete.length == 1) {
  525. // One result, let's show it
  526. if(!isBlacklisted(baseURL + data.autoComplete[0].url)) {
  527. metacritic_showHoverInfo(baseURL + data.autoComplete[0].url);
  528. return;
  529. }
  530. } else {
  531. // More than one result
  532. console.log("Multiple results for search_term="+current.searchTerm);
  533. var exactMatches = [];
  534. data.autoComplete.forEach(function(result,i) { // Try to find the correct result by matching the search term to exactly one movie title
  535. if(current.searchTerm == result.name) {
  536. exactMatches.push(result);
  537. }
  538. });
  539. if(exactMatches.length == 1) {
  540. // Only one exact match, let's show it
  541. if(!isBlacklisted(baseURL + exactMatches[0].url)) {
  542. metacritic_showHoverInfo(baseURL + exactMatches[0].url);
  543. return;
  544. }
  545. }
  546. }
  547. }
  548. // HERE: multiple results or no result. The user may type "meta" now
  549. };
  550. var cache = JSON.parse(GM_getValue("autosearchcache","{}"));
  551. for(var prop in cache) {
  552. // Delete cached values, that are older than 2 hours
  553. if((new Date()).getTime() - (new Date(cache[prop].time)).getTime() > 2*60*60*1000) {
  554. delete cache[prop];
  555. }
  556. }
  557. current.searchTerm = current.data.join(" ");
  558. if(current.searchTerm in cache) {
  559. handleresponse(cache[current.searchTerm], true);
  560. } else {
  561. GM_xmlhttpRequest({
  562. method: "POST",
  563. url: baseURL_autosearch,
  564. data: "search_term="+encodeURIComponent(current.searchTerm),
  565. headers: {
  566. "Referer" : url,
  567. "Content-Type" : "application/x-www-form-urlencoded; charset=UTF-8",
  568. "Host" : "www.metacritic.com",
  569. "User-Agent" : "MetacriticUserscript Mozilla/5.0 (Android 4.4; Mobile; rv:41.0) Gecko/41.0 Firefox/41.0",
  570. "X-Requested-With" : "XMLHttpRequest"
  571. },
  572. onload: function(response) {
  573. response = {
  574. time : (new Date()).toJSON(),
  575. responseText : response.responseText,
  576. };
  577. cache[current.searchTerm] = response;
  578. GM_setValue("autosearchcache",JSON.stringify(cache));
  579. handleresponse(response, false);
  580. }
  581. });
  582. }
  583. });
  584. }
  585.  
  586. function metacritic_waitForHotkeys() {
  587. listenForHotkeys("meta",metacritic_searchcontainer);
  588. }
  589.  
  590. function metacritic_searchcontainer(ev, query) {
  591. if(!query) {
  592. query = current.data.join(" ");
  593. }
  594. $("#mcdiv123").remove();
  595. var div = $('<div id="mcdiv123"></div>').appendTo(document.body);
  596. div.css({
  597. position:"fixed",
  598. bottom :0,
  599. left: 0,
  600. minWidth: 300,
  601. maxHeight: "80%",
  602. maxWidth: 640,
  603. overflow:"auto",
  604. backgroundColor: "#fff",
  605. border: "2px solid #bbb",
  606. borderRadius:" 6px",
  607. boxShadow: "0 0 3px 3px rgba(100, 100, 100, 0.2)",
  608. color: "#000",
  609. padding:" 3px",
  610. zIndex: "5010001",
  611. });
  612. var query = $('<input type="text" size="60" id="mcisearchquery">').appendTo(div).focus().val(query).on('keypress', function(e) {
  613. var code = e.keyCode || e.which;
  614. if(code == 13) { // Enter key
  615. metacritic_search.call(this,e);
  616. }
  617. });
  618. $('<button id="mcisearchbutton">').text("Search").appendTo(div).click(metacritic_search);
  619. }
  620.  
  621.  
  622. function metacritic_search(ev, query) {
  623. if(!query) { // Use values from search form
  624. query = $("#mcisearchquery").val();
  625. }
  626. var type = current.type;
  627.  
  628. var style = document.createElement('style');
  629. style.type = 'text/css';
  630. style.innerHTML = CSS;
  631. document.head.appendChild(style);
  632. var div = $("#mcdiv123");
  633. var loader = $('<div style="width:20px; height:20px;" class="grespinner"></div>').appendTo($("#mcisearchbutton"));
  634. var url = baseURL_search.replace("{type}",encodeURIComponent(type)).replace("{query}",encodeURIComponent(query));
  635. metacritic_searchResults(url,
  636. // On success
  637. function(results, time) {
  638. loader.remove();
  639. var accept = function(ev) {
  640. var a = $(this.parentNode).find("a[href*='metacritic.com']");
  641. var metaurl = a.attr("href");
  642. var docurl = document.location.href;
  643.  
  644. addToMap(docurl,metaurl);
  645. metacritic_showHoverInfo(metaurl);
  646. };
  647. var denyAll = function(ev) {
  648. var urls = [];
  649. var docurl = document.location.href;
  650. $("#mcdiv123searchresults").find("div.result a[href*='metacritic.com']").each(function() {
  651. addToBlacklist(docurl, this.href);
  652. });
  653. };
  654. var resultdiv = $("#mcdiv123searchresults").length?$("#mcdiv123searchresults").html(""):$('<div id="mcdiv123searchresults"></div>').css("max-width","95%").appendTo(div);
  655. results.forEach(function(html) {
  656. var singleresult = $('<div class="result"></div>').html(fixMetacriticURLs(html)+'<div style="clear:left"></div>').appendTo(resultdiv);
  657. $('<span title="This is the correct entry" style="cursor:pointer; color:green; font-size: 13px;">&check;</span>').prependTo(singleresult).click(accept);
  658. });
  659. var sub = $("<div></div>").appendTo(div);
  660. $('<time style="color:#b6b6b6; font-size: 11px;" datetime="'+time+'" title="'+time.toLocaleFormat()+'">'+minutesSince(time)+'</time>').appendTo(sub);
  661. $('<a style="color:#b6b6b6; font-size: 11px;" target="_blank" href="'+url+'" title="Open Metacritic">'+decodeURI(url.replace("http://www.","@"))+'</a>').appendTo(sub);
  662. $('<span title="Hide me" style="cursor:pointer; float:right; color:#b6b6b6; font-size: 11px;">&#128128;</span>').appendTo(sub).click(function() {
  663. document.body.removeChild(this.parentNode.parentNode);
  664. });
  665. $('<span title="None of the above is the correct item" style="cursor:pointer; float:right; color:crimson; font-size: 11px;">&cross;</span>').appendTo(sub).click(function() {if(confirm("None of the above is the correct item\nConfirm?")) denyAll()});
  666. },
  667. // On error i.e. no results
  668. function(results, time) {
  669. loader.remove();
  670. var resultdiv = $("#mcdiv123searchresults").length?$("#mcdiv123searchresults").html(""):$('<div id="mcdiv123searchresults"></div>').appendTo(div);
  671. resultdiv.html("No search results.");
  672. var sub = $("<div></div>").appendTo(div);
  673. $('<time style="color:#b6b6b6; font-size: 11px;" datetime="'+time+'" title="'+time.toLocaleFormat()+'">'+minutesSince(time)+'</time>').appendTo(sub);
  674. $('<a style="color:#b6b6b6; font-size: 11px;" target="_blank" href="'+url+'" title="Open Metacritic">'+decodeURI(url.replace("http://www.","@"))+'</a>').appendTo(sub);
  675. $('<span title="Hide me" style="cursor:pointer; float:right; color:#b6b6b6; font-size: 11px;">&#128128;</span>').appendTo(sub).click(function() {
  676. document.body.removeChild(this.parentNode.parentNode);
  677. });
  678. }
  679. );
  680. }
  681.  
  682. var current = {
  683. url : null,
  684. type : null,
  685. data : null, // Array of raw search keys
  686. searchTerm : null
  687. };
  688.  
  689.  
  690. function showURL(url) {
  691. if(!isBlacklisted(url)) {
  692. var docurl = document.location.host.replace(/^www\./,"") + document.location.pathname + document.location.search;
  693. docurl = filterUniversalUrl(docurl);
  694. metacritic_showHoverInfo(url, docurl);
  695. } else {
  696. console.log(url +" is blacklisted!");
  697. }
  698. }
  699.  
  700.  
  701. var metacritic = {
  702. "mapped" : function metacritic_mapped(url, type) {
  703. // url was in the map/whitelist
  704. current.data = [url]
  705. current.url = url;
  706. current.type = type;
  707. current.searchTerm = url;
  708. showURL(url);
  709. },
  710. "music" : function metacritic_music(artistname, albumname) {
  711. current.data = [albumname.trim(),artistname.trim()]
  712. artistname = name2metacritic(artistname);
  713. albumname = name2metacritic(albumname);
  714. var url = baseURL_music + albumname + "/" + artistname;
  715. current.url = url;
  716. current.type = "music";
  717. current.searchTerm = albumname + "/" + artistname;
  718. showURL(url);
  719. },
  720. "movie" : function metacritic_movie(moviename) {
  721. current.data = [moviename.trim()]
  722. moviename = name2metacritic(moviename);
  723. var url = baseURL_movie + moviename;
  724. current.url = url;
  725. current.type = "movie";
  726. current.searchTerm = moviename;
  727. showURL(url);
  728. },
  729. "tv" : function metacritic_tv(seriesname) {
  730. current.data = [seriesname.trim()]
  731. seriesname = name2metacritic(seriesname);
  732. var url = baseURL_tv + seriesname;
  733. current.url = url;
  734. current.type = "tv";
  735. current.searchTerm = seriesname;
  736. showURL(url);
  737. },
  738. "pcgame" : function metacritic_pcgame(gamename) {
  739. current.data = [gamename.trim()]
  740. gamename = name2metacritic(gamename);
  741. var url = baseURL_pcgame + gamename;
  742. current.url = url;
  743. current.type = "pcgame";
  744. current.searchTerm = gamename;
  745. showURL(url);
  746. },
  747. "ps4game" : function metacritic_ps4game(gamename) {
  748. current.data = [gamename.trim()]
  749. gamename = name2metacritic(gamename);
  750. var url = baseURL_ps4 + gamename;
  751. current.url = url;
  752. current.type = "ps4game";
  753. current.searchTerm = gamename;
  754. showURL(url);
  755. },
  756. "xonegame" : function metacritic_xonegame(gamename) {
  757. current.data = [gamename.trim()]
  758. gamename = name2metacritic(gamename);
  759. var url = baseURL_xone + gamename;
  760. current.url = url;
  761. current.type = "xonegame";
  762. current.searchTerm = gamename;
  763. showURL(url);
  764. }
  765. };
  766.  
  767.  
  768. var Always = function() { return true; };
  769. var sites = {
  770. 'bandcamp' : {
  771. host : ["bandcamp.com"],
  772. condition : function() {
  773. return unsafeWindow.TralbumData
  774. },
  775. products : [{
  776. condition : Always,
  777. type : "music",
  778. data : function() { return [unsafeWindow.TralbumData.artist, unsafeWindow.TralbumData.current.title]; }
  779. }]
  780. },
  781. 'itunes' : {
  782. host : ["itunes.apple.com"],
  783. condition : Always,
  784. products : [{
  785. condition : function() { return ~document.location.href.indexOf("/album/") },
  786. type : "music",
  787. data : function() { return [document.querySelector("*[itemprop=byArtist]").textContent, document.querySelector("*[itemprop=name]").textContent] }
  788. }]
  789. },
  790. 'googleplay' : {
  791. host : ["play.google.com"],
  792. condition : Always,
  793. products : [
  794. {
  795. condition : function() { return ~document.location.href.indexOf("/album/")},
  796. type : "music",
  797. data : function() { return [document.querySelector("*[itemprop=byArtist] a").textContent, document.querySelector("*[itemprop=name]").textContent]}
  798. },
  799. {
  800. condition : function() { return ~document.location.href.indexOf("/movies/details/")},
  801. type : "movie",
  802. data : function() { return document.querySelector("*[itemprop=name]").textContent}
  803. }
  804. ]
  805. },
  806. 'imdb' : {
  807. host : ["imdb.com"],
  808. condition : Always,
  809. products : [
  810. {
  811. condition : function() {
  812. var e = document.querySelector("meta[property='og:type']");
  813. if(e) {
  814. return e.content == "video.movie"
  815. }
  816. return false;
  817. },
  818. type : "movie",
  819. data : function() {
  820. if(document.querySelector(".title-extra[itemprop=name]")) {
  821. return [document.querySelector(".title-extra[itemprop=name]").firstChild.textContent.replace(/\"/g,"")];
  822. } else {
  823. return document.querySelector("*[itemprop=name]").firstChild.textContent;
  824. }
  825. }
  826. },
  827. {
  828. condition : function() {
  829. var e = document.querySelector("meta[property='og:type']");
  830. if(e) {
  831. return e.content == "video.tv_show"
  832. }
  833. return false;
  834. },
  835. type : "tv",
  836. data : function() { return document.querySelector("*[itemprop=name]").textContent}
  837. }
  838. ]
  839. },
  840. 'steam' : {
  841. host : ["store.steampowered.com"],
  842. condition : function() { return document.querySelector("*[itemprop=name]")},
  843. products : [{
  844. condition : Always,
  845. type : "pcgame",
  846. data : function() { return document.querySelector("*[itemprop=name]").textContent}
  847. }]
  848. },
  849. 'tv.com' : {
  850. host : ["www.tv.com"],
  851. condition : function() { return document.querySelector("h1[itemprop=name]")},
  852. products : [{
  853. condition : Always,
  854. type : "tv",
  855. data : function() { return document.querySelector("h1[itemprop=name]").textContent}
  856. }]
  857. },
  858. 'rottentomatoes' : {
  859. host : ["www.rottentomatoes.com"],
  860. condition : Always,
  861. products : [{
  862. condition : function() { return document.location.pathname.startsWith("/m/")},
  863. type : "movie",
  864. data : function() { return document.querySelector("h1[itemprop=name]").firstChild.textContent}
  865. },
  866. {
  867. condition : function() { return document.location.pathname.startsWith("/tv/")} ,
  868. type : "tv",
  869. data : function() { return document.querySelector("*[itemprop=partOfSeries] *[itemprop=name]").textContent}
  870. }
  871. ]
  872. },
  873. 'serienjunkies' : {
  874. host : ["www.serienjunkies.de"],
  875. condition : Always,
  876. products : [{
  877. condition : Always,
  878. type : "tv",
  879. data : function() {
  880. if(document.querySelector("h1[itemprop=name]")) {
  881. return document.querySelector("h1[itemprop=name]").textContent;
  882. } else {
  883. var n = $("a:contains(Details zur)");
  884. if(n) {
  885. var name = n.text().match(/Details zur Produktion der Serie (.+)/)[1];
  886. return name;
  887. }
  888. }
  889. }
  890. }]
  891. },
  892. 'gamespot' : {
  893. host : ["gamespot.com"],
  894. condition : function() { return document.querySelector("[itemprop=device]")},
  895. products : [
  896. {
  897. condition : function() { return $("[itemprop=device]").text().contains("PC")},
  898. type : "pcgame",
  899. data : function() { return document.querySelector("h1[itemprop=name]").textContent }
  900. },
  901. {
  902. condition : function() { return $("[itemprop=device]").text().contains("PS4")},
  903. type : "ps4game",
  904. data : function() { return document.querySelector("h1[itemprop=name]").textContent}
  905. },
  906. {
  907. condition : function() { return $("[itemprop=device]").text().contains("XONE")},
  908. type : "xonegame",
  909. data : function() { return document.querySelector("h1[itemprop=name]").textContent}
  910. }
  911. ]
  912. },
  913. 'amazon' : {
  914. host : ["amazon."],
  915. condition : Always,
  916. products : [
  917. {
  918. condition : function() {
  919. var music = ["Music","Musique","Musik","Música","Musica","&#38899;&#27005;"];
  920. return music.some(function(s) {
  921. if(~document.title.indexOf(s)) {
  922. return true;
  923. } else {
  924. return false;
  925. }
  926. });
  927. },
  928. type : "music",
  929. data : function() {
  930. var artist = document.querySelector("#byline .author a").textContent;
  931. var title = document.getElementById("productTitle").textContent;
  932. title = title.replace(/\[([^\]]*)\]/g,""); // Remove [brackets] and their content
  933. return [artist, title];
  934. }
  935. },
  936. {
  937. condition : function() { return (document.getElementById("aiv-content-title") && document.getElementsByClassName("season-single-dark").length)},
  938. type : "tv",
  939. data : function() { return document.getElementById("aiv-content-title").firstChild.data.trim()}
  940. },
  941. {
  942. condition : function() { return document.getElementById("aiv-content-title")},
  943. type : "movie",
  944. data : function() { return document.getElementById("aiv-content-title").firstChild.data.trim()}
  945. }
  946. ]
  947. },
  948. 'BoxOfficeMojo' : {
  949. host : ["boxofficemojo.com"],
  950. condition : function() { return ~document.location.search.indexOf("id=")},
  951. products : [{
  952. condition : function() { return document.querySelector("#body table:nth-child(2) tr:first-child b")},
  953. type : "movie",
  954. data : function() { return document.querySelector("#body table:nth-child(2) tr:first-child b").firstChild.data}
  955. }]
  956. },
  957. 'AllMovie' : {
  958. host : ["allmovie.com"],
  959. condition : function() { return document.querySelector("h2[itemprop=name].movie-title")},
  960. products : [{
  961. condition : function() { return document.querySelector("h2[itemprop=name].movie-title")},
  962. type : "movie",
  963. data : function() { return document.querySelector("h2[itemprop=name].movie-title").firstChild.data.trim()}
  964. }]
  965. },
  966. 'en.wikipedia' : {
  967. host : ["en.wikipedia.org"],
  968. condition : Always,
  969. products : [{
  970. condition : function() {
  971. if(!document.querySelector(".infobox .summary")) {
  972. return false;
  973. }
  974. var r = /\d\d\d\d films/;
  975. return $("#catlinks a").filter(function(i,e) {return e.firstChild.data.match(r)}).length;
  976. },
  977. type : "movie",
  978. data : function() { return document.querySelector(".infobox .summary").firstChild.data}
  979. },
  980. {
  981. condition : function() {
  982. if(!document.querySelector(".infobox .summary")) {
  983. return false;
  984. }
  985. var r = /television series/;
  986. return $("#catlinks a").filter(function(i,e) {return e.firstChild.data.match(r)}).length;
  987. },
  988. type : "tv",
  989. data : function() { return document.querySelector(".infobox .summary").firstChild.data}
  990. }]
  991. },
  992. 'movies.com' : {
  993. host : ["movies.com"],
  994. condition : function() { return document.querySelector("meta[property='og:title']")},
  995. products : [{
  996. condition : Always,
  997. type : "movie",
  998. data : function() { return document.querySelector("meta[property='og:title']").content}
  999. }]
  1000. },
  1001. 'themoviedb' : {
  1002. host : ["themoviedb.org"],
  1003. condition : function() { return document.querySelector("meta[property='og:type']")},
  1004. products : [{
  1005. condition : function() { return document.querySelector("meta[property='og:type']").content == "movie"},
  1006. type : "movie",
  1007. data : function() { return document.querySelector("meta[property='og:title']").content}
  1008. },
  1009. {
  1010. condition : function() { return document.querySelector("meta[property='og:type']").content == "tv_series"},
  1011. type : "tv",
  1012. data : function() { return document.querySelector("meta[property='og:title']").content}
  1013. }]
  1014. },
  1015. 'letterboxd' : {
  1016. host : ["letterboxd.com"],
  1017. condition : function() { return unsafeWindow.filmData && "name" in unsafeWindow.filmData},
  1018. products : [{
  1019. condition : Always,
  1020. type : "movie",
  1021. data : function() { return unsafeWindow.filmData.name}
  1022. }]
  1023. },
  1024. 'TVmaze' : {
  1025. host : ["tvmaze.com"],
  1026. condition : function() { return document.querySelector("h1")},
  1027. products : [{
  1028. condition : Always,
  1029. type : "tv",
  1030. data : function() { return document.querySelector("h1").firstChild.data}
  1031. }]
  1032. },
  1033. 'TVGuide' : {
  1034. host : ["tvguide.com"],
  1035. condition : Always,
  1036. products : [{
  1037. condition : function() { return document.location.pathname.startsWith("/tvshows/")},
  1038. type : "tv",
  1039. data : function() { return document.querySelector("meta[property='og:title']").content}
  1040. }]
  1041. },
  1042. 'followshows' : {
  1043. host : ["followshows.com"],
  1044. condition : Always,
  1045. products : [{
  1046. condition : function() { return document.querySelector("meta[property='og:type']").content == "video.tv_show"},
  1047. type : "tv",
  1048. data : function() { return document.querySelector("meta[property='og:title']").content}
  1049. }]
  1050. },
  1051. 'TheTVDB' : {
  1052. host : ["thetvdb.com"],
  1053. condition : Always,
  1054. products : [{
  1055. condition : function() { return ~document.location.search.indexOf("tab=series")},
  1056. type : "tv",
  1057. data : function() { return document.querySelector("#content h1").firstChild.data}
  1058. }]
  1059. },
  1060. 'ConsequenceOfSound' : {
  1061. host : ["consequenceofsound.net"],
  1062. condition : function() { return document.querySelector("meta[property='og:title']")},
  1063. products : [{
  1064. condition : function() { return document.querySelector("meta[property='og:title']").content.match(/.+: (.+) - (.+)/)},
  1065. type : "music",
  1066. data : function() {
  1067. var m = document.querySelector("meta[property='og:title']").content.match(/.+: (.+) - (.+)/);
  1068. m.shift();
  1069. return m;
  1070. }
  1071. }]
  1072. },
  1073. 'Pitchfork' : {
  1074. host : ["pitchfork.com"],
  1075. condition : Always,
  1076. products : [{
  1077. condition : function() { return document.querySelector("#main .review-meta .info h1 a")},
  1078. type : "music",
  1079. data : function() {
  1080. var artist = document.querySelector("#main .review-meta .info h1 a").firstChild.data;
  1081. var album = document.querySelector("#main .review-meta .info h2").firstChild.data;
  1082. return [artist, album];
  1083. }
  1084. }]
  1085. },
  1086. 'Last.fm' : {
  1087. host : ["last.fm"],
  1088. condition :function() {return document.querySelector("*[data-page-type]") && document.querySelector("*[data-page-type]").dataset.pageType == "album_door" },
  1089. products : [{
  1090. condition : function() { return document.querySelector("*[data-page-type]").dataset.musicAlbumName },
  1091. type : "music",
  1092. data : function() {
  1093. var artist = document.querySelector(".header-crumb").firstChild.data;
  1094. var album = document.querySelector("*[data-page-type]").dataset.musicAlbumName;
  1095. return [artist, album];
  1096. }
  1097. }]
  1098. },
  1099. };
  1100.  
  1101.  
  1102. function main() {
  1103.  
  1104. var map = false;
  1105.  
  1106. for(var name in sites) {
  1107. var site = sites[name];
  1108. if(site.host.some(function(e) {return ~this.indexOf(e)}, document.location.hostname) && site.condition()) {
  1109. for(var i = 0; i < site.products.length; i++) {
  1110. if(site.products[i].condition()) {
  1111. // Check map for a match
  1112. if(map === false) {
  1113. map = JSON.parse(GM_getValue("map","{}"));
  1114. }
  1115. var docurl = document.location.host.replace(/^www\./,"") + document.location.pathname + document.location.search;
  1116. docurl = filterUniversalUrl(docurl);
  1117. if(docurl in map) {
  1118. // Found in map, show result
  1119. var metaurl = map[docurl];
  1120. metacritic["mapped"].apply(undefined, [baseURL + metaurl, site.products[i].type]);
  1121. break;
  1122. }
  1123. // Try to retrieve item name from page
  1124. var data;
  1125. try {
  1126. data = site.products[i].data();
  1127. } catch(e) {
  1128. data = false;
  1129. console.log(e);
  1130. }
  1131. if(data) {
  1132. metacritic[site.products[i].type].apply(undefined, Array.isArray(data)?data:[data]);
  1133. }
  1134. break;
  1135. }
  1136. }
  1137. break;
  1138. }
  1139. }
  1140. }
  1141.  
  1142.  
  1143.  
  1144. main();
  1145. var lastLoc = document.location.href;
  1146. window.setInterval(function() {
  1147. if(document.location.href != lastLoc) {
  1148. lastLoc = document.location.href;
  1149. $("#mcdiv123").remove();
  1150. window.setTimeout(main,500);
  1151. }
  1152. },500);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址