ProductRnR

Makes all of the ProductRnR HITs easier/faster.

当前为 2016-02-13 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name ProductRnR
  3. // @namespace https://greasyfork.org/users/11580
  4. // @version 1.9.1
  5. // @description Makes all of the ProductRnR HITs easier/faster.
  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. $("input[value='notadult']").click(); // Marks Non-Adult.
  15.  
  16. // Checks to see if we are on the HIT:
  17. // If you were to select a caption for this image, which one would you prefer?
  18. if ($("h1:contains(If you were to select a caption for this image, which one would you prefer?)").length){
  19. var Index = 0;
  20.  
  21. $("div.documentbox").eq(Index).css({backgroundColor:"lightblue"});
  22. $("html, body").animate({
  23. scrollTop: $("div.documentbox").eq(Index).offset().top
  24. }, 0);
  25.  
  26. $(window).keydown(function(e){
  27. if (e.keyCode == 49 || e.keyCode == 97){ //1 or Numpad 1
  28. $(":radio:even").eq(Index).click();
  29. $("div.documentbox").css({backgroundColor:""});
  30. Index ++;
  31. $("div.documentbox").eq(Index).css({backgroundColor:"lightblue"});
  32. $("html, body").animate({
  33. scrollTop: $("div.documentbox").eq(Index).offset().top - $("div.documentbox").outerHeight()
  34. }, 0);
  35. }
  36. if (e.keyCode == 50 || e.keyCode == 98 ){ //2 or Numpad 2
  37. $(":radio:odd").eq(Index).click();
  38. $("div.documentbox").css({backgroundColor:""});
  39. Index ++;
  40. $("div.documentbox").eq(Index).css({backgroundColor:"lightblue"});
  41. $("html, body").animate({
  42. scrollTop: $("div.documentbox").eq(Index).offset().top - $("div.documentbox").outerHeight()
  43. }, 0);
  44. }
  45. if (e.keyCode == 51 || e.keyCode == 99){ //3 or Numpad 3
  46. $("div.documentbox").css({backgroundColor:""});
  47. Index --;
  48. $("div.documentbox").eq(Index).css({backgroundColor:"lightblue"});
  49. $("html, body").animate({
  50. scrollTop: $("div.documentbox").eq(Index).offset().top - $("div.documentbox").outerHeight()
  51. }, 0);
  52.  
  53. }
  54. if (e.keyCode === 13){
  55. $("button[name='SubmitButton']").click();
  56. }
  57. });
  58. }
  59.  
  60. // Checks to see if we are on the HIT:
  61. // Identify pages where you can purchase a product (updated HIT & guidelines)
  62. if ($("th:contains(Identify pages where you can purchase a product)").length){
  63. $("input[value='ShoppingPage_ProductAvailable']").click();
  64. }
  65.  
  66. // Checks to see if we are on the HIT:
  67. // Determine whether the provided value of product attribute matches the corresponding value on the page
  68. if ($("th:contains(Determine whether the provided value of product attribute matches the corresponding value on the page.)").length){
  69. $("input[value='Correct']").click();
  70. }
  71.  
  72. // Checks to see if we are on the HIT:
  73. // Identify these images as School appropriate. (WARNING: This HIT may contain adult content. Worker discretion is advised.)
  74. if ($("input[value='AdultImageV2_OkToShow']").length){
  75. $("input[value='AdultImageV2_OkToShow']").click();
  76. }
  77.  
  78. // Checks to see if we are on the HIT:
  79. // Determine whether or not the given image is an image of the product being sold on the provided page
  80. if ($("h1:contains(Determine whether or not the given image is an image of the product being sold on the provided page.)").length){
  81. //alert("hi");
  82. $("input[value='ShoppingImage_MatchesProduct']").prop("checked", true);
  83. }
  84.  
  85. // Checks to see if we are on the HIT:
  86. // If you looked at and liked the image above, which of the images below would you be more interested to see?
  87. 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){
  88. $(":radio:even").click();
  89. }
  90.  
  91. // Checks to see if we are on the HIT:
  92. // Choose between two pictures of a given person
  93. 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){
  94. $(":radio:even").click();
  95. }
  96.  
  97. // Checks to see if we are on the HIT:
  98. // Checks to see if we are on Label images based on their relevance for the query.
  99. if ($("b:contains(Unrelated/Only Indirectly Related)").length){
  100. ProductRnR_Relevance_Query();
  101. }
  102.  
  103. function ProductRnR_Relevance_Query(){
  104. $(":radio").on('change',function(){
  105. $(this).next(":contains(Related)").parent().parent().css("opacity", "1").css({ backgroundColor: "lightgreen", opacity: "1"});
  106. $(this).next(":contains(Unrelated/Indirectly Related)").parent().parent().css("opacity", "1").css({ backgroundColor: "red", opacity: "1"});
  107. $(this).next(":contains(Image didn't load)").parent().parent().css({ backgroundColor: "", opacity: "0.1"});
  108. });
  109. $("input[value='QueryImage_Unrelated']").prop("checked", true).change();
  110. $(".documentbox").click(function(e){e.preventDefault();});
  111. $('.documentbox').contextmenu( function() {
  112. return false;
  113. });
  114. $(".documentbox").mousedown(function(e){
  115. switch (e.which) {
  116. case 1:
  117. if($(this).find("input:radio:checked").next(":contains(Related):not(:contains('Unrelated'))").length > 0){
  118. $(this).find("input[value='QueryImage_Unrelated']").prop("checked", true).change();return false;
  119. }
  120. if($(this).find("input:radio:checked").next(":contains(Image didn't load)").length > 0){
  121. $(this).find("input[value='QueryImage_Related']").prop("checked", true).change();return false;
  122. }
  123. if($(this).find("input:radio:checked").next(":contains(Unrelated/Indirectly Related)").length > 0){
  124. $(this).find("input[value='QueryImage_Related']").prop("checked", true).change();return false;
  125. }
  126. break;
  127. case 3:
  128. $(this).find("input[value='NoLoad']").prop("checked", true).change();return false;
  129. break;
  130. }
  131. });
  132. $("img").error(function(){
  133. $(this).parents(".documentbox").find("input[value='NoLoad']").prop("checked", true).change();
  134. });
  135. }
  136.  
  137. // Checks to see if we are on the HIT:
  138. // Checks to see if we are on mark excellent HITs.
  139. if ($("b:contains(excellent)").length){
  140. ProductRnR_Excellent();
  141. }
  142.  
  143. function ProductRnR_Excellent(){
  144. $(":radio").on('change',function(){
  145. $(this).next(":contains(Excellent)").parent().parent().css("opacity", "1").css({ backgroundColor: "lightgreen", opacity: "1"});
  146. $(this).next(":contains(Not Excellent)").parent().parent().css("opacity", "1").css({ backgroundColor: "red", opacity: "1"});
  147. $(this).next(":contains(Image didn't load)").parent().parent().css({ backgroundColor: "", opacity: "0.1"});
  148. });
  149. $("input[value='Excellent']").prop("checked", true).change();
  150. $(".documentbox").click(function(e){e.preventDefault();});
  151. $('.documentbox').contextmenu( function() {
  152. return false;
  153. });
  154. $(".documentbox").mousedown(function(e){
  155. switch (e.which) {
  156. case 1:
  157. if($(this).find("input:radio:checked").next(":contains(Excellent):not(:contains('Not'))").length > 0){
  158. $(this).find("input[value='Bad']").prop("checked", true).change();return false;
  159. }
  160. if($(this).find("input:radio:checked").next(":contains(Image didn't load)").length > 0){
  161. $(this).find("input[value='Excellent']").prop("checked", true).change();return false;
  162. }
  163. if($(this).find("input:radio:checked").next(":contains(Not Excellent)").length > 0){
  164. $(this).find("input[value='Excellent']").prop("checked", true).change();return false;
  165. }
  166. break;
  167. case 3:
  168. $(this).find("input[value='NoLoad']").prop("checked", true).change();return false;
  169. break;
  170. }
  171. });
  172. $("img").error(function(){
  173. $(this).parents(".documentbox").find("input[value='NoLoad']").prop("checked", true).change();
  174. });
  175. }
  176.  
  177. // Enter will sunmit the HIT.
  178. window.onkeydown = function(event) {
  179. if (event.keyCode === 13) {
  180. $("button[name='SubmitButton']").click();
  181. }
  182. };