can you modify the code to indicate the word that is close to the hovered word in meaning from the four words below it:

// content.js

// Cache to store fetched meanings and prevent redundant API calls
const meaningsCache = {};

// Variable to keep track of the currently hovered word
let currentWord = null;

// Variable to keep the tooltip element
let tooltip = null;

// Listen for mouseover events
document.addEventListener('mouseover', handleMouseOver);

// Listen for mouseout events to remove tooltip
document.addEventListener('mouseout', handleMouseOut);

// Function to handle mouseover events
function handleMouseOver(event) {
  const word = getWordUnderCursor(event);

  // If there's a word and it's different from the current word
  if (word && word !== currentWord) {
    currentWord = word;

    // Check if meanings are already cached
    if (meaningsCache[word]) {
      showTooltip(event.pageX, event.pageY, meaningsCache[word]);
    } else {
      // Fetch meanings and cache them
      fetchMeanings(word)
        .then(meanings => {
          if (meanings.length > 0) {
            meaningsCache[word] = meanings.join('; ');
            showTooltip(event.pageX, event.pageY, meaningsCache[word]);
          }
        })
        .catch(error => {
          console.error('Error fetching meanings:', error);
        });
    }
  }
}

// Function to handle mouseout events
function handleMouseOut(event) {
  const relatedTarget = event.relatedTarget;

  // If moving to a child element, do not remove tooltip
  if (tooltip && (!relatedTarget || !tooltip.contains(relatedTarget))) {
    removeExistingTooltip();
    currentWord = null;
  }
}

// Function to get the word under the cursor
function getWordUnderCursor(event) {
  const range = document.caretRangeFromPoint
    ? document.caretRangeFromPoint(event.clientX, event.clientY)
    : document.caretPositionFromPoint(event.clientX, event.clientY)?.offsetNode;

  if (!range) return null;

  const node = range.startContainer;

  if (node.nodeType !== Node.TEXT_NODE) return null;

  const text = node.textContent;
  const offset = range.startOffset;

  // Use regex to find word boundaries
  const left = text.slice(0, offset).search(/\S+$/);
  const right = text.slice(offset).search(/\s/);

  const start = left === -1 ? 0 : left;
  const end = right === -1 ? text.length : offset + right;

  const word = text.slice(start, end).trim();

  // Validate that it's a single word (no spaces)
  if (word && !/\s/.test(word)) {
    return word;
  }

  return null;
}

// Function to fetch meanings from the Datamuse API
function fetchMeanings(word) {
  return fetch(`https://api.datamuse.com/words?ml=${encodeURIComponent(word)}&max=5`)
    .then(response => response.json())
    .then(data => data.map(obj => obj.word));
}

// Function to display a tooltip near the hovered word
function showTooltip(x, y, text) {
  removeExistingTooltip(); // Ensure no duplicate tooltips

  tooltip = document.createElement('div');
  tooltip.id = 'word-meaning-tooltip';
  tooltip.innerText = text;

  // Style the tooltip
  Object.assign(tooltip.style, {
    position: 'absolute',
    top: (y + 15) + 'px',
    left: (x + 15) + 'px',
    backgroundColor: '#fffbea',
    border: '1px solid #ccc',
    padding: '5px',
    zIndex: 10000,
    boxShadow: '2px 2px 6px rgba(0,0,0,0.2)',
    borderRadius: '4px',
    fontSize: '14px',
    color: '#333',
    maxWidth: '300px',
    wordWrap: 'break-word',
    pointerEvents: 'none' // Allows mouse events to pass through
  });

  document.body.appendChild(tooltip);
}

// Function to remove existing tooltip
function removeExistingTooltip() {
  if (tooltip) {
    tooltip.remove();
    tooltip = null;
  }
}