AB Links Solver

Solves AbLink images

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

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