// Select all elements with the class 'postMessage'
elements = document.querySelectorAll('.postMessage');

// Create an object to store text content and their occurrences
textContentMap = {};

// Iterate over the elements and populate the textContentMap
elements.forEach(element => {
  const textContent = element.textContent.replace(/>>\d+(?:\s+\(You\))?(?:\s+\(Cross-thread\))?#?/gm, '').trim();
  if (!textContent) {
    return;
  }
  if (textContentMap[textContent]) {
    textContentMap[textContent].push(element);
  } else {
    textContentMap[textContent] = [element];
  }
});

// Find and log the later occurrences of duplicated text content
Object.values(textContentMap).forEach(elementsWithSameText => {
  if (elementsWithSameText.length > 1) {
    // Log or process the later occurrences
    elementsWithSameText.slice(1).forEach(element => {
      element.style.background = '#f00';
      console.log(element); // Replace this with your desired action
    });
  }
});
Edit

Pub: 27 Jun 2025 17:19 UTC

Edit: 27 Jun 2025 17:24 UTC

Views: 68