IMDb Standard Deviation

Adds standard deviation to IMDb ratings breakdown pages.

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

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

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

您需要先安裝使用者腳本管理器擴充功能,如 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      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)}`;
}());