AB Links Solver

Solves AbLink images

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

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