IMDb Standard Deviation

Adds standard deviation to IMDb ratings breakdown pages.

Від 08.12.2018. Дивіться остання версія.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(У мене вже є менеджер скриптів, дайте мені встановити його!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==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.8.11.39
// @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.replace(/[\s,]+/g, ""));
	votes.shift();//
	let product = 0;
	let votecount = 0;
	votes.forEach((v, i) => {
		product += v * (10 - i);
		votecount += +v;
	});
	const sumOfSquares = votes.reduce((p, c, i) => p +
		Math.pow(10 - i - product / votecount, 2) * c, 0);
	main.querySelector(".title-ratings-sub-page .allText[align=\"center\"]").textContent +=
		`\xA0 Standard Deviation = ${Math.sqrt(sumOfSquares / (votecount - 1)).toFixed(2)}`;
}());