MTurk Worst & Best Case Scenario

This script will calculate the best and worst case scenario of your pending HITs. The information will be displayed on your dashboard.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name		MTurk Worst & Best Case Scenario
// @author		Austin3600 (WoLF)
// @description	This script will calculate the best and worst case scenario of your pending HITs. The information will be displayed on your dashboard.
// @include		https://www.mturk.com/mturk/dashboard
// @version		1.0
// @grant		none
// @namespace https://greasyfork.org/users/6438
// ==/UserScript==

// History
// 04-05-2014: v1.0 Released

// Color settings
// Users can change these colors to anything they want by changed this words
// Look up a list of HTML color names, any of those may be used.
// EX: 'red', 'blue', 'orange', 'yellow', 'gold'

var goodColor = 'lightgreen';
var okColor = 'orange';
var badColor = 'red';

// Percentage Settings
// You can change these
// goodP = What's the lowest approval rating you deem as "Good"
// okP = What's the lowest approval rating you deem just "OK"

var goodP = 99.0;
var okP = 95.0;

// End of settings - Don't change anything below this line.

// Variable setup
var pending, submitted, approved, approvalP, rejected, worstCase, bestCase, bestColor;
var results = document.evaluate("//tr[@class]", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);

for (var x=0;x < results.snapshotLength;x++) {
	var line = results.snapshotItem(x);
	if (line.cells.length == 3) {
		if (line.cells[0].textContent.match('HITs Submitted')) {
			submitted = parseInt(line.cells[1].textContent);
		}
		if (line.cells[0].textContent.match('... Approved')) {
			approved = parseInt(line.cells[1].textContent);
			approvalP = parseFloat(line.cells[2].textContent);
			if (approvalP >= goodP) {
				line.cells[2].style.backgroundColor = goodColor;
			}
			else if (approvalP >= okP) {
				line.cells[2].style.backgroundColor = okColor;
			}
			else {
				line.cells[2].style.backgroundColor = badColor;
			}
		}
		if (line.cells[0].textContent.match('... Rejected')) {
			rejected = parseInt(line.cells[1].textContent);
		}
		if (line.cells[0].textContent.match('... Pending')) {
			pending = parseInt(line.cells[1].textContent);
			line.cells[0].innerHTML += " <small>(Worst Case Scenario)</small>";
			if (goodP < approvalP) {
				var f = 1.0 - goodP/100;
				var i = (rejected-(f*submitted))/(f-1);
				line.cells[0].innerHTML += "<br>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color:" + okColor + "\">(~" + Math.round(i) + " rejects => " + goodP + "%)</span>";
			}
			if (okP < approvalP) {
				var f = 1.0 - okP/100;
				var i = (rejected-(f*submitted))/(f-1);
				line.cells[0].innerHTML += "<br>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color:" + badColor + "\">(~" + Math.round(i) + " rejects => " + okP + "%)</span>";
			}
			worstCase = Math.round(approved/(approved+rejected+pending) * 1000)/10;
			line.cells[2].innerHTML = '(' + worstCase + '%)';
			if (worstCase >= goodP) {
				line.cells[2].style.backgroundColor = goodColor;
			}
			else if (worstCase >= okP) {
				line.cells[2].style.backgroundColor = okColor;
			}
			else {
				line.cells[2].style.backgroundColor = badColor;
			}
			// BestCase Scenario Implementation
			bestCase = ((approved+pending)/(approved+rejected+pending) * 100).toFixed(1);
			if (bestCase >= goodP) {
				bestColor = 'green';
			}
			else if (bestCase >= okP) {
				bestColor = okColor;
			}
			else {
				bestColor = badColor
			}
			line.cells[0].innerHTML += "<br>... Pending <small><span style=\"color:" + bestColor + "\">" + "(Best Case Scenario = " + bestCase + "%)</small></span>";
			if (goodP > approvalP) {
				var f = 1.0 - goodP/100;
				var i = (rejected-(f*submitted))/f;
				line.cells[0].innerHTML += "<br>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color:" + 'green' + "\">(~" + Math.round(i) + " accepts => " + goodP + "%)</span>";
			}
			if (okP > approvalP) {
				var f = 1.0 - okP/100;
				var i = (rejected-(f*submitted))/f;
				line.cells[0].innerHTML += "<br>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color:" + okColor + "\">(~" + Math.round(i) + " accepts => " + okP + "%)</span>";
			}
		}
	}
}