addEventListener(‘click) not triggering when button is clicked

Goal: Clicking on the button opens a link in a new page.
Issue: eventListener not triggering when button is clicked

Button element:

<button type="button" class="btn oe_stat_button o_field_widget o_readonly_modifier"></button>

Event listener:

const mainButton = document.querySelector('.btn.oe_stat_button.o_field_widget.o_readonly_modifier');
mainButton.addEventListener('click', () => window.open(linkConfig,'_blank'));

I have verified that my button is well assigned to the mainButton and found in the DOM.
I have verified that the value assigned to container is found in the DOM.

Whole code:

setTimeout(linkToSupplier, 3000);

function linkToSupplier() {

        const container = document.querySelector('[data-id^="product.supplierinfo_"]').innerText;
        const supplierContent = document.querySelector('[title="Supplier"]');
        
    function linkConfig(supplierLink) {

        supplierContent.innerText = '';
        const link = document.createElement("a")

        // Create txt
        const txt = document.createTextNode("Vist Website ")

        //append txt to anchor element
        link.appendChild(txt)

        // set the innerText
        link.title = "Visit Website ";
        link.target = 'target="_blank"';

        // set the href property
        link.href = supplierLink;

        // get text to add link to
        const mainButton = document.querySelector('.btn.oe_stat_button.o_field_widget.o_readonly_modifier');
        mainButton.outerHTML = `<button type="button" class="btn oe_stat_button o_field_widget o_readonly_modifier"></button>`;
        mainButton.addEventListener('click', () => window.open(linkConfig,'_blank'));
    }

    window.addEventListener('hashchange', () => setTimeout(linkToSupplier, 1000));

    if (container.includes('Google')) {
        linkConfig('https://google.com/');
    }
}