MTurk Worst Case Scenario Calculator

Shows what your approval rate would be in worst case scenario. This version was patched by Austin3600, since the original hasn't been updated since 2012 and is broken with new dashboard.

当前为 2014-10-30 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name MTurk Worst Case Scenario Calculator
  3. // @author ThirdClassInternationalMasterTurker
  4. // @description Shows what your approval rate would be in worst case scenario. This version was patched by Austin3600, since the original hasn't been updated since 2012 and is broken with new dashboard.
  5. // @include https://www.mturk.com/mturk/dashboard
  6. // @version 3.2
  7. // @grant none
  8. // @namespace https://greasyfork.org/users/6438
  9. // ==/UserScript==
  10.  
  11. //
  12. // 2012-09-07 First public release by ThirdClassInternationalMasterTurker
  13. //
  14. // 2012-09-09 Added approximate number of rejects that drop you to the
  15. // edge of RATE_GOOD and RATE_OK
  16. //
  17. // 2012-10-06 Added GUI for setting RATE_GOOD and RATE_OK
  18. // (Click 'Pending (Worst Case Scenario)')
  19. //
  20. // 2012-12-02 3.1: Added @downloadURL and @updateURL
  21. //
  22. // 2014-04-04 3.2: Austin3600 patched script to work with new dashboard
  23.  
  24. // --- SETTINGS ------------------------------------------------------- //
  25. var RATE_GOOD = (localStorage['WCS_GOOD']) ? localStorage['WCS_GOOD'] : 99.0;
  26. var RATE_OK = (localStorage['WCS_OK']) ? localStorage['WCS_OK'] : 95.0;
  27.  
  28. var COLOUR_GOOD = 'lightgreen';
  29. var COLOUR_OK = 'orange';
  30. var COLOUR_BAD = 'red';
  31.  
  32. // -------------------------------------------------------------------- //
  33.  
  34. var rows = document.evaluate('//tr[@class]',
  35. document,
  36. null,
  37. XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  38.  
  39. var submitted;
  40. var approved;
  41. var rejected;
  42. var pending;
  43.  
  44. function config_func()
  45. {
  46. return function()
  47. {
  48. var t = prompt('MTurk Worst Case Scenario\nSet your RATE_GOOD and RATE_OK.\nFor example: 99.0;95.0',
  49. '' + RATE_GOOD + ';' + RATE_OK);
  50. if (!t)
  51. return;
  52.  
  53. var rates = t.split(';', 2);
  54. rates[0] = parseFloat(rates[0]).toFixed(1);
  55. rates[1] = parseFloat(rates[1]).toFixed(1);
  56. if (rates[0] > 0 && rates[0] <= 100)
  57. localStorage['WCS_GOOD'] = rates[0];
  58. if (rates[1] > 0 && rates[1] <= 100)
  59. localStorage['WCS_OK'] = rates[1];
  60. };
  61. }
  62.  
  63.  
  64. for (var i=0;i<rows.snapshotLength;i++) {
  65. var row = rows.snapshotItem(i);
  66.  
  67. if (row.cells.length != 3)
  68. continue;
  69. if (row.className.match('odd|even') == null) {
  70. continue;
  71. }
  72.  
  73. if (row.cells[0].textContent.match('HITs Submitted')) {
  74. submitted = parseInt(row.cells[1].textContent);
  75. }
  76.  
  77. if (row.cells[0].textContent.match('\\.\\.\\. Approved')) {
  78. approved = parseInt(row.cells[1].textContent);
  79. approved_p = parseFloat(row.cells[2].textContent);
  80.  
  81. if (approved_p >= RATE_GOOD) {
  82. row.cells[2].style.backgroundColor = COLOUR_GOOD;
  83. }
  84. else if (approved_p >= RATE_OK) {
  85. row.cells[2].style.backgroundColor = COLOUR_OK;
  86. }
  87. else {
  88. row.cells[2].style.backgroundColor = COLOUR_BAD;
  89. }
  90. }
  91.  
  92. if (row.cells[0].textContent.match('\\.\\.\\. Rejected')) {
  93. rejected = parseInt(row.cells[1].textContent);
  94. }
  95.  
  96. if (row.cells[0].textContent.match('\\.\\.\\. Pending')) {
  97. pending = parseInt(row.cells[1].textContent);
  98.  
  99. row.cells[0].innerHTML += " <small>(Worst Case Scenario)</small>";
  100.  
  101. if (RATE_GOOD < approved_p) {
  102. var p = 1.0 - RATE_GOOD/100;
  103. var x = (rejected-(p*submitted))/(p-1);
  104. row.cells[0].innerHTML += "<br>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color:" + COLOUR_OK + "\">(~" + Math.round(x) + " rejects => " + RATE_GOOD + "%)</span>";
  105. }
  106. if (RATE_OK < approved_p) {
  107. var p = 1.0 - RATE_OK/100;
  108. var x = (rejected-(p*submitted))/(p-1);
  109. row.cells[0].innerHTML += "<br>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color:" + COLOUR_BAD + "\">(~" + Math.round(x) + " rejects => " + RATE_OK + "%)</span>";
  110. }
  111.  
  112. WCS = Math.round((approved/(approved+rejected+pending) * 1000))/10;
  113. row.cells[2].innerHTML = '(' + WCS + '%)';
  114.  
  115. if (WCS >= RATE_GOOD) {
  116. row.cells[2].style.backgroundColor = COLOUR_GOOD;
  117. }
  118. else if (WCS >= RATE_OK) {
  119. row.cells[2].style.backgroundColor = COLOUR_OK;
  120. }
  121. else {
  122. row.cells[2].style.backgroundColor = COLOUR_BAD;
  123. }
  124.  
  125. row.cells[0].addEventListener("click", config_func(), false);
  126. row.cells[2].addEventListener("click", config_func(), false);
  127. }
  128. }