AB Links Solver

Solves AbLink images

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

  1. // ==UserScript==
  2. // @name AB Links Solver
  3. // @namespace ABLinks Solver(Solves Ablinks images)
  4. // @version 3.1
  5. // @description Solves AbLink images
  6. // @author engageub
  7. // @match https://tronpayz.com/faucet
  8. // @match https://freeltc.fun/faucet/currency/*
  9. // @match https://eftacrypto.com/claim/tron/
  10. // @match https://earncryptowrs.in/faucet/*
  11. // @match https://claimcoin.in/faucet
  12. // @match https://whoopyrewards.com/faucet
  13. // @match https://ourcoincash.xyz/faucet
  14. // @match https://claimclicks.com/*
  15. // @match https://linksfly.link/faucet/currency/*
  16. // @match https://gamerlee.com/faucet/currency/*
  17. // @match https://coinarns.com/faucet
  18. // @match https://mamineearn.online/faucet
  19. // @exclude *://btcbunch.com/*
  20. // @noframes
  21. // @connect https://unpkg.com
  22. // @require https://unpkg.com/opencv.js@1.2.1/opencv.js
  23. // @require https://unpkg.com/jimp@0.5.2/browser/lib/jimp.min.js
  24. // @require https://unpkg.com/tesseract.js@2.1.5/dist/tesseract.min.js
  25. // @grant GM_xmlhttpRequest
  26. // @antifeature referral-link
  27. // ==/UserScript==
  28.  
  29. // This script solves Ablink images with words and having 3 or 4 different options
  30. // Number identification logic for comparing words and numbers will be implemented in the next versions
  31. // Accuracy can be improved by adding more filters for different types of images and fonts
  32. // This script does not have a global matcher, you will need to add the websites in the matcher section manually, till
  33. // all the solutions are implemented
  34. // Your account will be locked for 24 hours, if 3 incorrect solutions are provided consecutively in 10 minutes. (This is the default but depends on website)
  35. // To avoid this add a rotator to change the website whenever an incorrect solution is provided.
  36.  
  37. // TODO: Refactor Code
  38. (function() {
  39. 'use strict';
  40.  
  41. var questions = [];
  42. var questionImages = [];
  43. var questionImage = "";
  44. var questionImageSource = "";
  45. var numericWordArray = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"];
  46.  
  47. // Crea un cuadro de consola personalizado
  48. var consoleBox = document.createElement('div');
  49. consoleBox.id = 'myConsole'; // Agrega el ID aquí
  50. consoleBox.style.position = 'fixed';
  51. consoleBox.style.bottom = '0';
  52. consoleBox.style.width = '100%';
  53. consoleBox.style.height = '200px';
  54. consoleBox.style.backgroundColor = 'black';
  55. consoleBox.style.overflowY = 'scroll';
  56. consoleBox.style.border = '1px solid black';
  57. consoleBox.style.padding = '10px';
  58. consoleBox.style.textAlign = 'center'; // Alinea el texto a la izquierda
  59. consoleBox.style.color = 'white'; // Establece el color del texto
  60. document.body.appendChild(consoleBox);
  61.  
  62. // Crea una nueva función para imprimir mensajes en la consola personalizada
  63. function myLog(message) {
  64. var p = document.createElement('p');
  65. p.style.wordWrap = 'break-word';
  66. p.textContent = message;
  67. consoleBox.appendChild(p);
  68. // Auto scroll to the bottom
  69. consoleBox.scrollTop = consoleBox.scrollHeight;
  70. }
  71.  
  72. async function waitForImage(imgElement) {
  73. return await new Promise(res => {
  74. if (imgElement.complete) {
  75. return res();
  76. }
  77. imgElement.onload = () => res();
  78. imgElement.onerror = () => res();
  79. });
  80. }
  81.  
  82. async function toDataURL(c){
  83. return await new Promise(function(resolve){
  84. const dataURI = c.toDataURL('image/png');
  85. return resolve(dataURI);
  86. })
  87.  
  88. }
  89.  
  90. async function removeNoiseUsingImageData(imgdata,width,height,threshold){
  91. return await new Promise(function(resolve){
  92. var noiseCount =0;
  93. var noiseRowStart = 0;
  94. for (let column = 0; column < width; column++) {
  95. let count = 0;
  96. for (let row = 0; row < height; row++) {
  97.  
  98. let position = row * width + column;
  99. let pixelAtPosition = imgdata[position];
  100.  
  101. //Remove noise from first row and last row
  102. if(row == 0 || row == height-1){
  103. imgdata[position] = 0xFFFFFFFF;
  104. }
  105.  
  106. if (pixelAtPosition == 0xFF000000){
  107. if(noiseCount == 0){
  108. noiseRowStart = row;
  109. }
  110. noiseCount++;
  111. }else{
  112. //Define the number of consecutive pixels to be considered as noise
  113. if(noiseCount > 0 && noiseCount <= threshold){
  114. //Start from noiseRow till current row and remove noise
  115. while(noiseRowStart < row){
  116. let noisePosition = noiseRowStart * width + column;
  117. imgdata[noisePosition] = 0xFFFFFFFF;
  118. noiseRowStart++;
  119. }
  120. }
  121. noiseCount =0;
  122. }
  123. }
  124. }
  125. return resolve(imgdata);
  126. })
  127.  
  128. }
  129.  
  130. async function imageUsingOCRAntibotQuestion(image) {
  131.  
  132. if (!image || !image.src) {
  133. myLog("No images found");
  134. return;
  135. }
  136.  
  137. var img = new Image();
  138. img.crossOrigin = 'anonymous';
  139. img.src = image.src
  140. await waitForImage(img);
  141. var c = document.createElement("canvas")
  142. c.width = img.width;
  143. c.height = img.height;
  144. var ctx = c.getContext("2d");
  145. await ctx.drawImage(img, 0, 0);
  146.  
  147. var imageData = await ctx.getImageData(0, 0, c.width, c.height);
  148. var data = await imageData.data;
  149. // myLog(data);
  150.  
  151. await ctx.putImageData(imageData, 0, 0);
  152.  
  153. let src = await cv.imread(c);
  154. let dst = new cv.Mat();
  155. let ksize = new cv.Size(3, 3);
  156. // You can try more different parameters
  157. await cv.GaussianBlur(src, dst, ksize, 0, 0, cv.BORDER_DEFAULT);
  158.  
  159. await cv.imshow(c, dst);
  160. src.delete();
  161. dst.delete();
  162.  
  163. //myLog( c.toDataURL());
  164. let imageDataURI = await toDataURL(c);
  165. return await (imageUsingOCR(imageDataURI));
  166. }
  167.  
  168. async function imageUsingOCRAntibotLowValues(image) {
  169.  
  170. if (!image || !image.src) {
  171. myLog("No images found");
  172. return;
  173. }
  174.  
  175. var img = new Image();
  176. img.crossOrigin = 'anonymous';
  177. img.src = image.src;
  178. await waitForImage(img);
  179.  
  180. var c = document.createElement("canvas")
  181. c.width = img.width;
  182. c.height = img.height;
  183. var ctx = c.getContext("2d");
  184. await ctx.drawImage(img, 0, 0);
  185. //myLog(await c.toDataURL());
  186. var imageData = await ctx.getImageData(0, 0, c.width, c.height);
  187. var data = await imageData.data;
  188.  
  189. //Make the image visible
  190. for (let i = 0; i < data.length; i += 4) {
  191.  
  192. if ((data[i] < 100 || data[i + 1] < 100 || data[i + 2] < 100) && data[i+3]>0) {
  193. data[i] = 0;
  194. data[i + 1] = 0;
  195. data[i + 2] = 0;
  196. } else {
  197. data[i] = 255;
  198. data[i + 1] = 255;
  199. data[i + 2] = 255;
  200. }
  201. data[i + 3] = 255;
  202. }
  203.  
  204. //Remove Noise from Image
  205. var imgdata = await new Uint32Array(data.buffer);
  206.  
  207. imgdata = await removeNoiseUsingImageData(imgdata,c.width,c.height,1);
  208.  
  209. await ctx.putImageData(imageData, 0, 0);
  210.  
  211. //myLog( c.toDataURL());
  212. let imageDataURI = await toDataURL(c);
  213. return await (imageUsingOCR(imageDataURI));
  214. }
  215.  
  216. async function imageUsingOCRAntibotHighValues(image) {
  217.  
  218. if (!image || !image.src) {
  219. myLog("No images found");
  220. return;
  221. }
  222.  
  223. var img = new Image();
  224. img.crossOrigin = 'anonymous';
  225. img.src = image.src;
  226. await waitForImage(img);
  227.  
  228. var c = document.createElement("canvas")
  229. c.width = img.width;
  230. c.height = img.height;
  231. var ctx = c.getContext("2d");
  232. await ctx.drawImage(img, 0, 0);
  233. //myLog(await c.toDataURL());
  234. var imageData = await ctx.getImageData(0, 0, c.width, c.height);
  235. var data = await imageData.data;
  236.  
  237. //Make the image visible
  238. for (let i = 0; i < data.length; i += 4) {
  239.  
  240. if ((data[i] > 100 || data[i + 1] > 100 || data[i + 2] > 100) && data[i + 3] > 0) {
  241. data[i] = 0;
  242. data[i + 1] = 0;
  243. data[i + 2] = 0;
  244.  
  245. } else {
  246.  
  247. data[i] = 255;
  248. data[i + 1] = 255;
  249. data[i + 2] = 255;
  250. }
  251. data[i + 3] = 255;
  252. }
  253.  
  254. //Remove Noise from Image
  255. var imgdata = await new Uint32Array(data.buffer);
  256.  
  257. imgdata = await removeNoiseUsingImageData(imgdata,c.width,c.height,1);
  258.  
  259.  
  260. await ctx.putImageData(imageData, 0, 0);
  261. //myLog( c.toDataURL());
  262. let imageDataURI = await toDataURL(c);
  263. return await (imageUsingOCR(imageDataURI));
  264. }
  265.  
  266. async function splitImageUsingOCRAntibotLowValues(questionImageSource, answerImagesLength) {
  267.  
  268. var img = new Image();
  269. img.crossOrigin = 'anonymous';
  270. img.src = questionImageSource;
  271. await waitForImage(img);
  272.  
  273. var c = document.createElement("canvas")
  274. c.width = img.width;
  275. c.height = img.height;
  276. var ctx = c.getContext("2d");
  277. await ctx.drawImage(img, 0, 0);
  278. //myLog(await c.toDataURL());
  279. var imageData = await ctx.getImageData(0, 0, c.width, c.height);
  280. var data = await imageData.data;
  281.  
  282. //Make the image visible
  283. for (let i = 0; i < data.length; i += 4) {
  284. if ((data[i] < 100 || data[i + 1] < 100 || data[i + 2] < 100) && data[i+3]>0) {
  285. data[i] = 0;
  286. data[i + 1] = 0;
  287. data[i + 2] = 0;
  288.  
  289. } else {
  290. data[i] = 255;
  291. data[i + 1] = 255;
  292. data[i + 2] = 255;
  293.  
  294. }
  295. data[i + 3] = 255;
  296. }
  297.  
  298. await ctx.putImageData(imageData, 0, 0);
  299. //myLog(c.toDataURL());
  300. let imageDataURI = await toDataURL(c);
  301.  
  302. if(answerImagesLength == 3){
  303. return await splitImageByThree(imageDataURI);
  304. }
  305.  
  306. return await (splitImage(imageDataURI));
  307.  
  308. }
  309.  
  310. async function splitImageUsingDefaultValues(questionImageSource, answerImagesLength) {
  311.  
  312. var img = new Image();
  313. img.crossOrigin = 'anonymous';
  314. img.src = questionImageSource;
  315. await waitForImage(img);
  316.  
  317. var c = document.createElement("canvas")
  318. c.width = img.width;
  319. c.height = img.height;
  320. var ctx = c.getContext("2d");
  321. await ctx.drawImage(img, 0, 0);
  322. //myLog(await c.toDataURL());
  323. var imageData = await ctx.getImageData(0, 0, c.width, c.height);
  324. var data = await imageData.data;
  325.  
  326. //Make the image visible
  327. for (let i = 0; i < data.length; i += 4) {
  328. if (data[i] > 0 && data[i + 1] > 0 && data[i + 2] > 100 && data[i+3]>0) {
  329. data[i] = 0;
  330. data[i + 1] = 0;
  331. data[i + 2] = 0;
  332.  
  333. } else {
  334. data[i] = 255;
  335. data[i + 1] = 255;
  336. data[i + 2] = 255;
  337.  
  338. }
  339. data[i + 3] = 255;
  340. }
  341.  
  342. var imgdata = await new Uint32Array(data.buffer);
  343.  
  344. //Remove Noise from Image
  345. imgdata = await removeNoiseUsingImageData(imgdata,c.width,c.height,1);
  346.  
  347. await ctx.putImageData(imageData, 0, 0);
  348. //myLog(c.toDataURL());
  349. let imageDataURI = await toDataURL(c);
  350. if(answerImagesLength == 3){
  351. return await splitImageByThree(imageDataURI);
  352. }
  353.  
  354. return await splitImage(imageDataURI);
  355.  
  356. }
  357.  
  358.  
  359. async function splitImageUsingOCRAntibotHighValues(questionImageSource, answerImagesLength) {
  360.  
  361. var img = new Image();
  362. img.crossOrigin = 'anonymous';
  363. img.src = questionImageSource;
  364. await waitForImage(img);
  365.  
  366. var c = document.createElement("canvas")
  367. c.width = img.width;
  368. c.height = img.height;
  369. var ctx = c.getContext("2d");
  370. await ctx.drawImage(img, 0, 0);
  371.  
  372. //myLog(await c.toDataURL());
  373.  
  374.  
  375. var imageData = await ctx.getImageData(0, 0, c.width, c.height);
  376. var data = await imageData.data;
  377.  
  378. //Make the image visible
  379.  
  380. for (let i = 0; i < data.length; i += 4) {
  381.  
  382. if ((data[i] > 100 || data[i + 1] > 100 || data[i + 2] > 100) && data[i + 3] > 0) {
  383. data[i] = 0;
  384. data[i + 1] = 0;
  385. data[i + 2] = 0;
  386.  
  387. } else {
  388.  
  389. data[i] = 255;
  390. data[i + 1] = 255;
  391. data[i + 2] = 255;
  392. }
  393. data[i + 3] = 255;
  394. }
  395.  
  396. var imgdata = await new Uint32Array(data.buffer);
  397.  
  398. //Remove Noise from Image
  399. imgdata = await removeNoiseUsingImageData(imgdata,c.width,c.height,1);
  400.  
  401.  
  402. await ctx.putImageData(imageData, 0, 0);
  403.  
  404. let imageDataURI = await toDataURL(c);
  405.  
  406. if(answerImagesLength == 3){
  407. return await splitImageByThree(imageDataURI);
  408. }
  409.  
  410. return await splitImage(imageDataURI);
  411.  
  412. }
  413.  
  414. async function splitImage(imgSource) {
  415.  
  416. var img = new Image();
  417. img.crossOrigin = 'anonymous';
  418. img.src = imgSource
  419. await waitForImage(img);
  420. var c = document.createElement("canvas")
  421. c.width = img.width;
  422. c.height = img.height;
  423. var ctx = c.getContext("2d");
  424. await ctx.drawImage(img, 0, 0);
  425.  
  426. var imageData = await ctx.getImageData(0, 0, c.width, c.height);
  427. var data = await imageData.data;
  428. var imgdata = await new Uint32Array(data.buffer);
  429.  
  430. //Scan from left to right
  431. //Get the weight of white spaces
  432. //Ignore first white space and last white space
  433. var sequenceLength = 0;
  434. var prevColumn = 0;
  435. var hashMap = new Map();
  436. var first = 0;
  437. var second = 0;
  438. var third = 0;
  439. var firstMaxColumn = 0;
  440. var secondMaxColumn = 0;
  441. var thirdMaxColumn = 0;
  442.  
  443. //Remove Noise from Image
  444. imgdata = await removeNoiseUsingImageData(imgdata,c.width,c.height,1);
  445.  
  446. //await ctx.putImageData(imageData, 0, 0);
  447.  
  448. //myLog(await c.toDataURL());
  449.  
  450.  
  451. for (let column = Math.floor(0.1 * c.width); column < c.width; column++) {
  452. var count = 0;
  453. for (let row = 0; row < c.height; row++) {
  454.  
  455. var position = row * c.width + column;
  456. var pixelAtPosition = imgdata[position];
  457. if (pixelAtPosition == 0xFFFFFFFF) {
  458. count++;
  459. }
  460.  
  461. }
  462.  
  463. //Get the blank spaces based on weight of the column
  464. if (count > Math.floor(0.88 * c.height) && column != 0) {
  465. if (column - prevColumn == 1) {
  466. sequenceLength = sequenceLength + 1;
  467. }
  468. } else {
  469.  
  470. if ((column - sequenceLength != 1) && (column != 0 || sequenceLength != 0 || column != c.width - 1)) {
  471. // If current element is
  472. // greater than first
  473. if (sequenceLength > first) {
  474. third = second;
  475. thirdMaxColumn = secondMaxColumn;
  476. second = first;
  477. secondMaxColumn = firstMaxColumn;
  478. first = sequenceLength;
  479. firstMaxColumn = column - 1;
  480. } else if (sequenceLength > second) {
  481. third = second;
  482. thirdMaxColumn = secondMaxColumn;
  483. second = sequenceLength;
  484. secondMaxColumn = column - 1;
  485. } else if (sequenceLength > third) {
  486. third = sequenceLength;
  487. thirdMaxColumn = column - 1;
  488. }
  489. }
  490.  
  491. sequenceLength = 0;
  492. }
  493.  
  494. prevColumn = column;
  495.  
  496. }
  497.  
  498. firstMaxColumn = firstMaxColumn - Math.floor(first / 2)
  499. secondMaxColumn = secondMaxColumn - Math.floor(second / 2)
  500. thirdMaxColumn = thirdMaxColumn - Math.floor(third / 2)
  501.  
  502. var columnArray = [firstMaxColumn, secondMaxColumn, thirdMaxColumn];
  503. columnArray = await columnArray.sort(function(a, b) {
  504. return a - b;
  505. });
  506.  
  507.  
  508. await ctx.putImageData(imageData, 0, 0);
  509.  
  510.  
  511. let url = await questionImage.src.replace(/^data:image\/\w+;base64,/, "");
  512. let buffer = await new Buffer(url, 'base64');
  513. //Check if overlaps are detected and split the images
  514. var len = [];
  515. len[0] = columnArray[0] - 0;
  516. len[1] = columnArray[1] - columnArray[0];
  517. len[2] = columnArray[2] - columnArray[1];
  518. len[3] = c.width - columnArray[2];
  519.  
  520. for (let i = 0; i < len.length; i++) {
  521. if (len[i] < Math.floor(0.1 * c.width)) {
  522. myLog("Overlap detected");
  523. return;
  524. break;
  525. }
  526. }
  527.  
  528. await new Promise((resolve, reject) => {
  529.  
  530. Jimp.read(buffer).then(async function(data) {
  531. await data.crop(0, 0, columnArray[0], questionImage.height)
  532. .getBase64(Jimp.AUTO, async function(err, src) {
  533. let img = new Image();
  534. img.crossOrigin = 'anonymous';
  535. img.src = src
  536. await waitForImage(img);
  537. questionImages[0] = img;
  538. resolve();
  539. })
  540. });
  541. });
  542.  
  543. await new Promise((resolve, reject) => {
  544. Jimp.read(buffer).then(async function(data) {
  545. await data.crop(columnArray[0], 0, columnArray[1] - columnArray[0], questionImage.height)
  546. .getBase64(Jimp.AUTO, async function(err, src) {
  547. var img = new Image();
  548. img.crossOrigin = 'anonymous';
  549. img.src = src
  550. await waitForImage(img);
  551. questionImages[1] = img;
  552. resolve();
  553.  
  554. })
  555. });
  556. });
  557.  
  558. await new Promise((resolve, reject) => {
  559. Jimp.read(buffer).then(async function(data) {
  560. await data.crop(columnArray[1], 0, columnArray[2] - columnArray[1], questionImage.height)
  561. .getBase64(Jimp.AUTO, async function(err, src) {
  562. var img = new Image();
  563. img.crossOrigin = 'anonymous';
  564. img.src = src
  565. await waitForImage(img);
  566. questionImages[2] = img;
  567. resolve();
  568.  
  569. })
  570. });
  571. });
  572.  
  573. await new Promise((resolve, reject) => {
  574. Jimp.read(buffer).then(async function(data) {
  575. await data.crop(columnArray[2], 0, c.width - columnArray[2], questionImage.height)
  576. .getBase64(Jimp.AUTO, async function(err, src) {
  577. var img = new Image();
  578. img.crossOrigin = 'anonymous';
  579. img.src = src
  580. await waitForImage(img);
  581. questionImages[3] = img;
  582. resolve();
  583. })
  584. });
  585. });
  586. }
  587.  
  588.  
  589. async function splitImageByThree(imgSource) {
  590.  
  591. var img = new Image();
  592. img.crossOrigin = 'anonymous';
  593. img.src = imgSource
  594. await waitForImage(img);
  595. var c = document.createElement("canvas")
  596. c.width = img.width;
  597. c.height = img.height;
  598. var ctx = c.getContext("2d");
  599. await ctx.drawImage(img, 0, 0);
  600.  
  601. var imageData = await ctx.getImageData(0, 0, c.width, c.height);
  602. var data = await imageData.data;
  603. var imgdata = await new Uint32Array(data.buffer);
  604.  
  605. //Scan from left to right
  606. //Get the weight of white spaces
  607. //Ignore first white space and last white space
  608. var sequenceLength = 0;
  609. var prevColumn = 0;
  610. var hashMap = new Map();
  611. var first = 0;
  612. var second = 0;
  613. var third = 0;
  614. var firstMaxColumn = 0;
  615. var secondMaxColumn = 0;
  616. var thirdMaxColumn = 0;
  617.  
  618. //Remove Noise from Image
  619. imgdata = await removeNoiseUsingImageData(imgdata,c.width,c.height,1);
  620.  
  621. //await ctx.putImageData(imageData, 0, 0);
  622.  
  623. //myLog(await c.toDataURL());
  624.  
  625.  
  626. for (let column = Math.floor(0.1 * c.width); column < c.width; column++) {
  627. var count = 0;
  628. for (let row = 0; row < c.height; row++) {
  629.  
  630. var position = row * c.width + column;
  631. var pixelAtPosition = imgdata[position];
  632. if (pixelAtPosition == 0xFFFFFFFF) {
  633. count++;
  634. }
  635.  
  636. }
  637.  
  638. //Get the blank spaces based on weight of the column
  639. if (count > Math.floor(0.88 * c.height) && column != 0) {
  640. if (column - prevColumn == 1) {
  641. sequenceLength = sequenceLength + 1;
  642. }
  643. } else {
  644.  
  645. if ((column - sequenceLength != 1) && (column != 0 || sequenceLength != 0 || column != c.width - 1)) {
  646. // If current element is
  647. // greater than first
  648. if (sequenceLength > first) {
  649. second = first;
  650. secondMaxColumn = firstMaxColumn;
  651. first = sequenceLength;
  652. firstMaxColumn = column - 1;
  653. } else if (sequenceLength > second) {
  654. second = sequenceLength;
  655. secondMaxColumn = column - 1;
  656. }
  657. }
  658.  
  659. sequenceLength = 0;
  660. }
  661.  
  662. prevColumn = column;
  663.  
  664. }
  665.  
  666. firstMaxColumn = firstMaxColumn - Math.floor(first / 2)
  667. secondMaxColumn = secondMaxColumn - Math.floor(second / 2)
  668.  
  669. var columnArray = [firstMaxColumn, secondMaxColumn];
  670. columnArray = await columnArray.sort(function(a, b) {
  671. return a - b;
  672. });
  673.  
  674.  
  675. await ctx.putImageData(imageData, 0, 0);
  676.  
  677.  
  678. let url = await questionImage.src.replace(/^data:image\/\w+;base64,/, "");
  679. let buffer = await new Buffer(url, 'base64');
  680. //Check if overlaps are detected and split the images
  681. var len = [];
  682. len[0] = columnArray[0] - 0;
  683. len[1] = columnArray[1] - columnArray[0];
  684. len[2] = c.width - columnArray[1];
  685.  
  686. for (let i = 0; i < len.length; i++) {
  687. if (len[i] < Math.floor(0.1 * c.width)) {
  688. myLog("Overlap detected");
  689. return;
  690. break;
  691. }
  692. }
  693.  
  694. await new Promise((resolve, reject) => {
  695.  
  696. Jimp.read(buffer).then(async function(data) {
  697. await data.crop(0, 0, columnArray[0], questionImage.height)
  698. .getBase64(Jimp.AUTO, async function(err, src) {
  699. let img = new Image();
  700. img.crossOrigin = 'anonymous';
  701. img.src = src
  702. await waitForImage(img);
  703. questionImages[0] = img;
  704. resolve();
  705. })
  706. });
  707. });
  708.  
  709. await new Promise((resolve, reject) => {
  710. Jimp.read(buffer).then(async function(data) {
  711. await data.crop(columnArray[0], 0, columnArray[1] - columnArray[0], questionImage.height)
  712. .getBase64(Jimp.AUTO, async function(err, src) {
  713. var img = new Image();
  714. img.crossOrigin = 'anonymous';
  715. img.src = src
  716. await waitForImage(img);
  717. questionImages[1] = img;
  718. resolve();
  719.  
  720. })
  721. });
  722. });
  723.  
  724. await new Promise((resolve, reject) => {
  725. Jimp.read(buffer).then(async function(data) {
  726. await data.crop(columnArray[1], 0, c.width - columnArray[1], questionImage.height)
  727. .getBase64(Jimp.AUTO, async function(err, src) {
  728. var img = new Image();
  729. img.crossOrigin = 'anonymous';
  730. img.src = src
  731. await waitForImage(img);
  732. questionImages[2] = img;
  733. resolve();
  734. })
  735. });
  736. });
  737. }
  738.  
  739.  
  740. async function imageUsingOCRAntibotQuestion1(image) {
  741.  
  742. if (!image || !image.src) {
  743. myLog("No images found");
  744. return;
  745. }
  746.  
  747. var img = new Image();
  748. img.crossOrigin = 'anonymous';
  749. img.src = image.src
  750. await waitForImage(img);
  751. var c = document.createElement("canvas")
  752. c.width = image.width;
  753. c.height = image.height;
  754. var ctx = c.getContext("2d");
  755. // ctx.filter = 'grayscale(1)';
  756. await ctx.drawImage(img, 0, 0);
  757.  
  758. var imageData = await ctx.getImageData(0, 0, c.width, c.height);
  759. var data = await imageData.data;
  760. // myLog(data);
  761.  
  762. await ctx.putImageData(imageData, 0, 0);
  763.  
  764.  
  765. let src = await cv.imread(c);
  766.  
  767. let dst = new cv.Mat();
  768. await cv.medianBlur(src, dst, 3)
  769.  
  770. await cv.imshow(c, dst);
  771.  
  772. src.delete();
  773. dst.delete();
  774.  
  775. //myLog( c.toDataURL());
  776. let imageDataURI = await toDataURL(c);
  777.  
  778. return await (imageUsingOCR(imageDataURI));
  779. }
  780.  
  781.  
  782.  
  783. async function imageUsingOCRAntibot1(image) {
  784. var img1 = image;
  785.  
  786. var img = new Image();
  787. img.crossOrigin = 'anonymous';
  788. img.src = img1.src
  789. await waitForImage(img);
  790.  
  791. var c = document.createElement("canvas")
  792. c.width = img1.width;
  793. c.height = img1.height;
  794. var ctx = c.getContext("2d");
  795.  
  796. await ctx.drawImage(img, 0, 0);
  797.  
  798.  
  799. var imageData = await ctx.getImageData(0, 0, c.width, c.height);
  800. var data = await imageData.data;
  801.  
  802.  
  803. var hashMap = new Map();
  804.  
  805. for (let i = 0; i < data.length; i += 4) {
  806.  
  807. var rgba = data[i] + ',' + data[i + 1] + ',' + data[i + 2] + ',' + data[i + 3];
  808.  
  809. if (hashMap.has(rgba)) {
  810. hashMap.set(rgba, hashMap.get(rgba) + 1)
  811. } else {
  812. hashMap.set(rgba, 1)
  813. }
  814.  
  815. }
  816.  
  817. var data_tmp = [];
  818. var data_tmp_edges = [];
  819.  
  820. for (let i = 0; i < data.length; i += 4) {
  821.  
  822. if (data[i + 3] > 130 && data[i] < 100 && data[i + 1] < 100 && data[i + 2] < 100) {
  823. data[i] = 0;
  824. data[i + 1] = 0;
  825. data[i + 2] = 0;
  826. data[i + 3] = 255;
  827. data_tmp_edges[i] = 1;
  828. data_tmp_edges[i + 1] = 1;
  829. data_tmp_edges[i + 2] = 1;
  830.  
  831. } else {
  832. data[i] = 255;
  833. data[i + 1] = 255;
  834. data[i + 2] = 255;
  835. data[i + 3] = 255;
  836.  
  837. }
  838. }
  839.  
  840. await ctx.putImageData(imageData, 0, 0);
  841.  
  842. let imageDataURI = await toDataURL(c);
  843.  
  844. return await (imageUsingOCR(imageDataURI));
  845.  
  846. }
  847.  
  848.  
  849. async function imageUsingOCRAntibotFiltered(image) {
  850.  
  851. var img = new Image();
  852. img.crossOrigin = 'anonymous';
  853. img.src = image.src
  854. await waitForImage(img);
  855.  
  856. let mat = cv.imread(img);
  857.  
  858. var c = document.createElement("canvas")
  859. c.width = image.width;
  860. c.height = image.height;
  861. var ctx = c.getContext("2d");
  862. await ctx.drawImage(img, 0, 0);
  863. var imageData = await ctx.getImageData(0, 0, c.width, c.height);
  864. var data = await imageData.data;
  865. // myLog(data);
  866.  
  867. for (let i = 0; i < data.length; i += 4) {
  868. if (data[i + 3] > 130 && data[i] < 100) {
  869. data[i] = 255;
  870. data[i + 1] = 255;
  871. data[i + 2] = 255;
  872. data[i + 3] = 255;
  873. } else {
  874. data[i] = 0;
  875. data[i + 1] = 0;
  876. data[i + 2] = 0;
  877. data[i + 3] = 255;
  878. }
  879.  
  880. }
  881.  
  882.  
  883. await ctx.putImageData(imageData, 0, 0);
  884.  
  885.  
  886. let src = await cv.imread(c);
  887.  
  888. let dst = new cv.Mat();
  889.  
  890. let M = cv.Mat.ones(2, 1, cv.CV_8U);
  891. let anchor = new cv.Point(-1, -1);
  892.  
  893. // Opening , remove small particles from image
  894. await cv.morphologyEx(src, dst, cv.MORPH_OPEN, M, anchor, 1,
  895. cv.BORDER_CONSTANT, cv.morphologyDefaultBorderValue());
  896. await cv.imshow(c, dst);
  897.  
  898. //Image erode, thinning the text
  899.  
  900. src = await cv.imread(c);
  901. M = cv.Mat.ones(2, 1, cv.CV_8U);
  902. await cv.erode(src, dst, M, anchor, 1, cv.BORDER_CONSTANT, cv.morphologyDefaultBorderValue());
  903. await cv.imshow(c, dst);
  904.  
  905. src.delete();
  906. dst.delete();
  907. M.delete();
  908.  
  909. // myLog( c.toDataURL());
  910.  
  911. let imageDataURI = await toDataURL(c);
  912. return await (imageUsingOCR(imageDataURI));
  913.  
  914. }
  915.  
  916. async function imageUsingOCRAntibotFiltered1(image) {
  917.  
  918. var img = new Image();
  919. img.crossOrigin = 'anonymous';
  920. img.src = image.src
  921. await waitForImage(img);
  922.  
  923. let mat = cv.imread(img);
  924.  
  925. var c = document.createElement("canvas")
  926. c.width = image.width;
  927. c.height = image.height;
  928. var ctx = c.getContext("2d");
  929. await ctx.drawImage(img, 0, 0);
  930. var imageData = await ctx.getImageData(0, 0, c.width, c.height);
  931. var data = await imageData.data;
  932. // myLog(data);
  933.  
  934. for (let i = 0; i < data.length; i += 4) {
  935. if (data[i + 3] > 130 && data[i] > 70) {
  936. data[i] = 255;
  937. data[i + 1] = 255;
  938. data[i + 2] = 255;
  939. data[i + 3] = 255;
  940. } else {
  941. data[i] = 0;
  942. data[i + 1] = 0;
  943. data[i + 2] = 0;
  944. data[i + 3] = 255;
  945. }
  946.  
  947. }
  948.  
  949. await ctx.putImageData(imageData, 0, 0);
  950.  
  951. let src = await cv.imread(c);
  952. let dst = new cv.Mat();
  953. let M = cv.Mat.ones(2, 1, cv.CV_8U);
  954. let anchor = new cv.Point(-1, -1);
  955.  
  956. // Opening morphology, remove noise from image
  957. await cv.morphologyEx(src, dst, cv.MORPH_OPEN, M, anchor, 1,
  958. cv.BORDER_CONSTANT, cv.morphologyDefaultBorderValue());
  959. await cv.imshow(c, dst);
  960. //myLog( c.toDataURL());
  961.  
  962. //Image erode
  963. src = await cv.imread(c);
  964. M = cv.Mat.ones(2, 1, cv.CV_8U);
  965. await cv.erode(src, dst, M, anchor, 1, cv.BORDER_CONSTANT, cv.morphologyDefaultBorderValue());
  966. await cv.imshow(c, dst);
  967. src.delete();
  968. dst.delete();
  969. M.delete();
  970.  
  971. // myLog( c.toDataURL());
  972. let imageDataURI = await toDataURL(c);
  973.  
  974. return await (imageUsingOCR(imageDataURI));
  975.  
  976. }
  977.  
  978. async function imageUsingOCRAntibot(image) {
  979.  
  980. var img = new Image();
  981. img.crossOrigin = 'anonymous';
  982. img.src = image.src
  983. await waitForImage(img);
  984. var c = document.createElement("canvas")
  985. c.width = image.width;
  986. c.height = image.height;
  987. var ctx = c.getContext("2d");
  988. // ctx.filter = 'grayscale(1)';
  989. await ctx.drawImage(img, 0, 0);
  990.  
  991. var imageData = await ctx.getImageData(0, 0, c.width, c.height);
  992. var data = await imageData.data;
  993.  
  994. var hashMap = new Map();
  995.  
  996. for (let i = 0; i < data.length; i += 4) {
  997.  
  998. var rgba = data[i] + ',' + data[i + 1] + ',' + data[i + 2] + ',' + data[i + 3];
  999.  
  1000. if (hashMap.has(rgba)) {
  1001. hashMap.set(rgba, hashMap.get(rgba) + 1)
  1002. } else {
  1003. hashMap.set(rgba, 1)
  1004. }
  1005.  
  1006. }
  1007.  
  1008. var maxCount = 0;
  1009. var objectKey = "0,0,0,0";
  1010. await hashMap.forEach((value, key) => {
  1011. if (maxCount < value && key != "0,0,0,0") {
  1012. objectKey = key;
  1013. maxCount = value;
  1014. }
  1015.  
  1016. });
  1017.  
  1018. var alphaValues = objectKey.split(",");
  1019. var alpha = Number(alphaValues[alphaValues.length - 1]);
  1020.  
  1021. var data_tmp = [];
  1022. var data_tmp_edges = [];
  1023.  
  1024. for (let i = 0; i < data.length; i += 4) {
  1025.  
  1026. if (data[i + 3] == alpha) {
  1027. data[i] = 255;
  1028. data[i + 1] = 255;
  1029. data[i + 2] = 255;
  1030. data[i + 3] = 255;
  1031. //Giving some value for representation
  1032. data_tmp[i] = 1;
  1033. data_tmp[i + 1] = 1;
  1034. data_tmp[i + 2] = 1;
  1035.  
  1036.  
  1037. } else if (data[i + 3] > 0) {
  1038. data[i] = 0;
  1039. data[i + 1] = 0;
  1040. data[i + 2] = 0;
  1041. data[i + 3] = 255;
  1042. data_tmp_edges[i] = 1;
  1043. data_tmp_edges[i + 1] = 1;
  1044. data_tmp_edges[i + 2] = 1;
  1045.  
  1046. } else {
  1047. data[i] = 255;
  1048. data[i + 1] = 255;
  1049. data[i + 2] = 255;
  1050. data[i + 3] = 255;
  1051.  
  1052. }
  1053. }
  1054.  
  1055.  
  1056. //Fill if the adjacent value was present earlier
  1057. for (let k = 0; k < 20; k++) {
  1058. for (let i = 4; i < data.length; i += 4) {
  1059.  
  1060. if (data[i] == 0 && data_tmp[i - 4] == 1) {
  1061. data[i - 4] = 0;
  1062. data[i - 3] = 0;
  1063. data[i - 2] = 0;
  1064. data[i - 1] = 255;
  1065. }
  1066. }
  1067. }
  1068.  
  1069. //myLog(imageData.data);
  1070.  
  1071. await ctx.putImageData(imageData, 0, 0);
  1072.  
  1073. // myLog( c.toDataURL());
  1074. let imageDataURI = await toDataURL(c);
  1075.  
  1076. return await (imageUsingOCR(imageDataURI));
  1077.  
  1078.  
  1079. }
  1080.  
  1081. var worker = "";
  1082.  
  1083. async function imageUsingOCR(img) {
  1084. var answer = "";
  1085.  
  1086. if (!worker) {
  1087. worker = await new Tesseract.createWorker();
  1088. }
  1089.  
  1090. if(!img || img.width ==0 || img.height == 0){
  1091. myLog("OCR cannot be performed on this image");
  1092. return "";
  1093. }
  1094.  
  1095. try {
  1096.  
  1097. await worker.load();
  1098. await worker.loadLanguage('eng');
  1099. await worker.initialize('eng');
  1100. await worker.setParameters({
  1101. tessedit_pageseg_mode: '6',
  1102. preserve_interword_spaces: '1',
  1103. tessedit_char_whitelist: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,@!*+',
  1104. //tessedit_ocr_engine_mode:'1'
  1105. });
  1106.  
  1107. await worker.recognize(img, "eng").then(async function(result) {
  1108. answer = result.data.text.trim();
  1109. myLog("Captcha Answer::" + answer);
  1110. });
  1111.  
  1112. // await worker.terminate();
  1113. } catch (err) {
  1114. myLog(err.message);
  1115. await worker.terminate();
  1116.  
  1117. }
  1118.  
  1119. return answer;
  1120.  
  1121. }
  1122.  
  1123.  
  1124. // Compare similar strings
  1125. var LevenshteinDistance = function(a, b) {
  1126. if (a.length == 0) return b.length;
  1127. if (b.length == 0) return a.length;
  1128.  
  1129. var matrix = [];
  1130.  
  1131. // increment along the first column of each row
  1132. var i;
  1133. for (i = 0; i <= b.length; i++) {
  1134. matrix[i] = [i];
  1135. }
  1136.  
  1137. // increment each column in the first row
  1138. var j;
  1139. for (j = 0; j <= a.length; j++) {
  1140. matrix[0][j] = j;
  1141. }
  1142.  
  1143. // Fill in the rest of the matrix
  1144. for (i = 1; i <= b.length; i++) {
  1145. for (j = 1; j <= a.length; j++) {
  1146. if (b.charAt(i - 1) == a.charAt(j - 1)) {
  1147. matrix[i][j] = matrix[i - 1][j - 1];
  1148. } else {
  1149. matrix[i][j] = Math.min(matrix[i - 1][j - 1] + 1, // substitution
  1150. Math.min(matrix[i][j - 1] + 1, // insertion
  1151. matrix[i - 1][j] + 1)); // deletion
  1152. }
  1153. }
  1154. }
  1155.  
  1156. return matrix[b.length][a.length];
  1157. };
  1158.  
  1159.  
  1160. function countPairs(s1, s2) {
  1161. var n1 = s1.length;
  1162. var n2 = s2.length;
  1163.  
  1164. // To store the frequencies of
  1165. // characters of string s1 and s2
  1166. let freq1 = new Array(26);
  1167. let freq2 = new Array(26);
  1168. freq1.fill(0);
  1169. freq2.fill(0);
  1170.  
  1171. // To store the count of valid pairs
  1172. let i, count = 0;
  1173.  
  1174. // Update the frequencies of
  1175. // the characters of string s1
  1176. for (i = 0; i < n1; i++)
  1177. freq1[s1[i].charCodeAt() - 'a'.charCodeAt()]++;
  1178.  
  1179. // Update the frequencies of
  1180. // the characters of string s2
  1181. for (i = 0; i < n2; i++)
  1182. freq2[s2[i].charCodeAt() - 'a'.charCodeAt()]++;
  1183.  
  1184. // Find the count of valid pairs
  1185. for (i = 0; i < 26; i++)
  1186. count += (Math.min(freq1[i], freq2[i]));
  1187.  
  1188. return count;
  1189. }
  1190.  
  1191. async function getFinalOCRResultFromImage(image,leastLength){
  1192. var ocrResult = "";
  1193. var tempResult = "";
  1194. ocrResult = await imageUsingOCRAntibotLowValues(image);
  1195.  
  1196. if (ocrResult.length > leastLength || ocrResult.length > tempResult.length) {
  1197. tempResult = ocrResult.trim();
  1198. } else {
  1199. ocrResult = await imageUsingOCRAntibotHighValues(image);
  1200. }
  1201.  
  1202. if (ocrResult.length > leastLength || ocrResult.length > tempResult.length) {
  1203. tempResult = ocrResult.trim();
  1204. } else {
  1205. ocrResult = await imageUsingOCR(image);
  1206. }
  1207.  
  1208.  
  1209. if (ocrResult.length > leastLength || ocrResult.length > tempResult.length) {
  1210. tempResult = ocrResult.trim();
  1211. } else {
  1212. ocrResult = await imageUsingOCRAntibotQuestion(image);
  1213. }
  1214.  
  1215. if (ocrResult.length > leastLength || ocrResult.length > tempResult.length) {
  1216. tempResult = ocrResult.trim();
  1217. } else {
  1218. ocrResult = await imageUsingOCRAntibotQuestion1(image);
  1219. }
  1220.  
  1221.  
  1222. if (ocrResult.length > leastLength || ocrResult.length > tempResult.length) {
  1223. tempResult = ocrResult.trim()
  1224. } else {
  1225. ocrResult = await imageUsingOCRAntibot(image)
  1226. }
  1227.  
  1228.  
  1229. if (ocrResult.length > leastLength || ocrResult.length > tempResult.length) {
  1230. tempResult = ocrResult.trim()
  1231. } else {
  1232. ocrResult = await imageUsingOCRAntibot1(image);
  1233. }
  1234.  
  1235. if (ocrResult.length > leastLength || ocrResult.length > tempResult.length) {
  1236. tempResult = ocrResult.trim()
  1237. } else {
  1238. ocrResult = await imageUsingOCRAntibotFiltered(image)
  1239. }
  1240.  
  1241. if (ocrResult.length > leastLength || ocrResult.length > tempResult.length) {
  1242. tempResult = ocrResult.trim()
  1243. } else {
  1244. ocrResult = await imageUsingOCRAntibotFiltered1(image)
  1245. }
  1246.  
  1247. if (ocrResult.length > leastLength || ocrResult.length > tempResult.length) {
  1248. tempResult = ocrResult.trim()
  1249. }
  1250.  
  1251. ocrResult = tempResult;
  1252.  
  1253. return ocrResult;
  1254.  
  1255.  
  1256. }
  1257.  
  1258. //Adding referral links to faucetpay list
  1259. if (window.location.href.includes("faucetpay.io/page/faucet-list") && document.querySelectorAll(".btn.btn-primary.btn-sm").length > 0) {
  1260. for (let i = 0; i < document.querySelectorAll(".btn.btn-primary.btn-sm").length; i++) {
  1261. document.querySelectorAll(".btn.btn-primary.btn-sm")[i].href =
  1262. document.querySelectorAll(".btn.btn-primary.btn-sm")[i].href.replace(/\/$/, "") + "/?r=1HeD2a11n8d9zBTaznNWfVxtw1dKuW2vT5";
  1263. }
  1264. }
  1265.  
  1266.  
  1267. if(window.location.href.includes("gr8.cc")){
  1268. var oldFunction = unsafeWindow.open;
  1269. unsafeWindow.open= function(url){url = url.split("?r=")[0] + "?r=1HeD2a11n8d9zBTaznNWfVxtw1dKuW2vT5"; return oldFunction(url)}
  1270. for(let i=0; i< document.querySelectorAll("a").length;i++){
  1271. document.querySelectorAll("a")[i].removeAttribute("onmousedown");
  1272. document.querySelectorAll("a")[i].href= document.querySelectorAll("a")[i].href.split("?r=")[0] + "?r=1HeD2a11n8d9zBTaznNWfVxtw1dKuW2vT5";
  1273. }
  1274. }
  1275.  
  1276.  
  1277.  
  1278. setTimeout(async function() {
  1279.  
  1280. var answerSelector = "";
  1281. var questionSelector = "";
  1282. var addCount = 0;
  1283. var leastLength = 0;
  1284. var maxImages = 0;
  1285.  
  1286. function waitForCloudflareAndRetry() {
  1287. // Busca el texto que indica que Cloudflare está validando
  1288. const cloudflareIndicator = document.querySelector('#hRmtl0');
  1289. if (
  1290. cloudflareIndicator &&
  1291. (cloudflareIndicator.textContent.includes("Verifique que usted es un ser humano") ||
  1292. cloudflareIndicator.textContent.includes("Verifying you are human"))
  1293. ) {
  1294. myLog("Cloudflare validation in progress, waiting...");
  1295. setTimeout(waitForCloudflareAndRetry, 0); // Esperar 0 segundo y volver a comprobar
  1296. } else {
  1297. myLog("Ab links not detected");
  1298. location.reload();
  1299. }
  1300. }
  1301.  
  1302. if (document.querySelectorAll(".modal-content [href='/'] img").length == 4 && document.querySelectorAll(".modal-content img").length >= 5) {
  1303. questionSelector = ".modal-content img";
  1304. answerSelector = ".modal-content [href='/'] img";
  1305. } else if (document.querySelector(".modal-header img") && document.querySelectorAll(".modal-body [href='/'] img").length == 4) {
  1306. questionSelector = ".modal-header img";
  1307. answerSelector = ".modal-body [href='/'] img";
  1308. } else if (document.querySelector(".alert.alert-info img") && document.querySelectorAll(".antibotlinks [href='/'] img").length == 4) {
  1309. questionSelector = ".alert.alert-info img";
  1310. answerSelector = ".antibotlinks [href='/'] img";
  1311. } else if (document.querySelector(".alert.alert-warning img") && document.querySelectorAll(".antibotlinks [href='/'] img").length == 3) {
  1312. questionSelector = ".alert.alert-warning img";
  1313. answerSelector = ".antibotlinks [href='/'] img";
  1314. } else if (document.querySelector(".alert.alert-warning img") && document.querySelectorAll(".antibotlinks [href='#'] img").length == 3) {
  1315. questionSelector = ".alert.alert-warning img";
  1316. answerSelector = ".antibotlinks [href='#'] img";
  1317. } else if (document.querySelector(".sm\\:flex.items-center img") && document.querySelectorAll("[href='javascript:void(0)'] img").length == 3) {
  1318. questionSelector = ".sm\\:flex.items-center img";
  1319. answerSelector = "[href='javascript:void(0)'] img";
  1320. } else if (document.querySelectorAll(".modal-content [href='/'] img").length == 3 && document.querySelectorAll(".modal-content img").length >= 4) {
  1321. questionSelector = ".modal-content img";
  1322. answerSelector = ".modal-content [href='/'] img";
  1323. } else if (document.querySelector(".modal-header img") && document.querySelectorAll(".modal-body [href='/'] img").length == 3) {
  1324. questionSelector = ".modal-header img";
  1325. answerSelector = ".modal-body [href='/'] img";
  1326. } else if (document.querySelector(".alert.alert-info img") && document.querySelectorAll(".antibotlinks [href='/'] img").length == 3) {
  1327. questionSelector = ".alert.alert-info img";
  1328. answerSelector = ".antibotlinks [href='/'] img";
  1329. } else {
  1330. waitForCloudflareAndRetry();
  1331. return;
  1332. }
  1333.  
  1334. var answerImagesLength = document.querySelectorAll(answerSelector).length;
  1335.  
  1336.  
  1337. for (let i = 0; i < answerImagesLength; i++) {
  1338. if (document.querySelector(answerSelector).width <= document.querySelector(answerSelector).height) {
  1339. document.querySelector(answerSelector).value = "####"; //Using this as reference to move to next url
  1340. myLog("Numeric/Roman captcha Detected , captcha cannot be solved at the moment");
  1341. myLog("Reload the page to see if the captcha changes");
  1342. // solveNumberCaptchaByAnswer()
  1343. location.reload(); // Recargar la página automáticamente
  1344. return;
  1345. }
  1346. }
  1347.  
  1348. if (document.querySelector(questionSelector).width < (answerImagesLength+1) * document.querySelector(questionSelector).height) {
  1349. document.querySelector(answerSelector).value = "####"; //Using this as reference to move to next url
  1350. myLog("Numeric/Roman captcha Detected , captcha cannot be solved at the moment");
  1351. myLog("Reload the page to see if the captcha changes");
  1352. // solveNumberCaptchaByQuestion()
  1353. location.reload(); // Recargar la página automáticamente
  1354. return;
  1355. }
  1356.  
  1357. if (document.querySelector(questionSelector).width < 10 * document.querySelector(questionSelector).height) {
  1358. leastLength = 2;
  1359. } else {
  1360. leastLength = 3;
  1361. }
  1362.  
  1363. myLog("Solving Ab Links....");
  1364.  
  1365. if (!document.querySelector(questionSelector) || !document.querySelector(questionSelector).src) {
  1366. document.querySelector(answerSelector).value = "####"; //Using this as reference to move to next url
  1367. myLog("No image source found for question");
  1368. return
  1369. }
  1370.  
  1371. questionImage = document.querySelector(questionSelector);
  1372. questionImageSource = document.querySelector(questionSelector).src;
  1373. await waitForImage(questionImage);
  1374. var optionImages = [];
  1375.  
  1376. for (let i = 0; i < answerImagesLength; i++) {
  1377. optionImages[i] = document.querySelectorAll(answerSelector)[i + addCount];
  1378. }
  1379.  
  1380. var questionSolution = await imageUsingOCRAntibotLowValues(questionImage);
  1381. questionSolution = questionSolution.replace(/,$/, "");
  1382.  
  1383. if (!questionSolution || !questionSolution.includes(",") || questionSolution.split(",").length != answerImagesLength) {
  1384. questionSolution = await imageUsingOCRAntibotHighValues(questionImage);
  1385. questionSolution = questionSolution.replace(/,$/, "");
  1386. }
  1387.  
  1388. if (!questionSolution || !questionSolution.includes(",") || questionSolution.split(",").length != answerImagesLength) {
  1389. questionSolution = await imageUsingOCR(questionImage);
  1390. questionSolution = questionSolution.replace(/,$/, "");
  1391. }
  1392.  
  1393. if (!questionSolution || !questionSolution.includes(",") || questionSolution.split(",").length != answerImagesLength) {
  1394. questionSolution = await imageUsingOCRAntibotQuestion(questionImage);
  1395. questionSolution = questionSolution.replace(/,$/, "");
  1396. }
  1397.  
  1398.  
  1399. if (!questionSolution || !questionSolution.includes(",") || questionSolution.split(",").length != answerImagesLength) {
  1400.  
  1401. await splitImageUsingDefaultValues(questionImageSource, answerImagesLength);
  1402.  
  1403. if(questionImages.length < answerImagesLength){
  1404. questionImages = [];
  1405. await splitImageUsingOCRAntibotLowValues(questionImageSource, answerImagesLength);
  1406. }
  1407.  
  1408. if(questionImages.length < answerImagesLength){
  1409. questionImages = [];
  1410. await splitImageUsingOCRAntibotHighValues(questionImageSource, answerImagesLength);
  1411. }
  1412.  
  1413. if(questionImages.length < answerImagesLength){
  1414. document.querySelector(answerSelector).value = "####"; //Using this as reference to move to next url
  1415. myLog("Captcha cannot be solved");
  1416. return;
  1417. }
  1418.  
  1419. for (let i = 0; i < answerImagesLength; i++) {
  1420.  
  1421. questions[i] = await getFinalOCRResultFromImage(questionImages[i],leastLength);
  1422. questions[i] = questions[i].replaceAll("5", "s").replaceAll("3", "e").replaceAll(",", "")
  1423. .replaceAll("8", "b").replaceAll("1", "l").replaceAll("@", "a").replaceAll("*", "").replaceAll("9", "g")
  1424. .replaceAll("!", "i").replaceAll("0", "o").replaceAll("4", "a").replaceAll("2", "z").toLowerCase();
  1425.  
  1426. }
  1427. } else {
  1428. questionSolution = questionSolution.toLowerCase();
  1429. questionSolution = questionSolution.replaceAll("5", "s").replaceAll("3", "e")
  1430. .replaceAll("8", "b").replaceAll("1", "l").replaceAll("@", "a").replaceAll("*", "").replaceAll("9", "g")
  1431. .replaceAll("!", "i").replaceAll("0", "o").replaceAll("4", "a").replaceAll("2", "z").toLowerCase();
  1432. questions = questionSolution.split(',');
  1433. }
  1434.  
  1435. leastLength = 1000;
  1436. for (let i = 0; i < answerImagesLength; i++) {
  1437. if (questions[i].length < leastLength) {
  1438. leastLength = questions[i].length;
  1439. }
  1440. }
  1441.  
  1442. leastLength = leastLength - 1;
  1443.  
  1444. var answers = [];
  1445.  
  1446. for (let i = 0; i < answerImagesLength; i++) {
  1447. var answer = "";
  1448. answers[i] = await getFinalOCRResultFromImage(optionImages[i],leastLength);
  1449. answers[i] = answers[i].replaceAll("5", "s").replaceAll("3", "e")
  1450. .replaceAll("8", "b").replaceAll("1", "l").replaceAll("@", "a").replaceAll("9", "g")
  1451. .replaceAll("!", "i").replaceAll("0", "o").replaceAll("4", "a").replaceAll("2", "z").toLowerCase();
  1452.  
  1453. }
  1454.  
  1455. await worker.terminate();
  1456.  
  1457. if (questions.length == answerImagesLength) {
  1458.  
  1459. var map = new Map();
  1460. for (let i = 0; i < answerImagesLength; i++) {
  1461. questions[i] = questions[i].replaceAll(",", "").replaceAll(" ", "").trim();
  1462. for (let j = 0; j < answerImagesLength; j++) {
  1463. let score = "";
  1464. answers[j] = answers[j].replaceAll(",", "").replaceAll(" ", "").trim();
  1465. score = await LevenshteinDistance(questions[i], answers[j]);
  1466. map.set(questions[i] + "::" + answers[j], score);
  1467. }
  1468. }
  1469.  
  1470. map[Symbol.iterator] = function*() {
  1471. yield*[...this.entries()].sort((a, b) => a[1] - b[1]);
  1472. }
  1473.  
  1474. var tempMap = new Map();
  1475. var finalMap = new Map();
  1476. var preValue = "";
  1477. var count = 0;
  1478. for (let [key, value] of map) {
  1479. count = count + 1;
  1480. //Sort by same score
  1481. if (!preValue) {
  1482. preValue = value;
  1483. tempMap.set(key, value)
  1484. continue;
  1485. }
  1486.  
  1487. if (preValue == value) {
  1488. tempMap.set(key, value);
  1489. } else {
  1490. //The new score is different, sort all the temp values
  1491. tempMap[Symbol.iterator] = function*() {
  1492. yield*[...this.entries()].sort((a, b) => a[0] - b[0]);
  1493. }
  1494.  
  1495. finalMap = new Map([...finalMap, ...tempMap]);
  1496. tempMap = new Map();
  1497. tempMap.set(key, value)
  1498. preValue = value;
  1499. }
  1500.  
  1501. if (count == map.size) {
  1502. tempMap.set(key, value);
  1503. tempMap[Symbol.iterator] = function*() {
  1504. yield*[...this.entries()].sort((a, b) => a[0] - b[0]);
  1505. }
  1506.  
  1507. finalMap = new Map([...finalMap, ...tempMap]);
  1508. }
  1509.  
  1510. }
  1511.  
  1512. var questionAnswerMap = new Map();
  1513. var answerSet = new Set();
  1514. var prevKey = "";
  1515. map = finalMap;
  1516. for (let [key, value] of map) {
  1517. if (!prevKey) {
  1518. prevKey = key
  1519. continue;
  1520. }
  1521. //Check if scores are equal and assign the value
  1522. if (map.get(prevKey) == map.get(key) && prevKey.split("::")[0] == key.split("::")[0] && !answerSet.has(prevKey.split("::")[1]) &&
  1523. !answerSet.has(key.split("::")[1]) && !questionAnswerMap.has(prevKey.split("::")[0]) && !questionAnswerMap.has(key.split("::")[0])) {
  1524. var prevCount = countPairs(prevKey.split("::")[1], prevKey.split("::")[0]);
  1525. var currCount = countPairs(key.split("::")[1], key.split("::")[0]);
  1526.  
  1527. if (prevCount > currCount) {
  1528. key = prevKey;
  1529. } else {
  1530. prevKey = key;
  1531. }
  1532. } else {
  1533. if (!questionAnswerMap.has(prevKey.split("::")[0]) && !answerSet.has(prevKey.split("::")[1])) {
  1534. questionAnswerMap.set(prevKey.split("::")[0], prevKey.split("::")[1]);
  1535. answerSet.add(prevKey.split("::")[1]);
  1536. }
  1537. prevKey = key;
  1538. }
  1539. }
  1540.  
  1541. if (questionAnswerMap.size == answerImagesLength-1 && !questionAnswerMap.has(prevKey.split("::")[0]) && !answerSet.has(prevKey.split("::")[1])) {
  1542. questionAnswerMap.set(prevKey.split("::")[0], prevKey.split("::")[1]);
  1543. answerSet.add(prevKey.split("::")[1]);
  1544. }
  1545.  
  1546. var answersMap = new Map();
  1547.  
  1548. for (let i = 0; i < answerImagesLength; i++) {
  1549. answersMap.set(answers[i], i);
  1550. }
  1551.  
  1552. //Selecting the Answers
  1553. for (let i = 0; i < answerImagesLength; i++) {
  1554. var ans = questionAnswerMap.get(questions[i]);
  1555. let j = answersMap.get(ans);
  1556. myLog("Answer for " + questions[i] + "::" + answers[j]);
  1557. if (document.querySelectorAll(answerSelector)[j + addCount]) {
  1558. document.querySelectorAll(answerSelector)[j + addCount].click();
  1559. } else {
  1560. myLog("Answer Selector could not be identified");
  1561. }
  1562. }
  1563.  
  1564. }
  1565.  
  1566. }, 1000)
  1567.  
  1568. })();