IMDb Standard Deviation

Adds standard deviation to IMDb ratings breakdown pages.

Verze ze dne 08. 12. 2018. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==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)}`;
}());