IMDb rating sanitiser.

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

  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 0005
  8. // ==/UserScript==
  9. function main(url, combined) {
  10. $.ajax({
  11. url: url + 'ratings-international',
  12. success: function (data) {
  13. var line = $(data).find('#tn15content').find('p').eq(0).text();
  14. if (!line) {
  15. return false;
  16. }
  17.  
  18. var realvotes = line.match(/^(\d+) Non-US users/)[1].replace(/\B(?=(\d{3})+(?!\d))/g, ',') + ' non-US ',
  19. realscore = line.match(/vote of (\d+\.?\d*) \/ 10/)[1];
  20.  
  21. if (combined) {
  22. var star = $('#general-voting-stars'),
  23. rate = $('.starbar-meta').find('b').eq(0),
  24. vote = $('.tn15more').eq(0);
  25. } else {
  26. var star = $('.imdbRating').eq(0).find('span'),
  27. rate = star.eq(0),
  28. vote = star.eq(3);
  29. }
  30.  
  31. star.fadeOut(400);
  32. rate.fadeOut(400);
  33. vote.fadeOut(400);
  34. setTimeout(function () {
  35. if (combined) {
  36. star.width((realscore * 20));
  37. }
  38. rate.text(realscore + (combined ? '/10' : ''));
  39. vote.text(realvotes + (combined ? 'votes' : ''));
  40. }, 400);
  41. star.fadeIn(400);
  42. rate.fadeIn(400);
  43. vote.fadeIn(400);
  44. }
  45. });
  46. }
  47.  
  48. combined = (location.href.match(/\/combined\/?/)) ? true : false;
  49. url = location.href.replace(/(combined\/?|\?(pf_rd_m|ref_)=).*/g, '');
  50. if (url.match(/\/title\/tt\d{7,}\/$/)) {
  51. main(url, combined);
  52. }