HIT Return & Accept

This userscript returns your current mTurk then accepts a new one. It also checks the "accept next hit" box.

  1. // ==UserScript==
  2. // @name HIT Return & Accept
  3. // @namespace http://ericfraze.com
  4. // @version 0.2
  5. // @description This userscript returns your current mTurk then accepts a new one. It also checks the "accept next hit" box.
  6. // @include https://www.mturk.com/mturk/accept*
  7. // @include https://www.mturk.com/mturk/submit*
  8. // @include https://www.mturk.com/mturk/previewandaccept*
  9. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js
  10. // @copyright 2014+, Eric Fraze
  11. // ==/UserScript==
  12.  
  13. //Wait for page to load fully
  14. $(document).ready(function() {
  15. // Make sure the hit has been accepted
  16. if ( ( $("a[id*='pipeline.submit.iframes.tooltip']").length>0 ) || ( $("input[name='/submit']").length>0 ) ) {
  17. // Make sure the return button exits
  18. if ( $("a[href*='mturk/return']").length>0 ) {
  19. // Select each return button
  20. $("a[href*='mturk/return']").each(function() {
  21. // Add custom text next to return button text
  22. $(this).parents(':eq(2)').children(":first-child").append('<td><img src="/media/spacer.gif" width="20" height="8" border="0"></td>');
  23. $(this).parents(':eq(2)').children(":first-child").append('<td align="center" nowrap="">Return & Accept?</td>');
  24. // Add custom button next to return button
  25. $(this).parents(':eq(1)').append('<td><img src="/media/spacer.gif" width="20" height="1" border="0"></td>');
  26. $(this).parents(':eq(1)').append('<td><a id="returnAccept" href="#"><img src="/media/skip_hit.gif" alt="" border="0" width="68" height="22"></a></td>');
  27. });
  28. }
  29.  
  30. // Check the auto accept box
  31. $("input[name='autoAcceptEnabled']").prop('checked', true);
  32.  
  33. // If custom button is clicked
  34. $("#returnAccept").click(function() {
  35. // Get URL parameters
  36. var url = window.location.href.split("?");
  37.  
  38. // Return the HIT with Ajax then accept new hit
  39. $.ajax({
  40. // Return the hit
  41. url: $("a[href*='mturk/return']").attr("href"),
  42. context: document.body
  43. }).done(function() {
  44. // Accept new hit
  45. window.location.replace("/mturk/previewandaccept?" + url[1]) + "&";
  46. });
  47. });
  48. }
  49. });