IMDb Standard Deviation

Adds standard deviation to IMDb ratings breakdown pages.

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

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

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址