این کد رو دارم

let first_usdt = 4;
let has_profit;
let timer_time_out = 100; // ms

function delay(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
}

function show_time() {
  const now = new Date();
  const options = { 
      year: 'numeric', 
      month: '2-digit', 
      day: '2-digit', 
      hour: '2-digit', 
      minute: '2-digit', 
      second: '2-digit',
      hour12: false // برای 24 ساعت
  };
  const formattedDateTime = now.toLocaleString('en-GB', options);
  console.log("Current date and time:", formattedDateTime);
}

function find_element(xpathExpression) {
    const result = document.evaluate(
        xpathExpression,
        document,
        null,
        XPathResult.FIRST_ORDERED_NODE_TYPE,
        null
    );
    return result.singleNodeValue;
}

function get_elements() {
    return {
        first_input_element: find_element("/html/body/div[1]/div[1]/div[2]/div[2]/div[1]/div/input"),
        secound_input_element: find_element("/html/body/div[1]/div[1]/div[2]/div[2]/div[3]/div/input"),
        lis_element: find_element("/html/body/div[1]/div[1]/div[2]/div[2]/div[1]/div/div/div[3]/div[1]"),
        matic_element: find_element("/html/body/div[1]/div[1]/div[2]/div[2]/div[1]/div/div/div[3]/div[4]"),
        usdt_element: find_element("/html/body/div[1]/div[1]/div[2]/div[2]/div[1]/div/div/div[3]/div[5]"),
        near_element: find_element("/html/body/div[1]/div[1]/div[2]/div[2]/div[1]/div/div/div[3]/div[6]")
    };
}

function get_transfer_value(secound_input_element) {
    return secound_input_element.value;
}

function click_on_element(element) {
    if (element) {
        element.click();
    }
}

function set_value(element, value_item) {
    if (element) {
        element.value = value_item;
        const event = new Event('input', { bubbles: true });
        element.dispatchEvent(event);
    }
}

function click_sec_near() {
    click_on_element(find_element("/html/body/div[1]/div[1]/div[2]/div[2]/div[3]/div/div/div[3]/div[4]"));
}

function click_sec_usdt() {
    click_on_element(find_element("/html/body/div[1]/div[1]/div[2]/div[2]/div[3]/div/div/div[3]/div[2]"));
}

function click_swap_button() {
    click_on_element(find_element("/html/body/div[1]/div[1]/div[2]/div[2]/button"));
}

function click_confirm_button() {
    click_on_element(find_element("/html/body/div[1]/div[1]/div[2]/div[3]/div[1]/div/div/div/div[3]/button[2]"));
}

async function get_name_first_crypto() {
    const text_element = click_on_element(find_element("/html/body/div[1]/div[1]/div[2]/div[2]/div[1]/div/div/div[1]/div"));
    console.log(text_element.textContent);
}

async function get_name_second_crypto(params) {
    click_on_element(find_element("/html/body/div[1]/div[1]/div[2]/div[3]/div[1]/div/div/div/div[3]/button[2]"));
}

async function process_data() {
    const elements = get_elements();
    let transfer_value;
    const timer_swap_button = 200; // ms
    const timer_swap = 15000; // ms

    click_on_element(elements.usdt_element);
    set_value(elements.first_input_element, first_usdt);
    
    await delay(timer_time_out);
    transfer_value = get_transfer_value(elements.secound_input_element);
    click_swap_button();
    
    await delay(timer_swap_button);
    click_confirm_button();
    
    await delay(timer_swap);
    click_on_element(elements.matic_element);
    set_value(elements.first_input_element, transfer_value);

    await delay(timer_time_out);
    transfer_value = get_transfer_value(elements.secound_input_element);
    click_swap_button();
    
    await delay(timer_swap_button);
    click_confirm_button();

    await delay(timer_swap);
    click_on_element(elements.lis_element);
    
    await delay(timer_time_out);
    click_sec_near();
    set_value(elements.first_input_element, transfer_value);

    await delay(timer_time_out);
    transfer_value = get_transfer_value(elements.secound_input_element);
    click_swap_button();
    
    await delay(timer_swap_button);
    click_confirm_button();
    
    await delay(timer_swap);
    click_on_element(elements.near_element);
    
    await delay(timer_time_out);
    click_sec_usdt();
    set_value(elements.first_input_element, transfer_value);

    await delay(timer_time_out);
    transfer_value = get_transfer_value(elements.secound_input_element);
    click_swap_button();
    
    await delay(timer_swap_button);
    click_confirm_button();
    
    await delay(timer_swap);

    console.log("swap success");
    show_time();
}

async function get_all_data(callback) {
    const elements = get_elements();
    let transfer_value;

    click_on_element(elements.usdt_element);
    set_value(elements.first_input_element, first_usdt);
    
    await delay(timer_time_out);
    transfer_value = get_transfer_value(elements.secound_input_element);
    
    click_on_element(elements.matic_element);
    set_value(elements.first_input_element, transfer_value);
    
    await delay(timer_time_out);
    transfer_value = get_transfer_value(elements.secound_input_element);
    
    click_on_element(elements.lis_element);
    await delay(timer_time_out);
    
    click_sec_near();
    set_value(elements.first_input_element, transfer_value);

    await delay(timer_time_out);
    transfer_value = get_transfer_value(elements.secound_input_element);
    
    click_on_element(elements.near_element);
    await delay(timer_time_out);
    
    click_sec_usdt();
    set_value(elements.first_input_element, transfer_value);

    await delay(timer_time_out);
    transfer_value = get_transfer_value(elements.secound_input_element);

    console.log(first_usdt, transfer_value);
    console.log(parseFloat((((transfer_value / first_usdt) * 100) - 100).toFixed(2)), "%");
    show_time();
  
    if (first_usdt < transfer_value) {
        has_profit = true;
        // await process_data();
    }
    get_name_first_crypto();
    // Callback را در اینجا فراخوانی کنید
    callback(has_profit);
}

async function startDataCollection() {
    has_profit = false;
    const timer_run = 1; // به ثانیه
    const timer_rerun = 1;

    const checkForProfit = async () => {
        await get_all_data((hasProfitResult) => {
            if (hasProfitResult) {
                setTimeout(checkForProfit, timer_rerun * 1000); // 5 ثانیه
            } else {
                setTimeout(checkForProfit, timer_run * 1000); // بر اساس timer_run
            }
        });
    };

    checkForProfit();
}

startDataCollection();

اینم ارور

VM46:152 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'textContent')
    at get_name_first_crypto (<anonymous>:152:30)
    at get_all_data (<anonymous>:262:5)
    at async checkForProfit (<anonymous>:273:9)