IMDb Standard Deviation

Adds standard deviation to IMDb ratings breakdown pages.

目前為 2019-01-01 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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      2019.1.1.21.17
// @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) {
		const votes = [...main.querySelector("table").rows].slice(1)
			.map(k => +k.cells[2].textContent.replace(/[\s,]/g, ""));
		const [product, votecount] = votes.reduce(([p, v], c, i) => [p + c * (10 - i), v + c], [0, 0]);
		const sumOfSquares = votes.reduce((p, c, i) => p + Math.pow(10 - i - product / votecount, 2) * c, 0);
		main.querySelector("table ~ .allText").textContent += `\xA0 Standard Deviation = ${
			Math.sqrt(sumOfSquares / (votecount - 1)).toFixed(2)}`;
	}
}());