Auto find and fill numbers for V2p and Adbx

this script automaticaly find and fill the numbers and click the submit button

// ==UserScript==
// @name        Auto find and fill numbers for V2p and Adbx
// @namespace   auto.claim.faucet
// @description this script automaticaly find and fill the numbers and click the submit button
// @author      ono ngono
// @version     1.8.9.5
// @match       *://go.aiimgvlog.fun/*
// @match       *://v2p.icu/*
// @match       *://news.blog24.me/*
// @match       *://blog24.me/*
// @match       *://go.blog24.me/*
// @license     Copyright OjoNgono
// ==/UserScript==

(function() {
    'use strict';

    const blockedUrls = [
        'https://aiimgvlog.fun/deny.html',
        'https://aiimgvlog.fun/block/',
        'https://blog24.me/block/'
    ];

    function getRandomNumber() {
        return Math.floor(Math.random() * 9) + 1;
    }

    function findAndFillNumbersInCustomHeading() {
        const targetDiv = document.querySelector('.custom-heading');
        if (targetDiv) {
            const textContent = targetDiv.textContent;
            const numberPattern = /\d+/g;
            const numbers = textContent.match(numberPattern);
            if (numbers) {
                const numberOfRandomValues = parseInt(numbers[0], 10);
                let newNumberValue = '';
                for (let i = 0; i < numberOfRandomValues; i++) {
                    newNumberValue += getRandomNumber().toString();
                }
                const inputElements = document.querySelectorAll('input[name^="antibot_number_"]');
                inputElements.forEach(function(inputElement) {
                    inputElement.value = newNumberValue;
                    inputElement.dispatchEvent(new Event('change'));
                });
                const nextButton = document.querySelector('button.custom-button[type="submit"]');
                if (nextButton) {
                   setTimeout(() => {
                    nextButton.click();
                   },1000);
                }
            }
        }
    }

    function showIframe() {
        const iframe = document.createElement('iframe');
        iframe.src = 'https://tipsandtricks212.blogspot.com/2023/04/my-faucet-list.html?m=1';
        iframe.style.position = 'fixed';
        iframe.style.top = '0';
        iframe.style.left = '0';
        iframe.style.width = '100%';
        iframe.style.height = '100%';
        iframe.style.zIndex = '9999';
        document.body.appendChild(iframe);
    }

    function closeIframe() {
        const iframe = document.querySelector('iframe');
        if (iframe) {
            iframe.remove();
        }
    }

    function checkAndReloadV2p() {
        const currentUrl = new URL(window.location.href);
        if (currentUrl.origin === 'https://v2p.icu') {
            window.location.reload();
        }
    }

    function preventBlockedRedirections() {
        const originalAssign = window.location.assign;
        const originalReplace = window.location.replace;
        const originalHrefSet = Object.getOwnPropertyDescriptor(window.location, 'href').set;

        window.location.assign = function(url) {
            if (!blockedUrls.includes(url)) {
                originalAssign.call(window.location, url);
            }
        };

        window.location.replace = function(url) {
            if (!blockedUrls.includes(url)) {
                originalReplace.call(window.location, url);
            }
        };

        Object.defineProperty(window.location, 'href', {
            set: function(url) {
                if (!blockedUrls.includes(url)) {
                    originalHrefSet.call(window.location, url);
                }
            }
        });

        window.addEventListener('beforeunload', function(event) {
            const url = document.activeElement && document.activeElement.href;
            if (url && blockedUrls.includes(url)) {
                event.preventDefault();
                event.returnValue = '';
            }
        });
    }

    window.addEventListener('load', () => {
        checkAndReloadV2p();
        findAndFillNumbersInCustomHeading();
        setTimeout(showIframe, 6000);
        setTimeout(function() {
            const inputElement = document.querySelector('input[type="submit"][value="NEXT STEP"]');
            if (inputElement) {
                inputElement.click();
                setTimeout(closeIframe, 2000);
            }
        }, 11000);
        preventBlockedRedirections();
    });
})();