ProductRnR

Marks a default radio button depending on the HIT.

当前为 2015-10-28 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name ProductRnR
  3. // @namespace https://greasyfork.org/users/11580
  4. // @version 1.5.5
  5. // @description Marks a default radio button depending on the HIT.
  6. // @author Kadauchi
  7. // @icon http://www.mturkgrind.com/data/avatars/l/1/1084.jpg?1432698290
  8. // @include https://www.mturkcontent.com/dynamic/*
  9. // @grant GM_log
  10. // @require http://code.jquery.com/jquery-2.1.4.min.js
  11. // ==/UserScript==
  12.  
  13. // Marks radio buttons.
  14. $(".label.nal").click();
  15. $("input[value='notadult']").click(); // Marks Non-Adult.
  16.  
  17. // Checks to see if we are on the HIT:
  18. // If you looked at and liked the image above, which of the images below would you be more interested to see?
  19. if ($("div:contains(You are browsing the web for Images. If you looked at and liked the image above, which of the images below would you be more interested to see?)").length){
  20. $(":radio:even").click();
  21. }
  22.  
  23. // Checks to see if we are on the HIT:
  24. // Choose between two pictures of a given person
  25. if ($("div:contains(Which of the 2 images would you prefer to represent the given person? You can use the name to search for more context on the person if necessary.)").length){
  26. $(":radio:even").click();
  27. }
  28.  
  29. // Checks to see if we are on Label images based on their relevance for the query.
  30. if ($("b:contains(Unrelated/Only Indirectly Related)").length){
  31. ProductRnR_Relevance_Query();
  32. }
  33.  
  34. function ProductRnR_Relevance_Query(){
  35. $(":radio").on('change',function(){
  36. $(this).next(":contains(Related)").parent().parent().css("opacity", "1").css({ backgroundColor: "lightgreen", opacity: "1"});
  37. $(this).next(":contains(Unrelated/Indirectly Related)").parent().parent().css("opacity", "1").css({ backgroundColor: "red", opacity: "1"});
  38. $(this).next(":contains(Image didn't load)").parent().parent().css({ backgroundColor: "", opacity: "0.1"});
  39. });
  40. $("input[value='QueryImage_Unrelated']").prop("checked", true).change();
  41. $(".documentbox").click(function(e){e.preventDefault();});
  42. $('.documentbox').contextmenu( function() {
  43. return false;
  44. });
  45. $(".documentbox").mousedown(function(e){
  46. switch (e.which) {
  47. case 1:
  48. if($(this).find("input:radio:checked").next(":contains(Related):not(:contains('Unrelated'))").length > 0){
  49. $(this).find("input[value='QueryImage_Unrelated']").prop("checked", true).change();return false;
  50. }
  51. if($(this).find("input:radio:checked").next(":contains(Image didn't load)").length > 0){
  52. $(this).find("input[value='QueryImage_Related']").prop("checked", true).change();return false;
  53. }
  54. if($(this).find("input:radio:checked").next(":contains(Unrelated/Indirectly Related)").length > 0){
  55. $(this).find("input[value='QueryImage_Related']").prop("checked", true).change();return false;
  56. }
  57. break;
  58. case 3:
  59. $(this).find("input[value='NoLoad']").prop("checked", true).change();return false;
  60. break;
  61. }
  62. });
  63. $("img").error(function(){
  64. $(this).parents(".documentbox").find("input[value='NoLoad']").prop("checked", true).change();
  65. });
  66. }
  67.  
  68. // Checks to see if we are on mark excellent HITs.
  69. if ($("b:contains(excellent)").length){
  70. ProductRnR_Excellent();
  71. }
  72.  
  73. function ProductRnR_Excellent(){
  74. $(":radio").on('change',function(){
  75. $(this).next(":contains(Excellent)").parent().parent().css("opacity", "1").css({ backgroundColor: "lightgreen", opacity: "1"});
  76. $(this).next(":contains(Not Excellent)").parent().parent().css("opacity", "1").css({ backgroundColor: "red", opacity: "1"});
  77. $(this).next(":contains(Image didn't load)").parent().parent().css({ backgroundColor: "", opacity: "0.1"});
  78. });
  79. $("input[value='Excellent']").prop("checked", true).change();
  80. $(".documentbox").click(function(e){e.preventDefault();});
  81. $('.documentbox').contextmenu( function() {
  82. return false;
  83. });
  84. $(".documentbox").mousedown(function(e){
  85. switch (e.which) {
  86. case 1:
  87. if($(this).find("input:radio:checked").next(":contains(Excellent):not(:contains('Not'))").length > 0){
  88. $(this).find("input[value='Bad']").prop("checked", true).change();return false;
  89. }
  90. if($(this).find("input:radio:checked").next(":contains(Image didn't load)").length > 0){
  91. $(this).find("input[value='Excellent']").prop("checked", true).change();return false;
  92. }
  93. if($(this).find("input:radio:checked").next(":contains(Not Excellent)").length > 0){
  94. $(this).find("input[value='Excellent']").prop("checked", true).change();return false;
  95. }
  96. break;
  97. case 3:
  98. $(this).find("input[value='NoLoad']").prop("checked", true).change();return false;
  99. break;
  100. }
  101. });
  102. $("img").error(function(){
  103. $(this).parents(".documentbox").find("input[value='NoLoad']").prop("checked", true).change();
  104. });
  105. }
  106.  
  107. // Enter will sunmit the HIT.
  108. window.onkeydown = function(event) {
  109. if (event.keyCode === 13) {
  110. $("button[name='SubmitButton']").click();
  111. }
  112. };