steamfaucet / Vie Faucets Cryptorotator

// ==UserScript==
// @name         Vie Faucets Cryptorotator
// @namespace    Vie Faucets Cryptorotator
// @version      0.2
// @description  Vie Faucets Cryptorotator
// @author       steamfaucet
// @match        https://free-bonk.com/*
// @match        https://criptolia.site/*
// @match        https://banfaucet.com/*
// @match        https://cashbux.work/*
// @match        https://tronpayz.com/*
// @match        https://litefaucet.in/*
// @match        https://tartaria-faucet.net/*
// @match        https://coinarns.com/*
// @match        https://www.freebnbcoin.com/*
// @match        https://whoopyrewards.com/*
// @match        https://99faucet.com/*
// @match        https://pepy.monster/*
// @match        https://xtrabits.click/*
// @match        https://coinymate.com/*
// @match        https://bchads.io/*
// @match        https://freeltc.online/*
// @match        https://claimcrypto.in/*
// @match        https://claimcoin.in/*
// @match        https://coinluva.com/*
// @match        https://bitupdate.info/*
// @match        https://almasat.net/*
// @match        https://coinveu.com/*
// @match        https://adhunterptc.xyz/*
// @match        https://bullfaucet.in/*
// @match        https://bdfaucet.com/*
// @match        https://bitfaucet.pw/*
// @match        https://claimcash.cc/*
// @match        https://coinmb.com/*
// @match        https://cryptobigpay.online/*
// @match        https://cryptojunkie.net/*
// @match        https://earnbtc.pw/*
// @match        https://earnviv.com/*
// @match        https://faucet4u.com/*
// @match        https://faucetbazzar.com/*
// @match        https://freetron.top/*
// @match        https://hatecoin.me/*
// @match        https://nobitafc.com/*
// @match        https://wincrypt2.com/*
// @match        https://bitsfree.net/*
// @match        https://buxcoin.io/*
// @match        https://coinoto.net/*
// @match        https://crypto-farms.site/*
// @match        https://cryptomaker.in/*
// @match        https://cryptoukr.in.ua/*
// @match        https://faucetenb.com/*
// @match        https://freebinance.top/*
// @match        https://freecryptoss.com/*
// @match        https://freeshib.biz/*
// @match        https://furyfaucet.com/*
// @match        https://goldsurferfaucet.de/*
// @match        https://litecoinline.com/*
// @match        https://ptc4btc.com/*
// @match        https://coindoog.com/*
// @match        https://98faucet.com/*
// @match        https://spinfaucet.ru/*
// @match        https://liteonion.online/*
// @match        https://claimfreetrx.online/*
// @match        https://claimsatoshi.xyz/*
// @match        https://cryptoearns.com/*
// @match        https://kryptofaucet.com/*
// @match        https://fastfaucet.net/*
// @match        https://ourcoincash.xyz/*
// @noframes
// @grant       GM_addStyle
// @license MIT
// @copyright 2024, steamfaucet (https://openuserjs.org/users/steamfaucet)

// ==/UserScript==
(function() {

    'use strict';

    // Enable Next button to manually move to next website
    const ENABLE_NEXT_BUTTON = false;

    // Enable the withdrawal when you wish to withdraw
    // The automation is partial as the balances in different wallets is not known and sometimes insufficient.
    // The forms are filled. You can decide which coin to withdraw when it redirects to withdrawal page.
    // Make sure you are already logged in when enabling the following option.
    // You may enable this once a week or once a month to withdraw.
    // Make sure to disbale it after withdrawing
    const ENABLE_WITHDRAWAL = false;

    // Following email and wallet address are required to autofill form when withdrawal is enabled
    const FAUCET_PAY_EMAIL="";
    const FAUCET_PAY_BTC_WALLET_ADDRESS="";
    const CWALLET_EMAIL="";
    const CWALLET_ID="";

    // Set the following to true to enable shortlinks
    const SHORTLINKS_ENABLED = false;

    // Add or Remove Shortlinks from the list below
    // Shortlinks with pre_verify path are skipped due to multi captcha verification
    const SHORTLINKS_LIST = ["ouo","foary","cuty","cbshort","urlspay","exe","clksh","clk.pw",
                           "linkrex","mitly","tmearn","mgnet","bitspace","shrinkearn","fclc",
                           "fc.lc","droplink"];

    //  Enter your login and password below, if you like to Autologin. Be careful while providing passwords,
    //  else you may get your accounts locked
    var websiteData = [
        {url : "https://free-bonk.com/ptc", login: "", password: ""},
        {url : "https://banfaucet.com/ptc", login: "", password: ""},
        {url : "https://criptolia.site/ptc", login: "", password: ""},
        {url : "https://cashbux.work/ptc", login: "", password: ""},
        {url : "https://tronpayz.com/ptc", login: "", password: ""},
        {url : "https://litefaucet.in/ptc", login: "", password: ""},
        {url : "https://tartaria-faucet.net/ptc", login: "", password: ""},
        {url : "https://coinarns.com/ptc", login: "", password: ""},
        {url : "https://bchads.io/ptc", login: "", password: "", withdrawPath: "/dashboard"},
        {url : "https://coinluva.com/ptc", login: "", password: "", withdrawPath: "/dashboard"},
        {url : "https://whoopyrewards.com/ptc", login: "", password: "", withdrawPath: "/dashboard"},
        {url : "https://www.freebnbcoin.com/ptc", login: "", password: "", withdrawPath: "/withdrawtoken"},
        {url : "https://99faucet.com/ptc", login: "", password: ""},
        {url : "https://pepy.monster/ptc", login: "", password: ""},
        {url : "https://coinymate.com/ptc", login: "", password: ""},
        {url : "https://xtrabits.click/ptc", login: "", password: ""},
        {url : "https://freeltc.online/ptc", login: "", password: "", withdrawPath: "/dashboard"},
        {url : "https://bitupdate.info/ptc", login: "", password: "", withdrawPath: "/dashboard"},
        {url : "https://almasat.net/ptc", login: "", password: "", withdrawPath: "/dashboard"},
        {url : "https://adhunterptc.xyz/ptc", login: "", password: "", withdrawPath: "/dashboard"},
        {url : "https://bdfaucet.com/ptc", login: "", password: "", withdrawPath: "/dashboard"},
        {url : "https://claimcash.cc/ptc", login: "", password: "", withdrawPath: "/dashboard"},
        {url : "https://cryptobigpay.online/ptc", login: "", password: ""},
        {url : "https://cryptojunkie.net/ptc", login: "", password: "", withdrawPath: "/dashboard"},
        {url : "https://freetron.top/ptc", login: "", password: "", withdrawPath: "/dashboard"},
        {url : "https://hatecoin.me/ptc", login: "", password: "", withdrawPath: "/dashboard"},
        {url : "https://nobitafc.com/ptc", login: "", password: ""},
        {url : "https://wincrypt2.com/ptc", login: "", password: ""},
        {url : "https://bitsfree.net/ptc", login: "", password: ""},
        {url : "https://buxcoin.io/ptc", login: "", password: "", withdrawPath: "/dashboard"},
        {url : "https://coinoto.net/ptc", login: "", password: "", withdrawPath: "/dashboard"},
        {url : "https://cryptomaker.in/ptc", login: "", password: "", withdrawPath: "/dashboard"},
        {url : "https://cryptoukr.in.ua/ptc", login: "", password: "", withdrawPath: "/dashboard"},
        {url : "https://faucetenb.com/ptc", login: "", password: "", withdrawPath: "/dashboard"},
        {url : "https://freebinance.top/ptc", login: "", password: "", withdrawPath: "/dashboard"},
        {url : "https://freecryptoss.com/ptc", login: "", password: "", withdrawPath: "/dashboard"},
        {url : "https://freeshib.biz/ptc", login: "", password: ""},
        {url : "https://furyfaucet.com/ptc", login: "", password: "", withdrawPath: "/dashboard"},
        {url : "https://litecoinline.com/ptc", login: "", password: "", withdrawPath: "/dashboard"},
        {url : "https://ptc4btc.com/ptc", login: "", password: "", withdrawPath: "/dashboard"},
        {url : "https://coindoog.com/ptc", login: "", password: ""},
        {url : "https://98faucet.com/ptc", login: "", password: ""},
        {url : "https://spinfaucet.ru/ptc", login: "", password: "", withdrawPath: "/dashboard"},
        {url : "https://liteonion.online/ptc", login: "", password: "", withdrawPath: "/dashboard"},
        {url : "https://claimfreetrx.online/ptc", login: "", password: "", withdrawPath: "/dashboard"},
        {url : "https://claimsatoshi.xyz/ptc", login: "", password: ""},
        {url : "https://cryptoearns.com/ptc", login: "", password: ""},
        {url : "https://kryptofaucet.com/ptc", login: "", password: ""},
        {url : "https://fastfaucet.net/ptc", login: "", password: "", withdrawPath: "/dashboard"},
        {url : "https://ourcoincash.xyz/ptc", login: "", password: "", withdrawPath: "/dashboard"}
    ];

    // ============================================================================================================================================


    window.open= function(){};
    if(unsafeWindow){
        unsafeWindow.open= function(){};
    }

   // Captcha Priority List for switching between different types of captcha
    const CAPTCHA_PRIORITY_LIST = ["cloudflare","turnstile","recaptcha v2"];

    var clicked = false;

    //  Check if a string is present in Array
    String.prototype.includesOneOf = function(arrayOfStrings) {

        //  If this is not an Array, compare it as a String
        if (!Array.isArray(arrayOfStrings)) {
            return this.toLowerCase().includes(arrayOfStrings.toLowerCase());
        }

        for (var i = 0; i < arrayOfStrings.length; i++) {
            if (this.toLowerCase().includes(arrayOfStrings[i].toLowerCase())) {
                return true;
            }
        }
        return false;
    }

    var websiteMap = [
        {
            loginSelectors: ["input[type=email],input[type=text]", "input[type=password]", "button[type=submit]"],
            captchaButtonSubmitSelector: ["button[type=submit]"],
            additionalFunctions: ptcClick,
        },
    ]

    var websiteDataValues = {};

    //  Get selector details from the websiteMap
    for (let value of Object.values(websiteMap)) {
        websiteDataValues.inputTextSelector = value.inputTextSelector;
        websiteDataValues.inputTextSelectorButton = value.inputTextSelectorButton;
        websiteDataValues.defaultButtonSelectors = value.defaultButtonSelectors;
        websiteDataValues.claimButtonSelector = value.claimButtonSelector;
        websiteDataValues.captchaButtonSubmitSelector = value.captchaButtonSubmitSelector;
        websiteDataValues.loginSelectors = value.loginSelectors;
        websiteDataValues.loginCaptcha = value.loginCaptcha;
        websiteDataValues.allMessageSelectors = value.allMessageSelectors;
        websiteDataValues.messagesToCheckBeforeMovingToNextUrl = value.messagesToCheckBeforeMovingToNextUrl;
        websiteDataValues.withdrawPageUrl = value.withdrawPageUrl;
        websiteDataValues.withdrawEnabled = value.withdrawEnabled;
        websiteDataValues.balanceSelector = value.balanceSelector;
        websiteDataValues.withdrawMinAmount = value.withdrawMinAmount;
        websiteDataValues.successMessageSelectors = value.successMessageSelectors;
        websiteDataValues.additionalFunctions = value.additionalFunctions;
        websiteDataValues.timeoutbeforeMovingToNextUrl = value.timeoutbeforeMovingToNextUrl;
        break;
    }

    var login = "";
    var password = "";
    var withdrawPath = "";
    var count = 0;
    var addressAssigned = false;
    for (let value of Object.values(websiteData)){
        count = count + 1;
        if(value.url.includes(window.location.hostname) && (window.location.href.includes("/" + value.regex + "/") ||
                                                            window.location.href.includes("/" + value.regex + "-") ||
                                                            window.location.href.endsWith("/" + value.regex) ||
                                                            window.location.href.endsWith(window.location.hostname) ||
                                                            window.location.href.endsWith(window.location.hostname + "/"))){
            websiteDataValues.address = value.address;
            login = value.login;
            password = value.password;
            if(value.withdrawPath){
                withdrawPath = value.withdrawPath;
            }
            addressAssigned = true;
            break;
        }
    }

    //  If URL does not have coin, check the default from the domain name
    if(!addressAssigned){
        count = 0;
        for (let value of Object.values(websiteData)) {
            count = count + 1;
            if(value.url.includes(window.location.hostname)){
                websiteDataValues.url = value.url;
                login = value.login;
                password = value.password;
                if(value.withdrawPath){
                    withdrawPath = value.withdrawPath
                }
                addressAssigned = true;
                break;
            }
        }
    }

    async function ptcClick(){

        // Shortlinks with preverify are skipped due to different types of captchas
        // Write your logic here if you wish to solve captchas
        if (window.location.href.includes("pre_verify")) {
            goToNextUrl();
            return;
        }

        if (/links$/.test(window.location.href)) {

            unsafeWindow.onbeforeunload = function() {};

            const links = document.querySelectorAll('a');

            // Iterate through the NodeList and set the target attribute
            links.forEach(link => {
                link.removeAttribute('target'); // Set the target attribute
            });
            var clicked = false;
            let buttons = document.querySelectorAll(['h4', 'h5']);

            loopB:
                for (let i = 0; i < buttons.length; i++) {
                    if (buttons[i]?.parentNode.querySelector('a') && isAncestorHidden(buttons[i]?.parentNode.querySelector('a')) && !buttons[i]?.parentNode.querySelector('button')?.disabled &&
                        !buttons[i]?.parentNode.querySelector('a')?.hasAttribute("disabled")) {

                        for (let j = 0; j < SHORTLINKS_LIST.length; j++) {
                            if (buttons[i]?.innerText.toLowerCase().includes(SHORTLINKS_LIST[j].toLowerCase())) {
                                buttons[i]?.parentNode.querySelector('a')?.click();
                                clicked = true;
                                console.log("Clicked the element")
                                break loopB;
                            }
                        }
                    }

                }

            if (!clicked) {
                loopC: for (let i = 0; i < buttons.length; i++) {
                    if (buttons[i]?.parentNode?.parentNode?.querySelector('a') &&

                        !buttons[i]?.parentNode?.parentNode?.querySelector('a')?.hasAttribute("disabled")) {

                        for (let j = 0; j < SHORTLINKS_LIST.length; j++) {
                            if (buttons[i]?.innerText.toLowerCase().includes(SHORTLINKS_LIST[j].toLowerCase())) {
                                buttons[i]?.parentNode.parentNode.querySelector('a')?.click();
                                clicked = true;
                                console.log("Clicked the element")
                                break loopC;
                            }
                        }
                    }

                }
            }

            setInterval(function() {
                if (window.location.href.includes("google_vignette")) {
                    window.location.href = "/links";
                }

            }, 10000)


            if (!clicked) {
                goToNextUrl();
            }

            return;

        }


        const tabs = document.querySelectorAll('[role="tab"]');
        var tabDetected = false;

        // Iterate over tabs to find the one with "iframe" text inside
        tabs.forEach(async tab => {

            if (tab.innerText.toLowerCase().includes('iframe')) {
                // Select the tab by clicking it
                tab.click();
                tabDetected = true;
                await delay(2000);
            }
        });

        if(document.querySelector("#showIframeAds")){
            document.querySelector("#showIframeAds").click();
            tabDetected = true;
            await delay(2000);
        }

        const regexArray = [
            /^visit for \d+ sec$/,
            /^go$/,
            /^view$/,
            /^view now$/,
            /^visit now$/,
            /^view ads/,
            /^view ad/,
            /^watch$/,
            /^visit$/
        ];

        let ptcClicked = false;

        if(tabDetected == true){
            let tabId = document.querySelector('[role="tab"][aria-selected="true"]')?.getAttribute("href");
            let tabElement = document.querySelector(tabId) || document.querySelector("#iframeAds");

            if(tabElement){
                console.log(tabElement.querySelectorAll('button'));

                for(let i=0; i< regexArray.length;i++){
                    let button = Array.from(tabElement.querySelectorAll('button')).find(el => regexArray[i].test(el.textContent.toLowerCase().trim()));
                    if(button){
                        button?.click();
                        ptcClicked = true;
                        break;
                    }
                }

                if(!ptcClicked && /ptc$/.test(window.location.href)){
                    if(SHORTLINKS_ENABLED){
                     window.location.href = "/links";
                    } else {
                      goToNextUrl();
                    }
                }

            }
        }else{
            for(let i=0; i< regexArray.length;i++){
                let button = Array.from(document.querySelectorAll('button')).find(el => regexArray[i].test(el.textContent.toLowerCase().trim()));
                if(button && !isAncestorHidden(button)){
                    button?.click();
                    ptcClicked = true;
                    break;
                }
            }

            if(!ptcClicked && /ptc$/.test(window.location.href)){
                    if(SHORTLINKS_ENABLED){
                     window.location.href = "/links";
                    } else {
                      goToNextUrl();
                    }
            }
        }

    }

    function isAncestorHidden(element) {
        let parent = element;
        while (parent) {
            const display = getComputedStyle(parent).getPropertyValue('display');
            if (display === 'none') {
                return true;
            }
            parent = parent.parentElement;
        }
        return false;
    }

    //  Get the next Url from the website data map
    async function getNextUrl() {

        //  Go to the beginning if the end of the array is reached
        if (count >= websiteData.length) {
            websiteDataValues.nextUrl = websiteData[0].url;
        } else {
            websiteDataValues.nextUrl = websiteData[count].url;
        }

        //  Use case for overrding next Url
        if (websiteDataValues.overrideNextUrl) {
            websiteDataValues.nextUrl = websiteDataValues.overrideNextUrl;
        }

    }


    async function delay(ms) {
        return new Promise(resolve => setTimeout(resolve, ms))
    }


    var movingToNextUrl = false;
    async function goToNextUrl() {
        if (!movingToNextUrl) {
            movingToNextUrl = true;
            getNextUrl();
            await delay(3000);
            window.location.href = websiteDataValues.nextUrl;
        }
    }

    //  Default Setting: After 180 seconds go to next Url
    var delayBeforeMovingToNextUrl = 180000;
    if (websiteDataValues.timeoutbeforeMovingToNextUrl) {
        delayBeforeMovingToNextUrl = websiteDataValues.timeoutbeforeMovingToNextUrl;
    }

    setTimeout(function() {
        goToNextUrl();
    }, delayBeforeMovingToNextUrl);


    function withdraw() {


        if(document.querySelector("[role=dialog]") && !isAncestorHidden(document.querySelector("[role=dialog]"))){
            goToNextUrl();
            return;
        }

        if (performance.navigation.type == performance.navigation.TYPE_RELOAD) {
            goToNextUrl();
            return;
        }

        if(document.querySelector("input[type=text][name=wallet]") && document.querySelector("input[type=text][name=wallet]").value == ""){
            document.querySelector("input[type=text][name=wallet]").value=FAUCET_PAY_BTC_WALLET_ADDRESS;
        }

        if(document.querySelector("input[type=text][name=wallet]") &&
           document.querySelector("input[type=text][name=wallet]")?.nextElementSibling?.innerText.toLowerCase().includes("email") ||
           document.querySelector("input[type=text][name=wallet]")?.previousElementSibling?.innerText.toLowerCase().includes("email")){
            document.querySelector("input[type=text][name=wallet]").value=FAUCET_PAY_EMAIL;
        }

        var fpWalletNodes = Array.from(document.querySelectorAll(['span','p']))
        .filter(el => /faucetpay/.test(el.textContent.toLowerCase().trim()));
        var cWalletNodes = Array.from(document.querySelectorAll(['span','p']))
        .filter(el => /cwallet/.test(el.textContent.toLowerCase().trim()));

        function isProgressValid(element) {

            let parent = element;
            while (parent) {
                if (parent.querySelector("[role=progressbar]") && parseInt(parent.querySelector("[role=progressbar]").getAttribute("aria-valuenow")) > 10) {
                    return true;
                }
                if (parent.querySelector("[role=progressbar]") && parseInt(parent.querySelector("[role=progressbar]").getAttribute("aria-valuenow")) < 10) {
                    return false;
                }
                parent = parent.parentElement;
            }
            return true;
        }

        function selectRadioButton(element) {

            let parent = element;
            while (parent) {
                if (parent.querySelector("[type=radio]")) {
                    parent.querySelector("[type=radio]").click();
                    return true;
                }
                parent = parent.parentElement;
            }
            return false;

        }

        var selectedRadio = false;
        var walletSelected = "";

        for(let i=0; i< fpWalletNodes.length;i++){
            if(isProgressValid(fpWalletNodes[i])){

                let balance = parseFloat(fpWalletNodes[i]?.parentNode?.parentNode?.parentNode?.querySelector(".form-check-label")?.innerText.split('~')[1].trim());
                let minWithdraw = parseFloat(fpWalletNodes[i]?.parentNode?.parentNode?.parentNode?.querySelector("h5")?.innerText.split(" ")[0].trim());

                if(minWithdraw && balance < minWithdraw) {
                    goToNextUrl();
                    return;
                }
                selectRadioButton( fpWalletNodes[i]);
                selectedRadio = true;
                walletSelected = "faucetpay";
                break;
            }

        }

        if(selectedRadio == false){

            for(let i=0; i< cWalletNodes.length;i++){
                if(isProgressValid(cWalletNodes[i])){
                    let balance = parseFloat(cWalletNodes[i]?.parentNode?.parentNode?.parentNode?.querySelector(".form-check-label")?.innerText.split('~')[1].trim());
                    let minWithdraw = parseFloat(cWalletNodes[i]?.parentNode?.parentNode?.parentNode?.querySelector("h5")?.innerText.split(" ")[0].trim());

                    if(minWithdraw && balance < minWithdraw) {
                        goToNextUrl();
                        return;
                    }
                    selectRadioButton( cWalletNodes[i]);

                    selectedRadio = true;
                    walletSelected = "cwallet";
                    break;
                }

            }
        }

        if(selectedRadio == true) {
            // Update wallet address and solve captcha and click button

            if(walletSelected == "faucetpay"){
                if(document.querySelector("input[type=text][name=wallet]") && document.querySelector("input[type=text][name=wallet]").value == ""){
                    document.querySelector("input[type=text][name=wallet]").value=FAUCET_PAY_BTC_WALLET_ADDRESS;
                }

                if(document.querySelector("input[type=text][name=wallet]")&&
                   document.querySelector("input[type=text][name=wallet]")?.nextElementSibling?.innerText.toLowerCase().includes("email") ||
                   document.querySelector("input[type=text][name=wallet]")?.previousElementSibling?.innerText.toLowerCase().includes("email")){
                    document.querySelector("input[type=text][name=wallet]").value=FAUCET_PAY_EMAIL;
                }
            }

            if(walletSelected == "cwallet"){
                if(document.querySelector("input[type=text][name=wallet]").value == ""){
                    document.querySelector("input[type=text][name=wallet]").value=CWALLET_ID;
                }

                if(document.querySelector("input[type=text][name=wallet]") &&
                   document.querySelector("input[type=text][name=wallet]")?.nextElementSibling?.innerText.toLowerCase().includes("email") ||
                   document.querySelector("input[type=text][name=wallet]")?.previousElementSibling?.innerText.toLowerCase().includes("email")){
                    document.querySelector("input[type=text][name=wallet]").value=CWALLET_EMAIL;
                }
            }


            const regexArray = [
                /^withdraw$/
            ];

            function clickWithdrawButton(){
                for(let i=0; i< regexArray.length;i++){
                    let button = Array.from(document.querySelectorAll('button')).find(el => regexArray[i].test(el.textContent.toLowerCase().trim()));
                    if(button && !isAncestorHidden(button)){
                        button?.click();

                        break;
                    }
                }
            }

            let interval= setInterval(function(){

                if(document.querySelector("div.iconcaptcha-modal__body-title")?.innerText?.toLowerCase().includes("verified")){
                    clickWithdrawButton();
                    clearInterval(interval);
                }


                for (var hc = 0; hc < document.querySelectorAll("iframe").length; hc++) {
                    if (!clicked && document.querySelectorAll("iframe")[hc] &&
                        document.querySelectorAll("iframe")[hc].getAttribute("data-hcaptcha-response") &&
                        document.querySelectorAll("iframe")[hc].getAttribute("data-hcaptcha-response").length > 0) {
                        clickWithdrawButton();
                        clearInterval(interval);
                    }
                }

                if(unsafeWindow.turnstile?.getResponse?.()?.length >0){
                    clickWithdrawButton();
                    clearInterval(interval);
                }

                if(unsafeWindow.grecaptcha?.getResponse?.()?.length >0){
                    clickWithdrawButton();
                    clearInterval(interval);
                }

            },5000);

        }
    }

    var stopSolvingCaptcha = false;

    function checkLoginSelectors() {

        if (websiteDataValues.loginSelectors) {
            //  Check if all login selectors are present
            let count = 0;
            for (let i = 0; i < websiteDataValues.loginSelectors.length; i++) {
                if (document.querySelector(websiteDataValues.loginSelectors[i])) {
                    count++;
                }

            }

            if (count == websiteDataValues.loginSelectors.length) {

                if (login.length > 0 && password.length > 0) {
                    //  Input Login
                    document.querySelector(websiteDataValues.loginSelectors[0]).value = login;

                    //  Input Password
                    document.querySelector(websiteDataValues.loginSelectors[1]).value = password;
                } else {
                    stopSolvingCaptcha = true;
                }

            } else {
                stopSolvingCaptcha = true;
            }

        } else {
            stopSolvingCaptcha = true;
        }

    }

    if(ENABLE_NEXT_BUTTON){

        var node = document.createElement ('div');
        node.setAttribute ('class', 'floatbuttonabc nextabc');


        node.innerHTML = '<p>Next</p>';
        document.body.appendChild (node);

        document.querySelector(".floatbuttonabc").addEventListener (
            "click", goToNextUrl, false
        );


        GM_addStyle ( `

.floatbuttonabc {
  position: fixed;
  right: -77px;
  top: 270px;
  transition: all 0.2s ease-in 0s;//this is the key attribute
  z-index: 9999;
  cursor: pointer;
}

.floatbuttonabc:hover {
  right: -7px;//hide it by pushing it off the screen
}

.nextabc {
  position: fixed;
  width: 20%;
}

.nextabc p {
  padding: 8px;
  margin-bottom: 8px;
  background-color: #33b5e5;
  color: #ffffff;
}

.nextabc p:hover {
  background-color: #0099cc;
}


` );

    }


    setTimeout(function() {

        if(window.location.href.includes("maintenance") || window.location.href.includes("locked")){
            goToNextUrl();
            return;
        }

        if(document.querySelector("h2")?.innerText.toLowerCase().includes("verify")){
            console.log("Turnstile Detected");
            return;
        }

        if(ENABLE_WITHDRAWAL && withdrawPath && withdrawPath != "" && window.location.href.includes(withdrawPath)){
            withdraw();
            return;
        }

        if(ENABLE_WITHDRAWAL && withdrawPath && withdrawPath != "" && !window.location.href.includes("/login")){
            window.location.href = withdrawPath;
            return;
        }

        if(ENABLE_WITHDRAWAL && withdrawPath == "" && !window.location.href.includes("/login") && !window.location.href.includes("/withdraw")) {
            window.location.href = "/withdraw";
            return;
        }

        if(ENABLE_WITHDRAWAL && window.location.href.includes("/withdraw")){
            withdraw();
            return;
        }

        if(window.location.href.includes("/dashboard")){
            window.location.href="/ptc";
        }

        if(!window.location.href.match(/([a-zA-Z0-9]+)\/ptc/) && !window.location.href.includes("/dashboard") && !window.location.href.includes("/login") && !window.location.href.match(/([a-zA-Z0-9]+)\/links/)){
            window.location.href="/login";
        }

        checkLoginSelectors();

        if (websiteDataValues.additionalFunctions) {
            websiteDataValues.additionalFunctions();
        }

        //  Click the form button after solving captcha
        //  Works for both recaptcha and hcaptcha
        var clicked = false;
        var toogledCaptcha = false;

        function triggerEvent(el, type) {
            try{
                var e = document.createEvent('HTMLEvents');
                e.initEvent(type, false, true);
                el.dispatchEvent(e);
            }catch(exception){
                console.log(exception);
            }
        }

        function toggleCaptcha(selector, captchaTypes){

            if( document.querySelector(selector)){

                const select = document.querySelector(selector);
                var captchaSelected = false;
                for(let i=0; i< captchaTypes.length; i++){
                    const optionTextToSelect = captchaTypes[i];

                    for (let i = 0; i < select.options.length; i++) {
                        const option = select.options[i];
                        if (option.text.toLowerCase().includes(optionTextToSelect)) {
                            if(option.selected == true){
                                captchaSelected = true;
                                break;
                            }
                            option.selected = true;
                            captchaSelected = true;
                            setTimeout(function() {
                                triggerEvent(document.querySelector(selector), 'change');
                            }, 2000);
                            break;
                        }
                    }
                    if(captchaSelected){
                        break;
                    }
                }

            }
        }

       var captchaInterval = setInterval(function() {
            document.hasFocus=function(){return true};
            if (!stopSolvingCaptcha || !window.location.href.includes("login")) {
                try {

                    if(document.querySelector("button[type='submit']") && (isAncestorHidden(document.querySelector("button[type='submit']")) || document.querySelector("button[type='submit']")?.disabled == true )){
                        return;
                    }

                    if(!toogledCaptcha && document.querySelector("button[type='submit']") && !isAncestorHidden(document.querySelector("button[type='submit']"))){
                        toggleCaptcha("#selectCaptcha",CAPTCHA_PRIORITY_LIST);
                        toogledCaptcha = true;
                    }

                    if(!clicked && document.querySelector(".iconcaptcha-modal__body .iconcaptcha-modal__body-checkmark") &&
                       document.querySelector("button[type='submit']") && !isAncestorHidden(document.querySelector("button[type='submit']"))){
                        document.querySelector("button[type='submit']")?.click();
                        clicked = true;
                        clearInterval(captchaInterval);
                    }

                    if(!clicked && document.querySelector("#captcha-container .captcha-icon")?.classList[2] &&
                       document.querySelector("button[type='submit']") && !isAncestorHidden(document.querySelector("button[type='submit']"))){
                        let className = "." + document.querySelector("#captcha-container .captcha-icon").classList[2] ;
                        document.querySelector("#icon-options " + className)?.click();
                        setTimeout(function(){
                            if(document.querySelector("#captcha-result")?.innerText?.toLowerCase().includes("verified")){
                                document.querySelector("button[type='submit']")?.click();
                                clicked = true;
                                clearInterval(captchaInterval);
                            }
                        },5000);
                    }

                    if(!clicked && unsafeWindow?.hcaptcha?.getResponse?.()?.length >0){
                        for (let i = 0; i < websiteDataValues.captchaButtonSubmitSelector.length; i++) {
                            if (document.querySelector(websiteDataValues.captchaButtonSubmitSelector[i]) &&
                                !isAncestorHidden(document.querySelector(websiteDataValues.captchaButtonSubmitSelector[i]))) {
                                document.querySelector(websiteDataValues.captchaButtonSubmitSelector[i])?.click();
                                clicked = true;
                                clearInterval(captchaInterval);
                            }
                        }
                    }

                    if(!clicked && unsafeWindow?.turnstile?.getResponse?.()?.length >0){
                        for (let i = 0; i < websiteDataValues.captchaButtonSubmitSelector.length; i++) {
                            if (document.querySelector(websiteDataValues.captchaButtonSubmitSelector[i]) &&
                                !isAncestorHidden(document.querySelector(websiteDataValues.captchaButtonSubmitSelector[i]))) {
                                document.querySelector(websiteDataValues.captchaButtonSubmitSelector[i])?.click();
                                clicked = true;
                                clearInterval(captchaInterval);
                            }
                        }
                    }

                    if(!clicked && unsafeWindow?.grecaptcha?.getResponse?.()?.length >0){
                        for (let i = 0; i < websiteDataValues.captchaButtonSubmitSelector.length; i++) {
                            if (document.querySelector(websiteDataValues.captchaButtonSubmitSelector[i]) &&
                                !isAncestorHidden(document.querySelector(websiteDataValues.captchaButtonSubmitSelector[i]))) {
                                document.querySelector(websiteDataValues.captchaButtonSubmitSelector[i])?.click();
                                clicked = true;
                                clearInterval(captchaInterval);
                            }
                        }
                    }

                    for (var hc = 0; hc < document.querySelectorAll("iframe").length; hc++) {
                        if (!clicked && document.querySelectorAll("iframe")[hc] &&
                            document.querySelectorAll("iframe")[hc].getAttribute("data-hcaptcha-response") &&
                            document.querySelectorAll("iframe")[hc].getAttribute("data-hcaptcha-response").length > 0) {
                            for (let i = 0; i < websiteDataValues.captchaButtonSubmitSelector.length; i++) {
                                if (document.querySelector(websiteDataValues.captchaButtonSubmitSelector[i]) &&
                                    !isAncestorHidden(document.querySelector(websiteDataValues.captchaButtonSubmitSelector[i]))) {
                                    document.querySelector(websiteDataValues.captchaButtonSubmitSelector[i]).click();
                                    clicked = true;
                                    clearInterval(captchaInterval);
                                }
                            }
                        }
                    }

                } catch (e){
                    //  console.log(e);
                }
            }

        }, 5000);

    }, 5000);

})();