mmmturkeybacon AutoApprove Time and Ghost HIT Buster

Shows formated automatic approval time and if a HIT is

  1. // ==UserScript==
  2. // @name mmmturkeybacon AutoApprove Time and Ghost HIT Buster
  3. // @author mmmturkeybacon
  4. // @description Shows formated automatic approval time and if a HIT is
  5. // truly available by replacing the text of its link in the
  6. // search results. Using this script will greatly increase
  7. // the number of page requests you make while searching and
  8. // may cause Page Monitor to give false alarms.
  9. // @namespace http://userscripts.org/users/523367
  10. // @match https://*.mturk.com/mturk/viewhits*
  11. // @match https://*.mturk.com/mturk/findhits*
  12. // @match https://*.mturk.com/mturk/sorthits*
  13. // @match https://*.mturk.com/mturk/searchbar*
  14. // @match https://*.mturk.com/mturk/viewsearchbar*
  15. // @match https://*.mturk.com/mturk/sortsearchbar*
  16. // @match https://*.mturk.com/mturk/preview?*
  17. // @match https://*.mturk.com/mturk/return*
  18. // @require http://code.jquery.com/jquery-latest.min.js
  19. // @version 1.02
  20. // @grant none
  21. // ==/UserScript==
  22.  
  23. // Only run if on search results.
  24. var is_a_HIT = $('input[type="hidden"][name="isAccepted"]').length > 0;
  25. if (!is_a_HIT)
  26. {
  27. var $preview_links = $('a[href^="/mturk/preview?"]');
  28. function bustin_makes_me_feel_good($link)
  29. {
  30. $.get($link.attr('href'), function(data)
  31. {
  32. var $src = $(data);
  33. var maxpagerate = $src.find('td[class="error_title"]:contains("You have exceeded the maximum allowed page request rate for this website.")');
  34. if (maxpagerate.length == 0)
  35. {
  36. var is_a_HIT = $src.find('input[type="hidden"][name="isAccepted"]').length > 0;
  37. if (is_a_HIT)
  38. {
  39. var hitAutoAppDelayInSeconds = $src.find('input[type="hidden"][name="hitAutoAppDelayInSeconds"]').val();
  40. // time formatting code modified from http://userscripts.org/scripts/show/169154
  41. var days = Math.floor((hitAutoAppDelayInSeconds/(60*60*24)));
  42. var hours = Math.floor((hitAutoAppDelayInSeconds/(60*60)) % 24);
  43. var mins = Math.floor((hitAutoAppDelayInSeconds/60) % 60);
  44. var secs = hitAutoAppDelayInSeconds % 60;
  45. var time_str = (days == 0 ? '' : days + (days > 1 ? ' days ' : ' day ')) +
  46. (hours == 0 ? '' : hours + (hours > 1 ? ' hours ' : ' hour ')) +
  47. (mins == 0 ? '' : mins + (mins > 1 ? ' minutes ' : ' minute ')) +
  48. (secs == 0 ? '' : secs + (secs > 1 ? ' seconds ' : ' second '));
  49. time_str = time_str.replace(/\s+$/, '');
  50. if (hitAutoAppDelayInSeconds == 0)
  51. {
  52. time_str = "0 seconds";
  53. }
  54. $link.text('['+time_str+'] Available');
  55. }
  56. else
  57. {
  58. $link.text('G-G-Ghost!');
  59. }
  60. }
  61. else
  62. {
  63. $link.text('Page Request Rate Exceeded');
  64. }
  65. });
  66. }
  67. function preview_links_loop(i)
  68. {
  69. var $next_link = $preview_links.eq(i);
  70. i++;
  71. if ($next_link.length > 0)
  72. {
  73. bustin_makes_me_feel_good($next_link);
  74. // Slow don't page request rate.
  75. // This won't make the script immune to page request
  76. // errors. Retrying after an error would take to long.
  77. setTimeout(function(){preview_links_loop(i)}, 300);
  78. }
  79. }
  80. if ($preview_links.length > 0)
  81. {
  82. preview_links_loop(0);
  83. }
  84. }