IMDb Standard Deviation

Adds standard deviation to IMDb ratings breakdown pages.

目前為 2018-12-02 提交的版本,檢視 最新版本

// ==UserScript==
// @name         IMDb Standard Deviation
// @namespace    http://userscripts.org/users/7063
// @include      https://www.imdb.com/title/tt*/ratings
// @include      https://www.imdb.com/title/tt*/ratings-*
// @include      https://www.imdb.com/title/tt*/ratings?*
// @version      2018.12.2.9.44
// @grant        none
// @description  Adds standard deviation to IMDb ratings breakdown pages.
// ==/UserScript==

/*eslint-env browser*/

"use strict";
(function () {
	const main = document.querySelector("#main");
	if (!main) {
		return;
	}
	const votes = [...main.querySelector("table").rows].map(k => +k.cells[2].textContent);
	votes.shift();
	let product = 0;
	let votecount = 0;
	votes.forEach((v, i) => {
		product += v * (10 - i);
		votecount += v;
	});
	const redFun = (p, c, i) => p + Math.pow(10 - i - product / votecount, 2) * c;
	const out = main.querySelector(".title-ratings-sub-page .allText[align=\"center\"]");
	out.textContent += `\xA0 Standard Deviation = ${Math.sqrt(
		votes.reduce(redFun, 0) / (votecount - 1)).toFixed(2)}`;
}());

QingJ © 2025

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