Greasy Fork 还支持 简体中文。

IMDb Standard Deviation

Adds standard deviation to IMDb ratings breakdown pages.

  1. // ==UserScript==
  2. // @name IMDb Standard Deviation
  3. // @namespace http://userscripts.org/users/7063
  4. // @include https://www.imdb.com/title/tt*/ratings
  5. // @include https://www.imdb.com/title/tt*/ratings/
  6. // @include https://www.imdb.com/title/tt*/ratings-*
  7. // @include https://www.imdb.com/title/tt*/ratings?*
  8. // @version 2025.1.13.4.31
  9. // @grant none
  10. // @description Adds standard deviation to IMDb ratings breakdown pages.
  11. // @noframes
  12. // ==/UserScript==
  13.  
  14. (function () {
  15. "use strict";
  16. function go(main) {
  17. const votes = [...main.querySelectorAll(".VictoryContainer path ~ text")].map(k => {
  18. const text = k.textContent.match(/\((.*)\)/)[1];
  19. const km = text.match(/[KM]/);
  20. if (km) {
  21. return +text.match(/[^KM]+/) * 10 ** {"K": 3, "M": 6}[km];
  22. }
  23. return +text;
  24. });
  25. const [product, votecount] = votes.reduce(
  26. ([p, v], c, i) => [p + c * (10 - i), v + c],
  27. [0, 0]
  28. );
  29. const sumOfSquares = votes.reduce(
  30. (p, c, i) => p + Math.pow(10 - i - product / votecount, 2) * c,
  31. 0
  32. );
  33. const p = document.createElement("p");
  34. p.textContent = `${Math.sqrt(sumOfSquares / (votecount - 1)).toFixed(2)} Standard deviation`;
  35. p.classList.add("cSLvSW");
  36. main.append(p);
  37. }
  38. const obParams = [document.body, { childList: true, subtree: true }];
  39. const observer = new MutationObserver(() => {
  40. observer.disconnect();
  41. const histo = document.querySelector(`[data-testid="histogram-container"]`);
  42. if (histo) {
  43. go(histo);
  44. } else {
  45. observer.observe(...obParams);
  46. }
  47. });
  48. observer.observe(...obParams);
  49.  
  50. }());