mmmturkeybacon Queue Order Fix

After completing a HIT anywhere within your queue (i.e. HITs Assigned To You), this script

As of 2014-07-08. See the latest version.

  1. // ==UserScript==
  2. // @name mmmturkeybacon Queue Order Fix
  3. // @author mmmturkeybacon
  4. // @description After completing a HIT anywhere within your queue (i.e. HITs Assigned To You), this script
  5. // will automatically continue the HIT at the top* of your queue. If you sort your queue by
  6. // Time Left (least first), you can use this script to work around mturk's default** behavior
  7. // of ignoring what your queue is sorted by. You should only need to set the sort order once.
  8. // HITs accepted after setting the sort order will be sorted automatically.
  9. // Additionally you can manually continue the HIT at the top of your queue if you visit
  10. // "https://www.mturk.com/mturk/myhits?first". Create a bookmark on your
  11. // toolbar to quickly jump to the first HIT in your queue. This is especially useful if you
  12. // just caught a HIT that will expire quickly.
  13. // *The HIT at the top of the queue is determined when the HIT currently being worked on is
  14. // loaded. This means if a new HIT gets put on the top of the queue after the current HIT has
  15. // already been loaded it will not be the very next HIT, but the one just after that instead.
  16. // **To restore the default behavior sort by Assigned On (earliest first).
  17. // @namespace http://userscripts.org/users/523367
  18. // @match https://*.mturk.com/mturk/continue*
  19. // @match https://*.mturk.com/mturk/submit
  20. // @match https://*.mturk.com/mturk/myhits?first
  21. // @require http://code.jquery.com/jquery-latest.min.js
  22. // @version 1.65
  23. // @grant none
  24. // ==/UserScript==
  25.  
  26. /*
  27. * Mechanical Turk has two types of HITs. By far the ExternalQuestion HITs are
  28. * the most common. These HITs use an iframe to display the task, disable the
  29. * yellow Submit HIT button, and use the hidden link with the id hitExternalNextLink
  30. * to direct the browser to a new page after the task has been submitted in the
  31. * iframe. The second type of HIT is the QuestionForm HIT. These HITs do not use
  32. * an iframe, use the yellow Submit HIT button to submit, and do not use
  33. * hitExternalNextLink to direct the browser to a new page.
  34. *
  35. * For ExternalQuestion HITs, fixing the queue order is as simple as replacing
  36. * hitExternalNextLink with the URL of the next link you wish to work on.
  37. *
  38. * QuestionForm HITs don't use the hitExternalNextLink, however we can utilize
  39. * the fact that after a QuestionForm HIT is submitted the URL ends with
  40. * /mturk/submit to redirect the browser to the top of the queue.
  41. *
  42. */
  43.  
  44. $(document).ready(function()
  45. {
  46. var this_URL = window.location.href.split("mturk.com")[1];
  47. /* preview?groupId=GROUPIDSTRING&isPreviousIFrame= indicates not in queue
  48. * preview?isPreviousIFrame= indicates we are in the queue */
  49. var hitExternalNextLink = $('a[href^="/mturk/preview?isPreviousIFrame="][id="hitExternalNextLink"]');
  50.  
  51. if (hitExternalNextLink.length > 0)
  52. { // inside queue
  53. if (this_URL.split('?')[0] == '/mturk/continue' && $('img[alt="Submit from within the iframe"][src="/images/submit_hit_disabled.gif"]').length > 0)
  54. { // ExternalQuestion HIT
  55. /* Setting hitExternalNextLink in a QuestionForm is harmless but doing
  56. * so would require an unnecessary $.get page request, so it's best to
  57. * only change hitExternalNextLink for ExternalQuestion HITs */
  58. $.get('/mturk/myhits', function(data)
  59. {
  60. var first_queue_URL = $(data).find('a[href^="/mturk/continue"]').eq(0).attr('href');
  61. if (first_queue_URL)
  62. {
  63. if (this_URL == first_queue_URL)
  64. {
  65. var second_queue_URL = $(data).find('a[href^="/mturk/continue"]').eq(1).attr('href');
  66. if (second_queue_URL)
  67. {
  68. hitExternalNextLink.attr('href', second_queue_URL);
  69. }
  70. }
  71. else
  72. {
  73. hitExternalNextLink.attr('href', first_queue_URL);
  74. }
  75. }
  76. });
  77. }
  78. else if (this_URL == '/mturk/submit')
  79. { // next HIT after a QuestionForm HIT was submitted
  80. $.get('/mturk/myhits', function(data)
  81. {
  82. var first_queue_URL = $(data).find('a[href^="/mturk/continue"]').eq(0).attr('href');
  83. if (first_queue_URL)
  84. {
  85. window.location.replace(first_queue_URL);
  86. }
  87. });
  88. }
  89. }
  90. else if (this_URL == '/mturk/myhits?first')
  91. { // bookmark link was used
  92. $.get('/mturk/myhits', function(data)
  93. {
  94. var first_queue_URL = $(data).find('a[href^="/mturk/continue"]').eq(0).attr('href');
  95. if (first_queue_URL)
  96. {
  97. window.location.replace(first_queue_URL);
  98. }
  99. });
  100. }
  101. // else it's a submit link but not inside the queue, so do nothing
  102.  
  103. });