mmmturkeybacon Checkpoint Creator

Adds checkboxes next to HIT links so that you can set a checkpoint.

当前为 2014-07-08 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name mmmturkeybacon Checkpoint Creator
  3. // @author mmmturkeybacon
  4. // @description Adds checkboxes next to HIT links so that you can set a checkpoint.
  5. // A checkpoint will notify you that you've already seen a HIT by
  6. // changing the HIT link to display the date the checkpoint was set. A
  7. // well-placed checkpoint is useful when browsing HITs by creation date
  8. // (newest first) because it will alert you that you've already seen the
  9. // checkpoint HIT and probably all the HITs that come after it.
  10. // It's best to place a checkpoint on a HIT that won't be recreated
  11. // because recreated HITs jump to the first page.
  12. // mmmturkeybacon Color Coded Search with Checkpoints has the same
  13. // functionality built-in. So if you have that installed you don't
  14. // need this script.
  15. // @namespace http://userscripts.org/users/523367
  16. // @match https://*.mturk.com/mturk/viewhits*
  17. // @match https://*.mturk.com/mturk/findhits*
  18. // @match https://*.mturk.com/mturk/sorthits*
  19. // @match https://*.mturk.com/mturk/searchbar*
  20. // @match https://*.mturk.com/mturk/viewsearchbar*
  21. // @match https://*.mturk.com/mturk/sortsearchbar*
  22. // @match https://*.mturk.com/mturk/preview?*
  23. // @match https://*.mturk.com/mturk/statusdetail*
  24. // @match https://*.mturk.com/mturk/return*
  25. // @require http://code.jquery.com/jquery-latest.min.js
  26. // @version 1.3
  27. // @grant GM_getValue
  28. // @grant GM_setValue
  29. // ==/UserScript==
  30.  
  31. //var CHECKPOINT_COLOR = "#00AAAA"; // dark green-blue
  32. var CHECKPOINT_COLOR = "#000000"; // black
  33. var CHECKPOINT_MESSAGE = "CHECKPOINT REACHED!";
  34. //var CHECKPOINT_MESSAGE = "YOU SHALL NOT PASS!";
  35.  
  36. var is_HIT = $("input[type='hidden'][name='isAccepted']").length > 0;
  37. if (is_HIT)
  38. {
  39. // not on a search page so quit
  40. return;
  41. }
  42.  
  43. // This script won't place a checkbox next to HITs for which you are not
  44. // qualified that don't have a link.
  45. $('a[href^="/mturk/preview?groupId="]').each(function()
  46. {
  47. var checkbox = document.createElement('INPUT');
  48. checkbox.type = 'checkbox';
  49. checkbox.name = $(this).attr('href').slice(23); // groupId
  50. checkbox.checked = GM_getValue(checkbox.name+'_checked', false);
  51. checkbox.addEventListener('click', set_checkpoint);
  52. //checkbox.addEventListener('click', (function(checkbox,$link_obj){return function(){set_checkpoint(checkbox,$link_obj);};})(checkbox,$(this)) );
  53. checkbox.style.cssText ='vertical-align:middle;';
  54. $(this).after(checkbox);
  55. mark_checkpoint(checkbox, $(this));
  56. });
  57.  
  58. function set_checkpoint(e)
  59. {
  60. var caller = e.target || e.srcElement;
  61. var d = new Date();
  62. GM_setValue(caller.name+'_checked', caller.checked);
  63. GM_setValue(caller.name+'_date', '['+d.toLocaleDateString()+'] ');
  64. }
  65.  
  66. function mark_checkpoint(checkbox, $link_obj)
  67. {
  68. if (checkbox.checked == true)
  69. {
  70. var checkpoint_date = GM_getValue(checkbox.name+'_date');
  71. $link_obj.closest('table[width="100%"][cellspacing="0"][cellpadding="0"][border="0"][height="100%"]').css('border', '50px solid '+CHECKPOINT_COLOR);
  72. $link_obj.text(checkpoint_date+CHECKPOINT_MESSAGE);
  73. }
  74. }