Letterboxd Average Rating

Adds average rating of film to film pages

  1. // ==UserScript==
  2. // @name Letterboxd Average Rating
  3. // @namespace https://github.com/rcalderong/userscripts
  4. // @description Adds average rating of film to film pages
  5. // @copyright 2014+, Ramón Calderón (http://rcalderon.es)
  6. // @homepageURL https://github.com/rcalderong/userscripts
  7. // @supportURL https://github.com/rcalderong/userscripts/issues
  8. // @icon https://raw.githubusercontent.com/rcalderong/userscripts/master/img/letterboxd_icon.png
  9. // @license GPLv3; http://www.gnu.org/licenses/gpl.html
  10. // @version 1.3
  11. // @include http://letterboxd.com/film/*
  12. // @include http://letterboxd.com/film/*/crew/*
  13. // @include http://letterboxd.com/film/*/studios/*
  14. // @include http://letterboxd.com/film/*/genres/*
  15. // @exclude http://letterboxd.com/film/*/views/*
  16. // @exclude http://letterboxd.com/film/*/lists/*
  17. // @exclude http://letterboxd.com/film/*/likes/*
  18. // @exclude http://letterboxd.com/film/*/fans/*
  19. // @exclude http://letterboxd.com/film/*/ratings/*
  20. // @exclude http://letterboxd.com/film/*/reviews/*
  21. // @grant none
  22. // ==/UserScript==
  23.  
  24. var sectionElt = document.getElementsByClassName("ratings-histogram-chart")[0],
  25. ratingsPageUrl = sectionElt.getElementsByTagName("a")[0].href,
  26. dataElt = sectionElt.querySelector("span.average-rating meta"),
  27. oneToTenRating = parseFloat(dataElt.getAttribute("content")),
  28. oneToFiveRating = (oneToTenRating / 2).toFixed(1),
  29. ratingElt = document.createElement("a"),
  30. ratingInnerElt = document.createElement("span");
  31.  
  32. // Create element to be inserted in page
  33. ratingElt.className = "rating-green tooltip";
  34. ratingElt.style.position = "absolute";
  35. ratingElt.style.top = "0";
  36. ratingElt.style.left = "72px";
  37. ratingElt.href = ratingsPageUrl;
  38. ratingElt.setAttribute("title", oneToFiveRating + " stars" +
  39. " (" + oneToTenRating + "/10)");
  40. ratingInnerElt.className = "rating rated-" + Math.round(oneToTenRating);
  41. ratingElt.appendChild(ratingInnerElt);
  42.  
  43. // Insert element in page
  44. sectionElt.insertBefore(ratingElt, sectionElt.children[1]);

QingJ © 2025

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