KissAnime Auto Captcha

Auto complete KissAnime Captcha

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

  1. // ==UserScript==
  2. // @name KissAnime Auto Captcha
  3. // @namespace https://greasyfork.org/en/users/135934-elti-musa
  4. // @version 2.0
  5. // @description Auto complete KissAnime Captcha
  6. // @author AnimeBro1
  7. // @match http://kissanime.ru/Special/AreYouHuman2*
  8. // @grant GM_setValue
  9. // @grant GM_getValue
  10. // @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js
  11. // ==/UserScript==
  12.  
  13. var images = [];
  14. var words = [];
  15. var count = 0;
  16. (function() {
  17. $("body").append('<div id="CaptchaInfo" style="display:none;width:200px;height:150px;font-size:20px;position:fixed; top: 10px; left:10px; background: red; border-radius: 25px;padding:40px;"><p></p></div>');
  18. //getE();
  19. //alert(GM_listValues());
  20. if(!isBasicJson()){
  21. getBasicJson();
  22. }
  23. document.getElementsByTagName("body")[0].onload = function(){
  24. var loaders = [];
  25. var x = $("[indexValue]").toArray();
  26. for(var i =0; i < 5; i++){
  27. getBase64Image(x[i]);
  28. }
  29. console.log(images);
  30. words = getWords();
  31. Complete();
  32. };
  33. })();
  34.  
  35. function isBasicJson(){
  36. return GM_getValue("AnimeBro1",false);
  37. }
  38.  
  39. function getBasicJson(){
  40. var isFirefox = typeof InstallTrigger !== 'undefined';
  41. var isChrome = !!window.chrome && !!window.chrome.webstore;
  42. $("#CaptchaInfo").show();
  43. $("#CaptchaInfo").find("p").html("First time running, fetching some files... Page will reload.");
  44. var msg='';
  45. if(isChrome){
  46. msg = $.ajax({type: "GET", url: "https://rawgit.com/Eltion/Kissanime-Chaptcha-Auto-Complete/master/BasicJson.json", async: false}).responseText;
  47. }else if(isFirefox){
  48. msg = $.ajax({type: "GET", url: "https://rawgit.com/Eltion/Kissanime-Chaptcha-Auto-Complete/master/BasicJsonFirefox.json", async: false}).responseText;
  49. }else{
  50. alert("Not FireFox or Chrome");
  51. msg = $.ajax({type: "GET", url: "https://rawgit.com/Eltion/Kissanime-Chaptcha-Auto-Complete/master/BasicJsonFireFox.json", async: false}).responseText;
  52. }
  53. msg = JSON.parse(msg);
  54. for(var i = 0; i < msg.length; i++){
  55. GM_setValue(msg[i].n,msg[i].v);
  56. }
  57. location.reload();
  58. }
  59. function getE(){
  60. var x = GM_listValues();
  61. var b = "";
  62. for(var i =0; i < x.length; i++){
  63. b += '{"n":"'+x[i]+'","v":"'+GM_getValue(x[i])+'"},';
  64. }
  65. $('body').html("<p>"+b+"</p>");
  66. }
  67. function getBase64Image(img) {
  68. var canvas = document.createElement("canvas");
  69. canvas.width = img.naturalWidth;
  70. canvas.height = img.naturalHeight;
  71. var ctx = canvas.getContext("2d");
  72. ctx.drawImage(img, 0, 0);
  73. var dataURL = canvas.toDataURL("image/jpeg");
  74.  
  75. //dataURL = dataURL.replace(/^data:image\/(png|jpg);base64,/, "");
  76. images.push(dataURL);
  77. }
  78.  
  79. function getWords(){
  80. var words = $("#formVerify").find("span").toArray();
  81. var First = words[0].innerText;
  82. var Second = words[1].innerText;
  83. return [First, Second];
  84. }
  85.  
  86. function Learn(){
  87. $("[indexValue]").on('click', function(){
  88. count++;
  89. var x = parseInt($(this).attr("indexValue"));
  90. if(GM_getValue(words[count-1],false) !== false){
  91. var nn = GM_getValue(words[count-1])+" "+images[x];
  92. GM_setValue(words[count-1],nn);
  93. }else{
  94. var gg = images[x];
  95. GM_setValue(words[count-1],gg);
  96. }
  97. });
  98. }
  99.  
  100. function Complete() {
  101. var jj = 0;
  102. for(var j = 0; j <2; j++){
  103. var w1 = GM_getValue( words[j], false );
  104. if(w1 !== false){
  105. if(w1.includes(" ")){
  106. w1 = w1.split(" ");
  107. }else{
  108. w1 = [w1];
  109. }
  110. for(var k =0; k < w1.length; k++){
  111. for(var i = 0; i < images.length; i++){
  112. if(images[i] === w1[k]){
  113. $("[indexValue='"+i+"']").click();
  114. jj++;
  115. if(j === 0){
  116. count++;
  117. }
  118. }
  119. }
  120. }
  121. }
  122. }
  123. UpdateTest(jj);
  124. Learn();
  125. }
  126.  
  127. function UpdateTest(jj){
  128. if(jj === 0){
  129. $("#CaptchaInfo").show();
  130. $("#CaptchaInfo").find("p").html("Couldn't recognize the images. Please select them so script can learn them for next time. IMPORTANT ***Select them in order***");
  131. }else if(jj === 1){
  132. $("#CaptchaInfo").show();
  133. $("#CaptchaInfo").find("p").html("Only one of the images is recognized. Please select the other one so script can learn it for next time.");
  134. }
  135. }