/* Used to collect words and their definitions from the Swiss German Slängikon page. https://zuri.net/de/zurich/slängikon.htm */ $(document).ready(function() { var output = []; $('h2').each(function() { var heading = $(this).text().trim(); var headingElem = this; // Native DOM element var nextSibling = headingElem.nextSibling; var listText = ''; while (nextSibling) { if (nextSibling.nodeType === 3) { // Text node var text = nextSibling.textContent.trim(); if (text) { listText += text + ' '; } } else if (nextSibling.nodeType === 1 && (nextSibling.tagName === 'HR' || nextSibling.tagName === 'H2')) { break; // Stop at
or next

} nextSibling = nextSibling.nextSibling; } // Process the collected listText if (listText) { var words = listText.split(/ ?\| ?/); // Split by ' | ' or '|' words.forEach(function(word) { word = word.trim(); if (!word) return; // Extract content in parentheses at the end var explanation = ''; var match = word.match(/\s*\(([^)]+)\)$/); if (match) { explanation = match[1].trim(); word = word.replace(/\s*\([^)]+\)$/, '').trim(); } // Remove leading articles 'e ', 'es ', 'en ' word = word.replace(/^(e |es |en |d |de |s )\b/i, ''); // Construct definition: heading + (explanation if present) var definition = heading; if (explanation) { definition += ' (' + explanation + ')'; } // Add to output output.push(word + '\t' + definition); }); } }); // Output the list to console, one word per line if (output.length > 0) { var outputText = output.join('\n'); console.log(outputText); // Copy to clipboard navigator.clipboard.writeText(outputText).then(function() { console.log('Output successfully copied to clipboard.'); }).catch(function(err) { console.error('Failed to copy to clipboard: ', err); console.log('You can manually copy the output from the console above.'); }); } else { console.log('No words found. Please ensure jQuery is loaded and verify the page structure.'); } });