mmmturkeybacon Butt-in Buttons

Adds a PandA (previewandaccept: accepts a HIT from within in the group at random) link/button. Adds a Pick & Roll button that accepts the very HIT you are previewing (if still available) and then skips to a new HIT. Adds the automatically accept checkbox to HIT previews. Shows the Accept button and CAPTCHAs right away. Adds a RandA button that returns a HIT and loads the HIT's PandA URL. Makes the Return button red. Puts the buttons closer to the workspace. Removes the "Total Earned" field.

  1. // ==UserScript==
  2. // @name mmmturkeybacon Butt-in Buttons
  3. // @version 1.10
  4. // @description Adds a PandA (previewandaccept: accepts a HIT from within in the group at random) link/button. Adds a Pick & Roll button that accepts the very HIT you are previewing (if still available) and then skips to a new HIT. Adds the automatically accept checkbox to HIT previews. Shows the Accept button and CAPTCHAs right away. Adds a RandA button that returns a HIT and loads the HIT's PandA URL. Makes the Return button red. Puts the buttons closer to the workspace. Removes the "Total Earned" field.
  5. // @author mmmturkeybacon
  6. // @namespace http://userscripts.org/users/523367
  7. // @match https://www.mturk.com/mturk/preview?*
  8. // @match https://*.mturk.com/mturk/previewandaccept?*
  9. // @match https://*.mturk.com/mturk/accept?*
  10. // @match https://*.mturk.com/mturk/continue?*
  11. // @match https://*.mturk.com/mturk/submit*
  12. // @match https://*.mturk.com/mturk/return?*
  13. // //@run-at document-start
  14. // @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js
  15. // @grant GM_addStyle
  16. // ==/UserScript==
  17.  
  18. // following line borrowed from: https://greasyfork.org/en/scripts/5918-mturk-show-captcha-and-accept-button-asap/code
  19. GM_addStyle("#javascriptDependentFunctionality { display: block !important; }");
  20.  
  21. $(document).ready(function()
  22. {
  23. //var GENERIC_BUTTON_COLOR = '#ffd15f';
  24. //var GENERIC_BUTTON_COLOR = '#fbc134';
  25. var GENERIC_BUTTON_COLOR = '#a6cdde';
  26. var RANDA_BUTTON_COLOR = '#ff0000';
  27.  
  28. var $isAccepted = $('input[type="hidden"][name="isAccepted"]');
  29. //if (window.location.href.indexOf('https://www.mturk.com/mturk/preview?') > -1)
  30. if ($isAccepted.val() == 'false') //preview
  31. {
  32. $('a[id="requester.tooltip"]:contains("Requester:")').closest('div[style="width: auto; margin-top: 5px; margin-left: 10px; margin-right: 10px; margin-bottom: 5px;"]').detach().insertAfter('div[id="subtabs_and_searchbar"]');
  33. $('b:contains("Total Earned")').closest('tr').remove();
  34.  
  35. $('input[name="/accept"][src="/media/accept_hit.gif"][type="image"][border="0"]').each(function()
  36. {
  37. $(this).closest('td').before('<td rowspan="2" height="26" nowrap="" valign="middle" align="center"><a style="display: block;" name="autoAcceptCheckboxWrapper"><input type="checkbox" onclick="javascript:toggleAllCheckboxes(this);" value="on" name="autoAcceptEnabled" title="Automatically accept the next HIT"></input></a></td>');
  38. });
  39.  
  40. var hitId = $('input[type="hidden"][name="hitId"]').attr('value');
  41. var prevHitSubmitted = $('input[type="hidden"][name="prevHitSubmitted"]').attr('value');
  42. var prevRequester = $('input[type="hidden"][name="prevRequester"]').attr('value');
  43. var requesterId = $('input[type="hidden"][name="requesterId"]').attr('value');
  44. var prevReward = $('input[type="hidden"][name="prevReward"]').attr('value');
  45. var hitAutoAppDelayInSeconds = $('input[type="hidden"][name="hitAutoAppDelayInSeconds"]').attr('value');
  46. var groupId = $('input[type="hidden"][name="groupId"]').attr('value');
  47. var signature = $('input[type="hidden"][name="signature"]').attr('value');
  48. var autoAcceptEnabled_param = $('input[value="on"][name="autoAcceptEnabled"][type="checkbox"]').is(':checked') ? '&autoAcceptEnabled=on' : '';
  49.  
  50. var panda_URL = 'https://www.mturk.com/mturk/previewandaccept?groupId='+groupId;
  51. var pick_and_roll_URL = 'https://www.mturk.com/mturk/accept?hitId='+hitId+'&prevHitSubmitted='+prevHitSubmitted+'&prevRequester='+encodeURIComponent(prevRequester).replace(/%20/g,'+')+'&requesterId='+requesterId+'&prevReward='+prevReward+'&hitAutoAppDelayInSeconds='+hitAutoAppDelayInSeconds+'&groupId='+groupId+'&signature='+signature;
  52. var skip_URL = $('img[src="/media/skip_hit.gif"][height="22"][width="68"][border="0"]').parent().attr('href');
  53.  
  54. //* top buttons*/
  55. var $buttons_table_top = $('td[valign="top"][width="200"][align="center"] > table[cellpadding="0"][cellspacing="0"][border="0"]');
  56. $buttons_table_top.parent().prev()[0].width = '30%';
  57. $buttons_table_top.parent()[0].width = '400';
  58. $buttons_table_top.parent().next()[0].width = '30%';
  59. var $first_row = $buttons_table_top.find('tr:eq(0)');
  60. $first_row.after('<tr><td nowrap="" align="center"></td><td nowrap="" align="center"></td><td nowrap="" align="center"></td><td nowrap="" align="center"></td><td nowrap="" align="center"></td></tr>');
  61. $first_row.remove();
  62.  
  63. var $spacer_td = $buttons_table_top.find('tr:eq(1) > td:eq(2)');
  64. $spacer_td.after('<td rowspan="2" height="26" nowrap="" valign="top" align="center"><button id="mtbpar_pick_btn_top" title="Accept _this_ HIT and Skip to the next one. If this HIT is successfully acccepted it will be in your queue." style="height: 22px; color: #000000; background-color: '+GENERIC_BUTTON_COLOR+'; border-color: #000000; border-radius: 4px; moz-border-radius: 4px; webkit-border-radius: 4px;">Pick & Roll</button></td>');
  65. $spacer_td.after('<td rowspan="2" height="26" nowrap="" valign="top" align="center"><a id="mtbpar_panda_a_top" href="'+panda_URL+autoAcceptEnabled_param+'"><button id="mtbpar_panda_btn_top" title="A Preview and Accept link. Middle click works for this button." style="height: 22px; color: #000000; background-color: '+GENERIC_BUTTON_COLOR+'; border-color: #000000; border-radius: 4px; moz-border-radius: 4px; webkit-border-radius: 4px;">PandA</button></a></td>');
  66. $spacer_td.remove();
  67.  
  68. //* bottom buttons*/
  69. var $buttons_table_bottom = $('div[align="center"] > table[cellpadding="0"][cellspacing="0"][border="0"]');
  70. var $first_row = $buttons_table_bottom.find('tr:eq(0)');
  71. $first_row.after('<tr><td nowrap="" align="center"></td><td nowrap="" align="center"></td><td nowrap="" align="center"></td><td nowrap="" align="center"></td></tr>');
  72. $first_row.remove();
  73.  
  74. var $spacer_td = $buttons_table_bottom.find('tr:eq(1) > td:eq(2)');
  75. $spacer_td.after('<td rowspan="2" height="26" nowrap="" valign="top" align="center"><button id="mtbpar_pick_btn_bottom" title="Accept _this_ HIT and Skip to the next one. If this HIT is successfully acccepted it will be in your queue." style="height: 22px; color: #000000; background-color: '+GENERIC_BUTTON_COLOR+'; border-color: #000000; border-radius: 4px; moz-border-radius: 4px; webkit-border-radius: 4px;">Pick & Roll</button></td>');
  76. $spacer_td.after('<td rowspan="2" height="26" nowrap="" valign="top" align="center"><a id="mtbpar_panda_a_bottom" href="'+panda_URL+autoAcceptEnabled_param+'"><button id="mtbpar_panda_btn_bottom" title="A Preview and Accept link. Middle click works for this button." style="height: 22px; color: #000000; background-color: '+GENERIC_BUTTON_COLOR+'; border-color: #000000; border-radius: 4px; moz-border-radius: 4px; webkit-border-radius: 4px;">PandA</button></a></td>');
  77. $spacer_td.remove();
  78.  
  79. //* listeners */
  80. $('input[value="on"][name="autoAcceptEnabled"][type="checkbox"]').bind( 'click', function(){autoAcceptEnabled_param = $(this).is(':checked') ? '&autoAcceptEnabled=on' : ''; $('a[id^="mtbpar_panda_a"]').attr('href', panda_URL+autoAcceptEnabled_param)} );
  81. // preventDefault prevents the form from being submitted as if the Accept button had been pressed.
  82. $('button[id^="mtbpar_pick_btn"]').bind('click', function(event)
  83. {
  84. event.preventDefault();
  85. $.get(pick_and_roll_URL, function(data)
  86. {
  87. var queue_full = $(data).find('span[id="alertboxHeader"]:contains("You have accepted the maximum number of HITs allowed.")').length > 0;
  88. if (!queue_full)
  89. {
  90. window.location.href = skip_URL
  91. }
  92. else
  93. {
  94. alert('You have accepted the maximum number of HITs allowed.');
  95. }
  96. })
  97. });
  98. $('button[id^="mtbpar_panda_btn"]').bind('click', function(event){ event.preventDefault(); window.location.href = panda_URL+autoAcceptEnabled_param; });
  99. }
  100. else if ($isAccepted.val() == 'true') //accepted
  101. {
  102. var RETURN_BUTTON_IMAGE = 'data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAFIAAAAWCAMAAABkOzvTAAAC/VBMVEUAAAAAA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ZsJ3YKsxMT+PzxSKhkMfjcgWClJSUpKRpHyYB074wPK8GwgIBl8vjCYUi0KelZwq3ErtXikRCHlcAnoSEuORkDofNZsfqiRwCQwKiHE5yclxCAtgFXJ5QJFq5mzi6nI1tcckcdmxk4loWKyIi3sDqIRkIRUSwWGsTI2PZHBCDl738KHF9iXv8OrhQIgtUq1csCwqKiQkP/xb4ZkhwIjw8JiYoaNkK8EewwBu7Lt59yXWi7/iceb5ffe7nt2Cu78L5s7y8PDw+wXw0LPqYh4eX16z5C33nLvDzc/fznTfneB9BPDu2aIaLi5PT1CmT7O0nOzra2U10dnZweHdYHBycnSfa2Tk6Tra3nzRlqpPT+y4zFh17hv98+q4d3PLjqqiosLDQ0ODgwMDFAQEBPj4+Xw8DRCC4ODAwODg0NCwsKmrVD1sOXoM7vgAKeMvn1KwflwAAAABJRU5ErkJggg==';
  103.  
  104. $('img[src="/media/return_hit.gif"]').attr('src', RETURN_BUTTON_IMAGE);
  105.  
  106. $('a[id="requester.tooltip"]:contains("Requester:")').closest('div[style="width: auto; margin-top: 5px; margin-left: 10px; margin-right: 10px; margin-bottom: 5px;"]').detach().insertAfter('div[id="subtabs_and_searchbar"]');
  107. $('b:contains("Total Earned")').closest('tr').remove();
  108.  
  109. //* top buttons*/
  110. var $buttons_table_top = $('td[valign="top"][width="200"][align="center"] > table[cellpadding="0"][cellspacing="0"][border="0"]');
  111. $buttons_table_top.parent().prev()[0].width = '30%';
  112. $buttons_table_top.parent()[0].width = '400';
  113. $buttons_table_top.parent().next()[0].width = '30%';
  114. $buttons_table_top.find('tr:eq(1) > td').attr('valign', 'top');
  115.  
  116. //* bottom buttons*/
  117. var $buttons_table_bottom = $('div[align="center"] > table[cellpadding="0"][cellspacing="0"][border="0"]');
  118. $buttons_table_bottom.find('tr:eq(1) > td').attr('valign', 'top');
  119.  
  120. var groupId = $('input[type="hidden"][name="groupId"]').attr('value');
  121. if (groupId)
  122. {
  123. var autoAcceptEnabled = $('input[value="on"][name="autoAcceptEnabled"][type="checkbox"]').is(':checked')
  124. var autoAcceptEnabled_prop = autoAcceptEnabled ? 'checked="checked"' : '';
  125. var autoAcceptEnabled_param = autoAcceptEnabled ? '&autoAcceptEnabled=on' : '';
  126.  
  127. var panda_URL = 'https://www.mturk.com/mturk/previewandaccept?groupId='+groupId;
  128. var return_URL = $('a[href^="/mturk/return?"]').attr('href');
  129.  
  130. $('input[type="checkbox"][onclick="javascript:toggleAllCheckboxes(this);"]').closest('tr').remove();
  131. $('[src^="/media/submit"][border="0"]').each(function()
  132. {
  133. $(this).closest('td').before('<td rowspan="2" height="26" nowrap="" valign="middle" align="center"><a style="display: block;" name="autoAcceptCheckboxWrapper"><input type="checkbox" onclick="javascript:toggleAllCheckboxes(this);" value="on" name="autoAcceptEnabled" title="Automatically accept the next HIT" '+autoAcceptEnabled_prop+'></input></a></td>');
  134. });
  135.  
  136. //* top buttons*/
  137. var $first_row = $buttons_table_top.find('tr:eq(0)');
  138. $first_row.after('<tr><td nowrap="" align="center"></td><td nowrap="" align="center"></td><td nowrap="" align="center"></td><td nowrap="" align="center"></td></tr>');
  139. $first_row.remove();
  140.  
  141. var $spacer_td = $buttons_table_top.find('tr:eq(1) > td:eq(2)');
  142. $spacer_td.after('<td rowspan="2" height="26" nowrap="" valign="top" align="center"><button id="mtbpar_randa_btn_top" title="Return this HIT and Accept another one." style="height: 22px; color: #000000; background-color: '+RANDA_BUTTON_COLOR+'; border-color: #000000; border-radius: 4px; moz-border-radius: 4px; webkit-border-radius: 4px;">RandA</button></td>');
  143. $spacer_td.remove();
  144.  
  145. //* bottom buttons*/
  146. var $first_row = $buttons_table_bottom.find('tr:eq(0)');
  147. $first_row.after('<tr><td nowrap="" align="center"></td></td><td nowrap="" align="center"></td><td nowrap="" align="center"></td></tr>');
  148. $first_row.remove();
  149.  
  150. var $spacer_td = $buttons_table_bottom.find('tr:eq(1) > td:eq(2)');
  151. $spacer_td.after('<td rowspan="2" height="26" nowrap="" valign="top" align="center"><button id="mtbpar_randa_btn_bottom" title="Return this HIT and Accept another one." style="height: 22px; color: #000000; background-color: '+RANDA_BUTTON_COLOR+'; border-color: #000000; border-radius: 4px; moz-border-radius: 4px; webkit-border-radius: 4px;">RandA</button></td>');
  152. $spacer_td.remove();
  153.  
  154. //* listeners */
  155. $('input[value="on"][name="autoAcceptEnabled"][type="checkbox"]').bind( 'click', function(){autoAcceptEnabled_param = $(this).is(':checked') ? '&autoAcceptEnabled=on' : ''; $('a[id^="mtbpar_panda_a"]').attr('href', panda_URL+autoAcceptEnabled_param)} );
  156. // preventDefault prevents the form from being submitted as if the Accept button had been pressed.
  157. $('button[id^="mtbpar_randa_btn"]').bind('click', function(event){ event.preventDefault(); $.get(return_URL, function(data){window.location.href = panda_URL+autoAcceptEnabled_param}) });
  158. }
  159. }
  160. // else $isAccepted.val() is undefined so it is not a HIT
  161. });