Venue Quality

Hide instructions and a & s or 1 & 2 on number pad

当前为 2015-08-01 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Venue Quality
  3. // @version 0.9
  4. // @description Hide instructions and a & s or 1 & 2 on number pad
  5. // @author ikarma
  6. // @include https://www.mturk.com/mturk/*
  7. // @grant none
  8. // @namespace https://greasyfork.org/users/9054
  9. // @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js
  10.  
  11. // ==/UserScript==
  12.  
  13. if ( $("h1:contains('Why Users Get Blocked')").length ){
  14. var var1 = $(".question-content-wrapper tr:nth-child(2) td:eq(0)").text();
  15. var var2 = $(".question-content-wrapper tr:nth-child(2) td:eq(1)").text();
  16. var res = var1.split(":");
  17. var res2 = var2.split(":");
  18. var Name = $.trim(res[1].replace("Address",""));
  19. var Address = $.trim(res[2].replace("City, Region",""));
  20. var City = $.trim(res[3]);
  21. var Name2 = $.trim(res2[1].replace("Address",""));
  22. var Address2 = $.trim(res2[2].replace("City, Region",""));
  23. var City2 = $.trim(res2[3]);
  24.  
  25. }
  26.  
  27. var requesterName = $( 'tr:contains(Requester:)' ).last().children().first().next().text().trim();
  28.  
  29. // Style Sheet
  30. var sheet = document.createElement('style');
  31. sheet.innerHTML = ".highlight { font-weight: bold; background-color: yellow; font-size: 110%;}";
  32. document.body.appendChild(sheet);
  33.  
  34. /*
  35.  
  36. highlight v5
  37.  
  38. Highlights arbitrary terms.
  39.  
  40. <http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html>
  41.  
  42. MIT license.
  43.  
  44. Johann Burkard
  45. <http://johannburkard.de>
  46. <mailto:jb@eaio.com>
  47.  
  48. */
  49.  
  50. jQuery.fn.highlight = function(pat) {
  51. function innerHighlight(node, pat) {
  52. var skip = 0;
  53. if (node.nodeType == 3) {
  54. var pos = node.data.toUpperCase().indexOf(pat);
  55. pos -= (node.data.substr(0, pos).toUpperCase().length - node.data.substr(0, pos).length);
  56. if (pos >= 0) {
  57. var spannode = document.createElement('span');
  58. spannode.className = 'highlight';
  59. var middlebit = node.splitText(pos);
  60. var endbit = middlebit.splitText(pat.length);
  61. var middleclone = middlebit.cloneNode(true);
  62. spannode.appendChild(middleclone);
  63. middlebit.parentNode.replaceChild(spannode, middlebit);
  64. skip = 1;
  65. }
  66. }
  67. else if (node.nodeType == 1 && node.childNodes && !/(script|style)/i.test(node.tagName)) {
  68. for (var i = 0; i < node.childNodes.length; ++i) {
  69. i += innerHighlight(node.childNodes[i], pat);
  70. }
  71. }
  72. return skip;
  73. }
  74. return this.length && pat && pat.length ? this.each(function() {
  75. innerHighlight(this, pat.toUpperCase());
  76. }) : this;
  77. };
  78.  
  79. jQuery.fn.removeHighlight = function() {
  80. return this.find("span.highlight").each(function() {
  81. this.parentNode.firstChild.nodeName;
  82. with (this.parentNode) {
  83. replaceChild(this.firstChild, this);
  84. normalize();
  85. }
  86. }).end();
  87. };
  88. // end of plugin
  89.  
  90. // highlight matches
  91. if(Name == Name2){$('.question-content-wrapper').highlight(Name);}
  92. if(Address == Address2){$('.question-content-wrapper').highlight(Address);}
  93. if(City == City2){$('.question-content-wrapper').highlight(City);}
  94.  
  95. if ( $("h1:contains('Is this Event family friendly')").length ){
  96. $('.question-content-wrapper').highlight("child");
  97. $('.question-content-wrapper').highlight("kid");
  98. $('.question-content-wrapper').highlight("family");
  99. }
  100.  
  101. // hide instructions, listen for keypress
  102. if ( requesterName == 'Venue Quality' ) {
  103. $(".overview-wrapper").hide();
  104. $(".overview-wrapper").click(function() {
  105. $(".overview-wrapper").toggle();
  106. });
  107. $(".question-content-wrapper").click(function() {
  108. $(".overview-wrapper").toggle();
  109. });
  110.  
  111. var $j = jQuery.noConflict(true);
  112.  
  113. document.addEventListener( "keydown", kas, false);
  114. }
  115.  
  116. function kas(i) {
  117. if ( i.keyCode == 65 || i.keyCode == 97 ) { //A or npad 1
  118. $j('input[name="Answer_1"]').eq(0).click();
  119. $j('input[name="/submit"]').eq(0).click();
  120. }
  121. if ( i.keyCode == 83 || i.keyCode == 98 ) { //S or npad 2
  122. $j('input[name="Answer_1"]').eq(1).click();
  123. $j('input[name="/submit"]').eq(0).click();
  124. }
  125.  
  126. }