mmmturkeybacon Queue Order Fix

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

当前为 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
  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/return?requesterId=*
  21. // @match https://*.mturk.com/mturk/myhits?first
  22. // @require http://code.jquery.com/jquery-latest.min.js
  23. // @version 1.67
  24. // @grant none
  25. // ==/UserScript==
  26.  
  27. /*
  28. * Mechanical Turk has two types of HITs. By far the ExternalQuestion HITs are
  29. * the most common. These HITs use an iframe to display the task, disable the
  30. * yellow Submit HIT button, and use the hidden link with the id hitExternalNextLink
  31. * to direct the browser to a new page after the task has been submitted in the
  32. * iframe. The second type of HIT is the QuestionForm HIT. These HITs do not use
  33. * an iframe, use the yellow Submit HIT button to submit, and do not use
  34. * hitExternalNextLink to direct the browser to a new page.
  35. *
  36. * For ExternalQuestion HITs, fixing the queue order is as simple as replacing
  37. * hitExternalNextLink with the URL of the next link you wish to work on.
  38. *
  39. * QuestionForm HITs don't use the hitExternalNextLink, however we can utilize
  40. * the fact that after a QuestionForm HIT is submitted the URL ends with
  41. * /mturk/submit to redirect the browser to the top of the queue.
  42. *
  43. */
  44.  
  45.  
  46. $(document).ready(function()
  47. {
  48. var this_URL = window.location.href.split("mturk.com")[1];
  49. /* preview?groupId=GROUPIDSTRING&isPreviousIFrame= indicates not in queue
  50. * preview?isPreviousIFrame= indicates we are in the queue */
  51. var hitExternalNextLink = $('a[href^="/mturk/preview?isPreviousIFrame="][id="hitExternalNextLink"]');
  52.  
  53. if (hitExternalNextLink.length > 0)
  54. { // inside queue
  55. if (this_URL.split('?')[0] == '/mturk/continue' && $('img[alt="Submit from within the iframe"][src="/media/submit_hit_disabled.gif"]').length > 0)
  56. { // ExternalQuestion HIT
  57. /* Setting hitExternalNextLink in a QuestionForm is harmless but doing
  58. * so would require an unnecessary $.get page request, so it's best to
  59. * only change hitExternalNextLink for ExternalQuestion HITs */
  60. $.get('/mturk/myhits', function(data)
  61. {
  62. var first_queue_URL = $(data).find('a[href^="/mturk/continue"]').eq(0).attr('href');
  63. if (first_queue_URL)
  64. {
  65. var $return_button = $('a[href^="/mturk/return?"]');
  66. var return_URL = $return_button.attr('href');
  67.  
  68. if (this_URL == first_queue_URL)
  69. {
  70. var second_queue_URL = $(data).find('a[href^="/mturk/continue"]').eq(1).attr('href');
  71. if (second_queue_URL)
  72. {
  73. hitExternalNextLink.attr('href', second_queue_URL);
  74. // play nice with MTurk Confirm Return HIT, if confirm returns true then return HIT and load HIT at top of the queue
  75. $return_button.click(function(event){if(event.result){event.preventDefault(); $.get(return_URL); window.location.replace(second_queue_URL);}});
  76. }
  77. }
  78. else
  79. {
  80. hitExternalNextLink.attr('href', first_queue_URL);
  81. $return_button.click(function(event){if(event.result){event.preventDefault(); $.get(return_URL); window.location.replace(first_queue_URL);}});
  82. }
  83. }
  84. });
  85. }
  86. //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
  87. else if (this_URL == '/mturk/submit') // next HIT after a QuestionForm HIT was submitted
  88. {
  89. $.get('/mturk/myhits', function(data)
  90. {
  91. var first_queue_URL = $(data).find('a[href^="/mturk/continue"]').eq(0).attr('href');
  92. if (first_queue_URL)
  93. {
  94. window.location.replace(first_queue_URL);
  95. }
  96. });
  97. }
  98. }
  99. else if (this_URL == '/mturk/myhits?first')
  100. { // bookmark link was used
  101. $.get('/mturk/myhits', function(data)
  102. {
  103. var first_queue_URL = $(data).find('a[href^="/mturk/continue"]').eq(0).attr('href');
  104. if (first_queue_URL)
  105. {
  106. window.location.replace(first_queue_URL);
  107. }
  108. });
  109. }
  110. // else it's a submit link but not inside the queue, so do nothing
  111.  
  112. });