CH Precise Percents

Adds a more precise/accurate/honest display of your approved/rejected percentages and stats qual values to the MTurk dashboard.

目前为 2015-03-12 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name CH Precise Percents
  3. // @author clickhappier
  4. // @namespace clickhappier
  5. // @description Adds a more precise/accurate/honest display of your approved/rejected percentages and stats qual values to the MTurk dashboard.
  6. // @include https://www.mturk.com/mturk/dashboard*
  7. // @version 1.0c
  8. // @require https://cdnjs.cloudflare.com/ajax/libs/bignumber.js/2.0.3/bignumber.min.js
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12.  
  13. // based on 'MTurk Dashboard Change Notifier (with 12-value mod)': https://greasyfork.org/en/scripts/3019-mturk-dashboard-change-notifier-with-12-value-mod
  14.  
  15. // https://github.com/MikeMcl/bignumber.js/blob/master/README.md , http://mikemcl.github.io/bignumber.js/
  16. // - BigNumber math library used to avoid all the wrongness of javascript's built-in math functions
  17. BigNumber.config({ DECIMAL_PLACES : 50, ERRORS : false});
  18.  
  19.  
  20. var approvedHITs = new BigNumber(0);
  21. var rejectedHITs = new BigNumber(0);
  22. var approvedPercent = new BigNumber(0);
  23. var rejectedPercent = new BigNumber(0);
  24. var approvedQual = new BigNumber(0);
  25. var rejectedQual = new BigNumber(0);
  26. var approvedPctSpacer = "";
  27. var rejectedPctSpacer = "";
  28.  
  29. // TCIMT's xpath query getting all table rows that have a 'class' attribute specified
  30. var rows = document.evaluate('//tr[@class]', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  31.  
  32.  
  33. // retrieve approved and rejected HITs numbers
  34. for (var i=0; i<rows.snapshotLength; i++)
  35. {
  36. var row = rows.snapshotItem(i);
  37.  
  38. // HITs You Have Submitted section
  39. if (row.cells.length == 3) // table rows with three columns
  40. {
  41. if (row.cells[0].textContent.match('... Approved'))
  42. {
  43. approvedHITs = BigNumber( parseFloat(row.cells[1].childNodes[0].textContent) );
  44. }
  45. if (row.cells[0].textContent.match('... Rejected'))
  46. {
  47. rejectedHITs = BigNumber( parseFloat(row.cells[1].childNodes[0].textContent) );
  48. }
  49. }
  50. }
  51.  
  52.  
  53. // perform calculations
  54.  
  55. // approved percent
  56. if ( !(approvedHITs.equals(0)) || !(rejectedHITs.equals(0)) ) // if at least 1 HIT has been approved or rejected
  57. { approvedPercent = approvedHITs.dividedBy( approvedHITs.plus(rejectedHITs) ); }
  58. else // if 0 HITs approved+rejected (very new user)
  59. { approvedPercent = BigNumber(1); } // then 100% approved
  60. approvedPercent = BigNumber( approvedPercent.times(100).toFixed(10) ); // x% value rather than 0.x
  61. // approved % qual value
  62. if ( approvedHITs.plus(rejectedHITs).lessThan(100) ) // MTurk API doc says "if a Worker has submitted less than 100 assignments, the Worker's approval rate in the system is 100%."
  63. { approvedQual = BigNumber(100); }
  64. else
  65. { approvedQual = approvedPercent.truncated(); }
  66. // output spacer length for alignment
  67. if ( approvedPercent.lessThan(10) )
  68. { approvedPctSpacer = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"; } // for single-integer-digit values
  69. else
  70. { approvedPctSpacer = "&nbsp;&nbsp;&nbsp;&nbsp;"; }
  71.  
  72. // rejected percent
  73. rejectedPercent = BigNumber(100).minus(approvedPercent);
  74. rejectedPercent = BigNumber( rejectedPercent.toFixed(10) );
  75. // rejected % qual value
  76. rejectedQual = rejectedPercent.truncated();
  77. // output spacer length for alignment
  78. if ( rejectedPercent.lessThan(10) )
  79. { rejectedPctSpacer = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"; } // for single-integer-digit values
  80. else
  81. { rejectedPctSpacer = "&nbsp;&nbsp;&nbsp;&nbsp;"; }
  82.  
  83.  
  84. // display results
  85. for (var i=0; i<rows.snapshotLength; i++)
  86. {
  87. var row = rows.snapshotItem(i);
  88.  
  89. // HITs You Have Submitted section
  90. if (row.cells.length == 3) // table rows with three columns
  91. {
  92. if (row.cells[0].textContent.match('... Approved'))
  93. {
  94. row.cells[0].innerHTML += '<br><span style="color:grey;" title="Your HIT approval rate with up to 10 decimal places for better precision/accuracy, rather than being rounded to 1 decimal place.">' + approvedPctSpacer + '(' + approvedPercent + '%)</span>';
  95. row.cells[2].innerHTML += '<br><span style="color:grey;" title="Your actual \'HIT approval rate (%)\' stats qual value is truncated (always rounded down) from the un-rounded percent value. While you have fewer than 100 HITs (unclear whether that\'s approved or approved+rejected), this qual value apparently is always 100 (%). After that, it\'s never really 100% if you have even 1 rejection.">(qual:&nbsp;' + approvedQual + ')</span>';
  96. }
  97. if (row.cells[0].textContent.match('... Rejected'))
  98. {
  99. row.cells[0].innerHTML += '<br><span style="color:grey;" title="Your HIT rejection rate with up to 10 decimal places for better precision/accuracy, rather than being rounded to 1 decimal place.">' + rejectedPctSpacer + '(' + rejectedPercent + '%)</span>';
  100. row.cells[2].innerHTML += '<br><span style="color:grey;" title="Your actual \'HIT rejection rate (%)\' stats qual value is truncated (always rounded down) from the un-rounded percent value.">(qual:&nbsp;' + rejectedQual + ')</span>';
  101. }
  102. }
  103. }