Captcha Counter

Counts the number of hits remaining before you get a captcha

目前為 2014-05-16 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Captcha Counter
  3. // @version 0.4
  4. // @match https://www.mturk.com/mturk/*
  5. // @copyright 2014+, Tjololo
  6. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js
  7. // @namespace https://greasyfork.org/users/710
  8. // @description Counts the number of hits remaining before you get a captcha
  9. // ==/UserScript==
  10.  
  11. var hitId = "";
  12. if (document.getElementsByName("hitId")[0])
  13. hitId = document.getElementsByName("hitId")[0].value;
  14. var captchanum = 35;
  15. if (GM_getValue("captcha_number")){
  16. captchanum = GM_getValue("captcha_number");
  17. }
  18. var count = 0;
  19. if (GM_getValue("captcha_counter")){
  20. count = GM_getValue("captcha_counter");
  21. console.log("Count: "+count);
  22. }
  23.  
  24.  
  25. if (!this.GM_getValue || (this.GM_getValue.toString && this.GM_getValue.toString().indexOf("not supported")>-1)) {
  26. this.GM_getValue=function (key,def) {
  27. return localStorage[key] || def;
  28. };
  29. this.GM_setValue=function (key,value) {
  30. return localStorage[key]=value;
  31. };
  32. }
  33.  
  34. if(window.location.href.indexOf("accept") > -1) {
  35. if ($('input[name="userCaptchaResponse"]').length > 0) {
  36. count = 0;
  37. GM_setValue("captcha_counter",count);
  38. console.log("Captcha found: "+count);
  39. }
  40. else{
  41. if (hitId != "" && $('div[class="message error"]').length == 0){
  42. console.log("Accepted Hit");
  43. count+=1;
  44. GM_setValue("captcha_counter",count);
  45. console.log((captchanum-count)+" hits left until captcha!");
  46. if (count == captchanum)
  47. alert("Next hit is a captcha!");
  48. //alert((captchanum-count)+" hits left until captcha!");
  49. }
  50. else{
  51. console.log("No hit accepted");
  52. }
  53. }
  54. }
  55. else{
  56. if ($('input[name="userCaptchaResponse"]').length > 0) {
  57. count = 0;
  58. GM_setValue("captcha_counter",count);
  59. console.log("Captcha found: "+count);
  60. }
  61. }
  62.  
  63. if (captchanum-count == 1)
  64. captchaCountStr = (captchanum-count)+" hit left until captcha!";
  65. else if (captchanum-count == 0)
  66. captchaCountStr = "Last hit before captcha!";
  67. else
  68. captchaCountStr = (captchanum-count)+" hits left until captcha!";
  69.  
  70. var row = document.createElement("tr");
  71. var cell = document.createElement("td");
  72. var table = $('#theTime').parents('table')[0];
  73. cell.className = "title_orange_text";
  74. cell.setAttribute("align","left");
  75. cell.setAttribute("valign","top");
  76. cell.setAttribute("nowrap","");
  77. cell.style.paddingTop = "3px";
  78. cell.style.paddingLeft = "5px";
  79. cell.addEventListener("click", function clickCell(e) {
  80. var num_str=prompt("How many hits do you accept before you get a captcha? Note: This includes returns","35");
  81. var num = parseint(num_str);
  82. if (num){
  83. GM_setValue("captcha_number",num);
  84. alert("Captcha number saved as "+num);
  85. }
  86. });
  87. cell.innerHTML="<b>Captcha:</b> <span>"+captchaCountStr+"</span>";
  88. row.appendChild(cell);
  89. table.appendChild(row);