mmmturkeybacon Queue Order Fix

After completing a HIT anywhere within your queue (i.e. HITs Assigned To You), this script will automatically continue the HIT at the top of your queue.

目前為 2015-03-06 提交的版本,檢視 最新版本

  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 will automatically continue the HIT at the top of your queue.
  5. // For example, if you sort your queue by Time Left (least first), you can use this script to work on the HITs that are closest to expiring instead of mturk's default behavior ignoring what your queue is sorted by and putting the oldest HIT next in line. You should only need to set the sort order once. HITs accepted after setting the sort order will be sorted automatically by mturk. Additionally you can manually continue the HIT at the top of your queue if you visit "https://www.mturk.com/mturk/myhits?first". Create a bookmark on your toolbar to quickly jump to the first HIT in your queue. This is especially useful if you just caught a HIT that will expire quickly.
  6. // @namespace http://userscripts.org/users/523367
  7. // @match https://*.mturk.com/mturk/continue*
  8. // @match https://*.mturk.com/mturk/submit
  9. // @match https://*.mturk.com/mturk/return?requesterId=*
  10. // @match https://*.mturk.com/mturk/myhits?first
  11. // @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js
  12. // @version 2.00
  13. // @grant none
  14. // ==/UserScript==
  15.  
  16. /*
  17. * IMPORTANT: if any GM_ functions are @granted event.result from Confirm Return HIT will be unavailable and this script will cause the HIT to be returned
  18. * even if Cancel was clicked in Confirm HIT Return.
  19. */
  20.  
  21. /*
  22. * Mechanical Turk has two types of HITs. By far the ExternalQuestion HITs are
  23. * the most common. These HITs use an iframe to display the task, disable the
  24. * yellow Submit HIT button, and use the hidden link with the id hitExternalNextLink
  25. * to direct the browser to a new page after the task has been submitted in the
  26. * iframe. The second type of HIT is the QuestionForm HIT. These HITs do not use
  27. * an iframe, use the yellow Submit HIT button to submit, and do not use
  28. * hitExternalNextLink to direct the browser to a new page.
  29. *
  30. * For ExternalQuestion HITs, fixing the queue order is as simple as replacing
  31. * hitExternalNextLink with the URL of the next link you wish to work on.
  32. *
  33. * QuestionForm HITs don't use the hitExternalNextLink, however we can utilize
  34. * the fact that after a QuestionForm HIT is submitted the URL ends with
  35. * /mturk/submit to redirect the browser to the top of the queue.
  36. *
  37. */
  38.  
  39.  
  40. $(document).ready(function()
  41. {
  42. var this_URL = window.location.href.split("mturk.com")[1];
  43. /* preview?groupId=GROUPIDSTRING&isPreviousIFrame= indicates not in queue
  44. * preview?isPreviousIFrame= indicates we are in the queue */
  45. var hitExternalNextLink = $('a[href^="/mturk/preview?isPreviousIFrame="][id="hitExternalNextLink"]');
  46.  
  47. if (hitExternalNextLink.length > 0)
  48. { // inside queue
  49. if (this_URL.split('?')[0] == '/mturk/continue' && $('img[alt="Submit from within the iframe"][src="/media/submit_hit_disabled.gif"]').length > 0)
  50. { // ExternalQuestion HIT
  51. /* Setting hitExternalNextLink in a QuestionForm is harmless but doing
  52. * so would require an unnecessary $.get page request, so it's best to
  53. * only change hitExternalNextLink for ExternalQuestion HITs */
  54. $.get('/mturk/myhits', function(data)
  55. {
  56. var first_queue_URL = $(data).find('a[href^="/mturk/continue"]').eq(0).attr('href');
  57. if (first_queue_URL)
  58. {
  59. var $return_button = $('a[href^="/mturk/return?"]');
  60. var return_URL = $return_button.attr('href');
  61.  
  62. if (this_URL == first_queue_URL)
  63. {
  64. var second_queue_URL = $(data).find('a[href^="/mturk/continue"]').eq(1).attr('href');
  65. if (second_queue_URL)
  66. {
  67. hitExternalNextLink.attr('href', second_queue_URL);
  68. /* play nice with MTurk Confirm Return HIT
  69. * if event.result is true then confirm from Confirm Return HIT returned true
  70. * but event.result might be undefined because MTurk Confirm Return HIT isn't running
  71. * so if event.result is not false then return HIT and load HIT at top of the queue. */
  72. $return_button.click(function(event){if(event.result != false){event.preventDefault(); $.get(return_URL); window.location.replace(second_queue_URL);}});
  73. }
  74. }
  75. else
  76. {
  77. hitExternalNextLink.attr('href', first_queue_URL);
  78. $return_button.click(function(event){if(event.result != false){event.preventDefault(); $.get(return_URL); window.location.replace(first_queue_URL);}});
  79. }
  80. }
  81. });
  82. }
  83. //else if (this_URL == '/mturk/submit' || this_URL.split('?')[0] == '/mturk/return') // next HIT after a QuestionForm HIT was submitted or next HIT after a HIT was returned
  84. else if (this_URL == '/mturk/submit') // next HIT after a QuestionForm HIT was submitted
  85. {
  86. $.get('/mturk/myhits', function(data)
  87. {
  88. var first_queue_URL = $(data).find('a[href^="/mturk/continue"]').eq(0).attr('href');
  89. if (first_queue_URL)
  90. {
  91. window.location.replace(first_queue_URL);
  92. }
  93. });
  94. }
  95. }
  96. else if (this_URL.split('?')[0] == '/mturk/continue' && $('span[id="alertboxHeader"]:contains("You have already")').length > 0)
  97. {
  98. var first_queue_URL = $('a[href^="/mturk/continue"]').eq(0).attr('href');
  99. if (first_queue_URL)
  100. {
  101. window.location.replace(first_queue_URL);
  102. }
  103. }
  104. else if (this_URL == '/mturk/myhits?first')
  105. { // bookmark link was used or next HIT in queue was already completed
  106. $.get('/mturk/myhits', function(data)
  107. {
  108. var first_queue_URL = $(data).find('a[href^="/mturk/continue"]').eq(0).attr('href');
  109. if (first_queue_URL)
  110. {
  111. window.location.replace(first_queue_URL);
  112. }
  113. });
  114. }
  115. // else it's a submit link but not inside the queue, so do nothing
  116.  
  117. });