document.addEventListener('DOMContentLoaded', (event) => { // Function to check if a string could be a gift card identifier function couldBeGiftCardIdentifier(code) { // Define the suspected pattern of the gift card codes here const pattern = /^PWGC-/; return pattern.test(code); } // Find all elements that could contain gift card codes const elements = document.querySelectorAll('.gift-card-code-element'); // Loop over these elements and check for gift card identifiers elements.forEach((element) => { const code = element.textContent || element.value; if (couldBeGiftCardIdentifier(code)) { console.log('Found gift card identifier:', code); // Perform your logic here } }); });