window.addEventListener('load', function () {
    const targetNode = document.querySelector('#scrollIframe #iframe_6in1');

    if (targetNode) {
    // Function to add event listener to the load-more button
    const addLoadMoreListener = function () {
        const loadMoreButton = document.querySelector('#scrollIframe #iframe_6in1 .wrap-loadmore .load-more-btn');
        const tableView = document.querySelector('#scrollIframe #iframe_6in1 .table-view');

        // Check if both elements are present
        if (loadMoreButton && tableView) {
            loadMoreButton.addEventListener('click', function () {
                tableView.scrollTo({ top: tableView.scrollHeight, behavior: 'smooth' });
            });
        }
    };

    // Try adding the listener initially in case the button is already rendered
    addLoadMoreListener();

    // Set up a MutationObserver to detect when the element is added if it wasn't available on initial load
    const observer = new MutationObserver((mutationsList) => {
        for (const mutation of mutationsList) {
        if (mutation.type === 'childList') {
            // Try adding the listener again if new elements are added
            addLoadMoreListener();
        }
        }
    });

    // Start observing for child changes in the target node
    observer.observe(targetNode, { childList: true, subtree: true });
    }
});