IMDb rating sanitiser.

Replaces rating on IMDb title pages with Non-US user rating.

当前为 2014-07-19 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name IMDb rating sanitiser.
  3. // @namespace dicks
  4. // @description Replaces rating on IMDb title pages with Non-US user rating.
  5. // @include http*://*.imdb.com/title/tt*
  6. // @include http*://imdb.com/title/tt*
  7. // @version 0001
  8. // @require https://code.jquery.com/jquery-2.1.1.min.js
  9. // ==/UserScript==
  10. function main(url, combined) {
  11. $.ajax({
  12. url: url + 'ratings-international',
  13. success: function (data) {
  14. var line = $(data).find('#tn15content').find('p').eq(0).text();
  15. if (!line) {
  16. return false;
  17. }
  18.  
  19. var realvotes = line.match(/^(\d+) Non-US users/)[1].replace(/\B(?=(\d{3})+(?!\d))/g, ',') + ' non-US ',
  20. realscore = line.match(/vote of (\d+\.?\d*) \/ 10/)[1];
  21.  
  22. if (!combined) {
  23. var star = $('.titlePageSprite').eq(1),
  24. text = $('.star-box-details').eq(0).find('span'),
  25. rate = text.eq(0),
  26. vote = text.eq(3);
  27. } else {
  28. var star = $('#general-voting-stars'),
  29. rate = $('.starbar-meta').find('b').eq(0),
  30. vote = $('.tn15more').eq(0);
  31. }
  32.  
  33. star.fadeOut(400);
  34. rate.fadeOut(400);
  35. vote.fadeOut(400);
  36. setTimeout(function () {
  37. if (!combined) {
  38. star.text(realscore);
  39. } else {
  40. star.width((realscore * 20));
  41. }
  42. rate.text(realscore + (combined ? '/10' : ''));
  43. vote.text(realvotes + (combined ? 'votes' : ''));
  44. }, 400);
  45. star.fadeIn(400);
  46. rate.fadeIn(400);
  47. vote.fadeIn(400);
  48. }
  49. });
  50. }
  51.  
  52. combined = (location.href.match(/\/combined\/?/)) ? true : false;
  53. url = location.href.replace(/(combined\/?|\?ref_=).*/g, '');
  54. if (url.match(/\/title\/tt\d{7,}\/$/)) {
  55. main(url, combined);
  56. }