Maksyme / Unlimited Cryptocurrencies (FarazFaucets.xyz) - Bypass Antibot links

// ==UserScript==
// @name            Unlimited Cryptocurrencies (FarazFaucets.xyz) - Bypass Antibot links
// @name:fr         Cryptomonnaies illimitées (FarazFaucets.xyz) - Contourner les liens Antibot
// @namespace       http://tampermonkey.net/
// @version         1.4
// @description     Earn unlimited free cryptocurrencies on FarazFaucets.xyz using this script - Bypass Antibot links.
// @description:fr  Gagner gratuitement et sans limite de la cryptomonnaie sur FarazFaucets.xyz en utilisant ce script - Contourner les liens Antibot.
// @author          Maksyme
// @copyright       2021, Maksyme
// @license         MIT
// @match           https://farazrabbani.xyz/*
// @require         https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js
// @grant           GM_xmlhttpRequest
// ==/UserScript==

// ======================================================================================================================
// | Before using this script, follow instructions:                                                                     |
// | https://github.com/m4ksyme/faraz-faucets                                                                           |
// | You need to install the hCaptcha Solver in order to solve it automatically.                                        |
// | If you have not installed already, please install the script before proceeding further. Link below:                |
// | https://greasyfork.org/en/scripts/425854-hcaptcha-solver                                                           |
// | Credits: ngageub (https://greasyfork.org/en/users/767752-engageub).                                                |
// | Register to FaucetPay: https://faucetpay.io/?r=949628                                                              |
// | Note: You can use an Adblocker.                                                                                    |
// ======================================================================================================================

// ======================================================================================================================
// THIS SCRIPT REQUIRED A LOCALHOST SERVER AVAIBLE BELOW:                                                               |
// https://github.com/m4ksyme/faraz-faucets                                                                             |
// ======================================================================================================================

(function() {
    'use strict';

    // Enter Your FaucetPay Faucet Address below as mentioned in the example and save the entered text in a file.
    // Example: var dogecoin = "D6tJGhJvCPhiGiyj8eJ8gFoPUiUoDSc6VR";

    // ETHEREUM:
    // Generate wallet on https://vanity-eth.tk/
    // Link address on FaucetPay: https://faucetpay.io/page/user-admin/linked-addresses ; Instructions:
    // - Paste address in "Address" input
    // - Select "Ethereum (ETH)" in "Coin" list selection
    // - Click on "Link" button.
    // Paste linked address below:
    var ethereum = "0x13bef644d72ffa01b12d9e2d3b553ae5700fb5f4";
    var bitcoincash = "bitcoincash:qqpcpwvgfesqwz92uzk3arn0dm2sxupcys5twxsq2j";
    var dogecoin = "D6tJGhJvCPhiGiyj8eJ8gFoPUiUoDSc6VR";
    var litecoin = "MJzKGT4QsGNs3YTmBdTiN7wkoVBT4oP27J";
    var digibyte = "DHcXQzN5aCrcQYdHwcPayN6CzYArzQJMZA";
    var dash = "XhjDQvF7N3a6BJ5AGqqAVbsATLJMv1b1nq";
    var tron = "THbsbujrz9JBm7a25PBsihUGz7us6vDx9e";
    var binance = "0x0094e65Efb35ecdb0f76470893930a4847Ff8178";
    var zcash = "t1Pqd6zsaYi5kxcJspk8zMYP5WhtdhRvy8n";

    // Support me! Please, do not remove reflinks :) I earn 25% referral commission.
    var data = [
        {url : "https://farazrabbani.xyz/faucetpay/doge/?r=D6tJGhJvCPhiGiyj8eJ8gFoPUiUoDSc6VR", coin : "doge", address : dogecoin},
        {url : "https://farazrabbani.xyz/faucetpay/litecoin/?r=MJzKGT4QsGNs3YTmBdTiN7wkoVBT4oP27J", coin : "litecoin", address : litecoin},
        {url : "https://farazrabbani.xyz/faucetpay/tron/?r=THbsbujrz9JBm7a25PBsihUGz7us6vDx9e", coin : "tron", address : tron},
        {url : "https://farazrabbani.xyz/faucetpay/binance/?r=0x0094e65Efb35ecdb0f76470893930a4847Ff8178", coin : "binance", address : binance},
        {url : "https://farazrabbani.xyz/faucetpay/ethereum/?r=0x13bef644d72ffa01b12d9e2d3b553ae5700fb5f4", coin : "ethereum", address : ethereum},
        {url : "https://farazrabbani.xyz/faucetpay/zcash/?r=t1Pqd6zsaYi5kxcJspk8zMYP5WhtdhRvy8n", coin : "zcash", address : zcash},
        {url : "https://farazrabbani.xyz/faucetpay/digibyte/?r=DHcXQzN5aCrcQYdHwcPayN6CzYArzQJMZA", coin : "digibyte", address : digibyte},
        {url : "https://farazrabbani.xyz/faucetpay/dash/?r=XhjDQvF7N3a6BJ5AGqqAVbsATLJMv1b1nq", coin : "dash", address : dash},
        {url : "https://farazrabbani.xyz/faucetpay/bitcoincash/?r=bitcoincash:qqpcpwvgfesqwz92uzk3arn0dm2sxupcys5twxsq2j", coin : "bitcoincash", address : bitcoincash}
    ];

    var address = "";
    var URL = "";
    var count = 0;

    for (let value of Object.values(data)) {
        count = count + 1;

        if (!data[count].url.includes("?r=")) {
            window.location.href = "https://www.google.com/";
            window.alert("URLs has been edited! Do not remove reflinks!");
        }

        if (window.location.href.includes("https://farazrabbani.xyz/faucetpay/" + value.coin + "/")) {
            address = value.address;
            URL = value.url;
            break;
        }
    }

    // Select images in order.
    function clickImages(listClicks) {
        var listOrder = [topleft, topright, bottomleft, bottomright];
        var listOrderString = ['top-left', 'top-right', 'bottom-left', 'bottom-right'];

        // TO DO: optimize lines below.
        listClicks = listClicks.replaceAll("[", "");
        listClicks = listClicks.replaceAll("]", "");
        listClicks = listClicks.replaceAll("'", "");
        listClicks = listClicks.replaceAll(" ", "");
        listClicks = listClicks.split(",");

        var listFinal = [];
        for (let i = 0; i < 4; i++) {
            for (let y = 0; y < 4; y++) {
                if (listOrderString[y] == listClicks[i]) {
                    listOrder[y].click();
                }
            }
        }
        // Click on claim button.
        setTimeout(function() {
            document.getElementsByClassName("modal-body")[0].children.item(4).getElementsByClassName("animated-button")[0].click();
        }, 2000);
    }

    // Send images to localhost Python server.
    var clickOrder = "";
    function sendImages(listImages) {
        GM_xmlhttpRequest( {
            method: "POST",
            url: "http://192.168.1.24/farazfaucets/getData.php", // Edit this line with your local IP address.
            data: "listImages=" + listImages,
            headers: {
                "Content-Type": "application/x-www-form-urlencoded"
            },
            onload: function(response) {
                //window.alert(response.responseText); // Show result from Python.
                clickOrder = response.responseText;
                isReceived = true;
            },
        });
    }

    // If captcha and antibot link failed or success.
    setInterval(function() {
        if ((document.querySelector("body").innerHTML.includes("correct order"))
            || (document.querySelector("body").innerHTML.includes("sent to your"))) {
            window.location.href = URL;
            isClicked = true;
        }
    }, 1000);

    // Get images links.
    var original = document.getElementsByClassName("img-fluid mx-auto")[0].src;
    var top = document.getElementsByClassName("modal-body")[0].children.item(0);
    var bottom = document.getElementsByClassName("modal-body")[0].children.item(3);
    var topleft = top.querySelector(".mr-auto.float-left.ml-4 a img");
    var topright = top.querySelector(".ml-auto.float-right.mr-4 a img");
    var bottomleft = bottom.querySelector(".mr-auto.float-left.ml-4 a img");
    var bottomright = bottom.querySelector(".ml-auto.float-right.mr-4 a img");
    var listImages = [original, topleft.src, topright.src, bottomleft.src, bottomright.src];

    // Set address to input.
    setTimeout(function() {
        document.querySelector("input[class=field__input]").value = address;
        sendImages(listImages);
    }, 500);

    // Click on first button.
    setTimeout(function() {
        document.getElementsByClassName("form")[0].children.item(5).getElementsByClassName("animated-button")[0].click();
    }, 2000);

    // Reload if any error.
    setTimeout(function() {
        window.location.href = URL;
    }, 60000); // = 1 minute.

    // Send images when hCaptcha is solved.
    var isClicked = false;
    var isReceived = false;
    setInterval(function() {
        if (document.querySelector(".h-captcha > iframe").getAttribute("data-hcaptcha-response").length > 0) {
            if ((isClicked == false) && (isReceived == true)) {
                isClicked = true;
                isReceived = false;
                clickImages(clickOrder);
            }
        }
    }, 1000);

})();