(function() { function extractData(doc) { let items = []; const blocks = doc.querySelectorAll('.termlist-item.contentblock'); blocks.forEach(block => { let word = ""; let type = ""; let pronunciation = ""; // Extract from h2 const h2 = block.querySelector('h2.h3'); if (h2) { // Word is typically the first text node word = Array.from(h2.childNodes) .filter(node => node.nodeType === Node.TEXT_NODE) .map(node => node.textContent.trim()) .join(' ') .trim(); const spans = h2.querySelectorAll('span'); if (spans.length >= 2) { type = spans[0].textContent.trim(); pronunciation = spans[1].textContent.trim(); } else if (spans.length === 1) { type = spans[0].textContent.trim(); } } // Definition let definition = ""; const defDiv = block.querySelector('.prewrap.mb-2'); if (defDiv) { definition = defDiv.textContent.trim(); } // Examples let examples = []; const exListItems = block.querySelectorAll('.termlist-item-examples li'); exListItems.forEach(li => { // Ignore the audio button text (usually inside span elements) const text = Array.from(li.childNodes) .filter(node => node.nodeType === Node.TEXT_NODE) .map(node => node.textContent.trim()) .join(' ') .trim(); if (text) examples.push(text); }); // Image let imageUrl = ""; const img = block.querySelector('.termlist-item-images img'); if (img) { imageUrl = img.getAttribute('data-src') || img.src; if (imageUrl && imageUrl.startsWith('/')) { imageUrl = window.location.origin + imageUrl; } } // Audio (UK and US) let ukAudio = ""; let usAudio = ""; // The structure is usually