SEDAR Solver

Automatically solves the Captcha when you want to open a document

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

  1. // ==UserScript==
  2. // @name SEDAR Solver
  3. // @description Automatically solves the Captcha when you want to open a document
  4. // @namespace sedar
  5. // @include http://sedar.com/GetFile.do*
  6. // @include http://sedar.com/CheckCode.do*
  7. // @grant none
  8. // @version 1
  9. // ==/UserScript==
  10.  
  11. (function() {
  12.  
  13.  
  14. var image_timeout = 2000;
  15.  
  16. var solver = {
  17. "-1118695147" : "X",
  18. "-1156514050" : "K",
  19. "-1247154381" : "p",
  20. "-1316012178" : "B",
  21. "-1331678675" : "V",
  22. "-1483385094" : "U",
  23. "-154654324" : "S",
  24. "-1562298880" : "j",
  25. "-1562803413" : "Y",
  26. "-158457411" : "R",
  27. "-1638235653" : "P",
  28. "-170924901" : "D",
  29. "-1777523844" : "T",
  30. "-1917443890" : "u",
  31. "-1920195139" : "f",
  32. "-2003596324" : "c",
  33. "-2009400673" : "F",
  34. "-2067662048" : "J",
  35. "-2135061970" : "e",
  36. "-243244218" : "E",
  37. "-295515571" : "Z",
  38. "-29733915" : "Q",
  39. "-32272650" : "m",
  40. "-562668947" : "i",
  41. "-688611654" : "w",
  42. "-775762530" : "a",
  43. "-849441892" : "4",
  44. "-908128173" : "W",
  45. "-95295977" : "3",
  46. "-997779436" : "6",
  47. "1037015718" : "H",
  48. "1118165053" : "n",
  49. "1191042624" : "t",
  50. "1193354277" : "2",
  51. "12565210" : "C",
  52. "1274053572" : "r",
  53. "1479626033" : "8",
  54. "1586340532" : "g",
  55. "1607319639" : "9",
  56. "1607376555" : "x",
  57. "1628919237" : "5",
  58. "1715436632" : "z",
  59. "1785588234" : "s",
  60. "1836207174" : "k",
  61. "289883241" : "L",
  62. "38744379" : "h",
  63. "394797401" : "A",
  64. "517211170" : "G",
  65. "5186883" : "b",
  66. "562912450" : "M",
  67. "624234679" : "y",
  68. "73967475" : "7",
  69. "856644020" : "N",
  70. "956352863" : "v",
  71. "98577720" : "d",
  72. "993706722" : "q"
  73. };
  74.  
  75. String.prototype.replaceAt=function(index, character) {
  76. return this.substr(0, index) + character + this.substr(index+character.length);
  77. }
  78.  
  79. function hashCode(arr){
  80. var hash = 0;
  81. if (arr.length == 0) return hash;
  82. for (var i = 0; i < arr.length; i++) {
  83. hash = ((hash<<5)-hash)+arr[i];
  84. hash = hash & hash;
  85. }
  86. return hash;
  87. }
  88.  
  89. function hashData(data) {
  90. return ""+hashCode(data.data);
  91. }
  92.  
  93.  
  94. function solveSingleChar(img, index) {
  95. var loaded = false;
  96. var onload = function() {
  97. if(loaded) return;
  98. loaded = true;
  99. var c = document.createElement("canvas");
  100. c.setAttribute("width", 300);
  101. c.setAttribute("height", 60);
  102. c.setAttribute("style", "position:absolute;top:40px;left:15px");
  103. var ctx = c.getContext("2d");
  104. ctx.drawImage(img,0,0);
  105. var data = ctx.getImageData(0,0,30,30);
  106. var hash = hashData(data);
  107. if(hash in solver) {
  108. var v = document.querySelector("input[type=text]").value;
  109. v = v.replaceAt(index, solver[hash]);
  110. document.querySelector("input[type=text]").value = v;
  111. if(v.indexOf("-") == -1) {
  112. document.querySelector("input[type=submit]").click();
  113. }
  114. }
  115. };
  116. img.addEventListener("load",onload);
  117. window.setTimeout(function() {
  118. if(!loaded) {
  119. onload();
  120. }
  121. }, image_timeout);
  122. }
  123.  
  124. function solve() {
  125. var solution = document.querySelector("input[type=text]").value = "-----";
  126.  
  127. var imgs = document.querySelectorAll("form img");
  128. solveSingleChar(imgs[0], 0);
  129. solveSingleChar(imgs[1], 1);
  130. solveSingleChar(imgs[2], 2);
  131. solveSingleChar(imgs[3], 3);
  132. solveSingleChar(imgs[4], 4);
  133. }
  134.  
  135.  
  136. solve();
  137.  
  138.  
  139. })();