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.8
  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. // ==/UserScript==
  11.  
  12. var requesterName = $( 'tr:contains(Requester:)' ).last().children().first().next().text().trim();
  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. var requesterName = $( 'tr:contains(Requester:)' ).last().children().first().next().text().trim();
  27.  
  28.  
  29. if ( requesterName == 'Venue Quality' ) {
  30. // document.getElementsByClassName('overview-wrapper')[0].style.display='none';
  31. $(".overview-wrapper").hide();
  32. $(".overview-wrapper").click(function() {
  33. $(".overview-wrapper").toggle();
  34. });
  35. $(".question-content-wrapper").click(function() {
  36. $(".overview-wrapper").toggle();
  37. });
  38.  
  39. var $j = jQuery.noConflict(true);
  40.  
  41. document.addEventListener( "keydown", kas, false);
  42. }
  43.  
  44. function kas(i) {
  45. if ( i.keyCode == 65 || i.keyCode == 97 ) { //A or npad 1
  46. $j('input[name="Answer_1"]').eq(0).click();
  47. $j('input[name="/submit"]').eq(0).click();
  48. }
  49. if ( i.keyCode == 83 || i.keyCode == 98 ) { //S or npad 2
  50. $j('input[name="Answer_1"]').eq(1).click();
  51. $j('input[name="/submit"]').eq(0).click();
  52. }
  53.  
  54. }
  55. // Style Sheet
  56. var sheet = document.createElement('style')
  57. sheet.innerHTML = ".highlight { font-weight: bold; background-color: yellow; font-size: 110%;}";
  58. document.body.appendChild(sheet);
  59.  
  60. /*
  61.  
  62. highlight v5
  63.  
  64. Highlights arbitrary terms.
  65.  
  66. <http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html>
  67.  
  68. MIT license.
  69.  
  70. Johann Burkard
  71. <http://johannburkard.de>
  72. <mailto:jb@eaio.com>
  73.  
  74. */
  75.  
  76. jQuery.fn.highlight = function(pat) {
  77. function innerHighlight(node, pat) {
  78. var skip = 0;
  79. if (node.nodeType == 3) {
  80. var pos = node.data.toUpperCase().indexOf(pat);
  81. pos -= (node.data.substr(0, pos).toUpperCase().length - node.data.substr(0, pos).length);
  82. if (pos >= 0) {
  83. var spannode = document.createElement('span');
  84. spannode.className = 'highlight';
  85. var middlebit = node.splitText(pos);
  86. var endbit = middlebit.splitText(pat.length);
  87. var middleclone = middlebit.cloneNode(true);
  88. spannode.appendChild(middleclone);
  89. middlebit.parentNode.replaceChild(spannode, middlebit);
  90. skip = 1;
  91. }
  92. }
  93. else if (node.nodeType == 1 && node.childNodes && !/(script|style)/i.test(node.tagName)) {
  94. for (var i = 0; i < node.childNodes.length; ++i) {
  95. i += innerHighlight(node.childNodes[i], pat);
  96. }
  97. }
  98. return skip;
  99. }
  100. return this.length && pat && pat.length ? this.each(function() {
  101. innerHighlight(this, pat.toUpperCase());
  102. }) : this;
  103. };
  104.  
  105. jQuery.fn.removeHighlight = function() {
  106. return this.find("span.highlight").each(function() {
  107. this.parentNode.firstChild.nodeName;
  108. with (this.parentNode) {
  109. replaceChild(this.firstChild, this);
  110. normalize();
  111. }
  112. }).end();
  113. };
  114. // end of plugin
  115.  
  116. if(Name == Name2){$('body').highlight(Name);}
  117. if(Address == Address2){$('body').highlight(Address);}
  118. if(City == City2){$('body').highlight(City);}
  119.  
  120.  
  121.  
  122.