test Business

test Business

(function() {

    // Function to override redirection methods

    function preventRedirect() {

        console.log("Redirection attempt blocked");

    }


    // Override window.location methods

    Object.defineProperty(window, 'location', {

        configurable: false,

        enumerable: true,

        writable: false,

        value: {

            assign: preventRedirect,

            replace: preventRedirect,

            reload: preventRedirect,

            toString: function() {

                return window.location.href;

            }

        }

    });


    // Intercept any attempts to change window.location directly

    Object.defineProperty(window.location, 'href', {

        set: preventRedirect

    });


    // Override document.location if used

    Object.defineProperty(document, 'location', {

        configurable: false,

        enumerable: true,

        writable: false,

        value: window.location

    });


    // Prevent form submissions

    document.addEventListener('submit', function(event) {

        event.preventDefault();

        console.log("Form submission attempt blocked");

    }, true);


    // Prevent anchor link clicks that cause a redirect

    document.addEventListener('click', function(event) {

        if (event.target.tagName === 'A' && event.target.href) {

            event.preventDefault();

            console.log("Anchor link click attempt blocked");

        }

    }, true);


    // Mutation observer to handle dynamically added forms and links

    const observer = new MutationObserver((mutations) => {

        mutations.forEach((mutation) => {

            mutation.addedNodes.forEach((node) => {

                if (node.tagName === 'FORM') {

                    node.addEventListener('submit', function(event) {

                        event.preventDefault();

                        console.log("Dynamically added form submission attempt blocked");

                    }, true);

                }

                if (node.tagName === 'A') {

                    node.addEventListener('click', function(event) {

                        if (event.target.href) {

                            event.preventDefault();

                            console.log("Dynamically added anchor link click attempt blocked");

                        }

                    }, true);

                }

            });

        });

    });


    observer.observe(document.body, {

        childList: true,

        subtree: true

    });


    console.log("Redirection prevention script active");

})();