AB Links Solver

Solves AbLink images

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

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址