Mturk Expired-Queue-HIT-Death-Loop Rescuer

Redirects to queue view on expired queue HIT and continues on HITs with more time remaining

  1. // ==UserScript==
  2. // @name Mturk Expired-Queue-HIT-Death-Loop Rescuer
  3. // @description Redirects to queue view on expired queue HIT and continues on HITs with more time remaining
  4. // @author DCI
  5. // @version 1.0
  6. // @namespace www.redpandanetwork.org
  7. // @include https://www.mturk.com/mturk/myhits?ExpiredRedirect
  8. // @include https://www.mturk.com/mturk/preview?isPreviousHitExpired*
  9. // @exclude https://www.mturk.com/mturk/*&groupId*
  10. // ==/UserScript==
  11.  
  12. // This script will redirect you to your queue view page when a queued HIT you are working on expires.
  13. // You will then be redirected to the first HIT in your queue that meets the minimum time remaining requirement.
  14. // MinimumTime is in seconds but can be set to a number greater than 60.
  15. var MinimumTime = 30;
  16.  
  17.  
  18. if (window.location.toString().indexOf('preview?isPreviousHitExpired') !== -1){
  19. window.location.replace("https://www.mturk.com/mturk/myhits?ExpiredRedirect");
  20. }
  21.  
  22. if (window.location.toString() === "https://www.mturk.com/mturk/myhits?ExpiredRedirect"){
  23. var hit_capsules = document.getElementsByTagName('tbody')[6].children;
  24. for (f = 0; f < hit_capsules.length; f++){
  25. var timer = hit_capsules[f].getElementsByClassName('capsule_field_text')[2].innerHTML;
  26. var hastime = hit_capsules[f].getElementsByTagName('a')[2].href;
  27. if (hit_capsules[f].innerHTML.indexOf('minute') !== -1){
  28. var minutes = parseInt(timer.split('minutes')[0].trim());
  29. var seconds = parseInt(timer.split('minutes')[1].split('seconds')[0].trim());
  30. var remaining = (minutes * 60) + seconds;
  31. if (remaining >= MinimumTime){
  32. window.location.replace(hastime);
  33. }
  34. }
  35. else {
  36. if (hit_capsules[f].innerHTML.indexOf('seconds') !== -1){
  37. var seconds = parseInt(timer.split('seconds')[0].trim());
  38. if (seconds >= MinimumTime){
  39. window.location.replace(hastime);
  40. }
  41. }
  42. }
  43. }
  44. }