AB Links Solver

Solves AbLink images

当前为 2025-01-06 提交的版本,查看 最新版本

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