lyco0207 / AUTOMATIC REGISTER FOR AAAJL

// ==UserScript==
// @name         AUTOMATIC REGISTER FOR AAAJL
// @namespace    Violentmonkey Scripts
// @version      1.0
// @author       lyco12
// @match        https://www.aaajl.cc/m/*
// @grant        none
// @updateURL    https://openuserjs.org/meta/lyco0207/AUTOMATIC_REGISTER_FOR_AAAJL.meta.js
// @downloadURL  https://openuserjs.org/install/lyco0207/AUTOMATIC_REGISTER_FOR_AAAJL.user.js
// @copyright    2024, lyco0207
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Function to generate a random string with digits ranging from 6 to 13 characters
    function fullgenerate(length) {
        const characters = 'abcdefghijklmnopqrstuvwxyz';
        let result = '';
        for (let i = 0; i < length; i++) {
            result += characters.charAt(Math.floor(Math.random() * characters.length));
        }
        return result;
    }

    // Function to generate a random string with digits ranging from 6 to 13 characters
    function generateRandomString(length) {
        const characters = 'abcdefghijklmnopqrstuvwxyzZ0123456789';
        let result = '';
        for (let i = 0; i < length; i++) {
            result += characters.charAt(Math.floor(Math.random() * characters.length));
        }
        return result;
    }

    // Function to generate a random 11-digit number as a string
    function generateRandomAccountNumber() {
        const firstDigit = Math.floor(Math.random() * 9) + 1;
        let result = firstDigit.toString();
        for (let i = 1; i < 11; i++) {
            result += Math.floor(Math.random() * 10).toString();
        }
        return result;
    }

    // Function to copy text to clipboard using the Clipboard API
    function copyToClipboard(text) {
        if (navigator.clipboard) {
            navigator.clipboard.writeText(text).then(function() {
                console.log('Username copied to clipboard.');
            }).catch(function(error) {
                console.error('Failed to copy username: ', error);
            });
        } else {
            console.error('Clipboard API not supported on this device.');
        }
    }

    // Function to fill input and trigger event
    function fillAndDispatchEvent(inputField, value) {
        inputField.value = value;
        inputField.dispatchEvent(new Event('input', { bubbles: true }));
    }

    // Function to handle actions on the new URL
    function handleNewPage() {
        const intervalModal = setInterval(() => {
            const closeButton = document.querySelector('.close-btn');
            if (closeButton) {
                closeButton.click(); // Simulate click on the close button
                console.log('Modal closed.');
                clearInterval(intervalModal); // Stop checking once the modal is closed

                // After closing modal, choose a random bank
                chooseRandomBank();
            }
        }, 1000); // Check every second
    }

    // Function to select a random bank
    function chooseRandomBank() {
        const bankItems = document.querySelectorAll('.bank-item');
        if (bankItems.length > 0) {
            const randomIndex = Math.floor(Math.random() * bankItems.length);
            const randomBank = bankItems[randomIndex];
            randomBank.click(); // Simulate clicking the selected bank item
            console.log('Random bank selected.');

            // Fill necessary input fields after selecting a bank
            const fname = fullgenerate(Math.floor(Math.random() *2)+4);
          const lname = fullgenerate(Math.floor(Math.random() * 4)+5);
            fillPayeeField(`${fname} ${lname}`);

            const randomAccountNumber = generateRandomAccountNumber();
            fillAccountNumberField(randomAccountNumber);

            // Fill the payment and confirmation passwords
            const fixedPassword = '200202';
            fillPaymentPassword(fixedPassword);
            fillConfirmationPassword(fixedPassword);

            // Simulate click on the submit button and redirect
            submitForm();
        } else {
            console.error('No bank items found.');
        }
    }

    // Function to fill the payee name field
    function fillPayeeField(name) {
        const payeeInput = document.querySelector('input[name="payee"]');
        if (payeeInput) {
            fillAndDispatchEvent(payeeInput, name);
            console.log('Payee field filled with:', name);
        } else {
            console.error('Payee input field not found.');
        }
    }

    // Function to fill the account number field
    function fillAccountNumberField(accountNumber) {
        const accountNumberInput = document.querySelector('input[name="customField"]');
        if (accountNumberInput) {
            fillAndDispatchEvent(accountNumberInput, accountNumber);
            console.log('Account number field filled with:', accountNumber);
        } else {
            console.error('Account number input field not found.');
        }
    }

    // Function to fill the payment password field
    function fillPaymentPassword(password) {
        const passwordInput = document.querySelector('input[name="withdraw"]');
        if (passwordInput) {
            fillAndDispatchEvent(passwordInput, password);
            console.log('Payment password field filled with:', password);
        } else {
            console.error('Payment password input field not found.');
        }
    }

    // Function to fill the confirmation password field
    function fillConfirmationPassword(password) {
        const confirmationPasswordInput = document.querySelector('input[name="withdrawT"]');
        if (confirmationPasswordInput) {
            fillAndDispatchEvent(confirmationPasswordInput, password);
            console.log('Confirmation password field filled with:', password);
        } else {
            console.error('Confirmation password input field not found.');
        }
    }

    // Function to simulate form submission and redirect
    function submitForm() {
        const submitButton = document.querySelector('.am-button.btn-success');
        if (submitButton) {
            submitButton.click();
            console.log('Form submitted.');

            // Redirect to the new URL after submission
            setTimeout(() => {
                window.location.href = 'https://www.aaajl.cc/m/securityCenter?affiliateCode=855469&referralCode=lrg3327';
            }, 2000); // Delay to ensure the form submission completes
        } else {
            console.error('Submit button not found.');
        }
    }

    // Wait for the page to load fully
    window.addEventListener('load', function() {
        if (window.location.href.includes('securityCenter/addBankCardPix')) {
            handleNewPage();
        } else {
            // Original script logic for registration
            let usernameField = document.querySelector('input[name="username"]');
            let passwordField = document.querySelector('input[name="password"]');
            let confirmPasswordField = document.querySelector('input[name="confimpsw"]');

            if (usernameField) {
                const randomUsername = generateRandomString(Math.floor(Math.random() * 8) + 6);
                fillAndDispatchEvent(usernameField, randomUsername);
                copyToClipboard(randomUsername);
            }

            if (passwordField) {
                const randomPassword = "lyco12";
                fillAndDispatchEvent(passwordField, randomPassword);

                if (confirmPasswordField) {
                    fillAndDispatchEvent(confirmPasswordField, randomPassword);
                }
            }

            let submitButton = document.querySelector('button.submit-btn');
            if (submitButton) {
                submitButton.click();
                console.log('Form submitted.');

                const interval = setInterval(() => {
                    const modalContent = document.querySelector('.am-modal-content');
                    if (modalContent) {
                        const modalBody = modalContent.querySelector('.am-modal-body');
                        if (modalBody && modalBody.textContent.includes('Matagumpay na nakarehistro, handa na para sa pag-login')) {
                            clearInterval(interval);
                            modalContent.querySelector('.am-modal-button').click();
                            window.location.href = 'https://www.aaajl.cc/m/securityCenter/addBankCardPix?affiliateCode=855469&referralCode=lrg3327&group=263002';
                        }
                    }
                }, 1000); // Check every second
            }
        }
    });
})();