IMDb Standard Deviation

Adds standard deviation to IMDb ratings breakdown pages.

当前为 2014-05-01 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

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

(function () {
	"use strict";

	var	$ = function (a, b) {return b.getElementsByTagName(a); },
		tn = document.getElementById("tn15content"),
		table = $("table", tn),
		votes = [],
		product = 0,
		votecount = 0,
		sd = 0,
		mean,
		i;

	if (table.length) {
		for (i = 0; i < 10; i++) {
			votes.push(+table[0].rows[i + 1].cells[0].textContent);
			product += votes[i] * (10 - i);
			votecount += votes[i];
		}

		//votecount--;
		mean = product / votecount;

		for (i = 1; i <= 10; i++) {
			sd += Math.pow(i - mean, 2) * votes[10 - i];
		}

		$("p", tn)[2].textContent += ". \xA0Standard Deviation = " + Math.sqrt(sd / votecount).toFixed(2);
	}
}());