// Update the recipe book UI function updateRecipeBook() if (!recipeListDiv) return; if (recipes.size === 0) recipeListDiv.innerHTML = '<div style="color:#888; padding:8px;">No recipes yet. Combine elements to learn!</div>'; return;
let html = '<table style="width:100%; border-collapse: collapse;">'; for (let [result, [left, right]] of recipes.entries()) html += ` <tr class="ic-recipe-row" data-left="$escapeHtml(left)" data-right="$escapeHtml(right)" style="border-bottom:1px solid #333; cursor:pointer;"> <td style="padding:6px 4px;">$escapeHtml(left)</td> <td style="padding:6px 4px;">+</td> <td style="padding:6px 4px;">$escapeHtml(right)</td> <td style="padding:6px 4px; color:#4caf50;">→ $escapeHtml(result)</td> </tr> `; html += '</table>'; recipeListDiv.innerHTML = html;
// Hook into game's combine function if possible const origCombine = window.combine; if (origCombine) window.combine = function(left, right) const result = origCombine(left, right); if (result && result.name) addRecipeFromCombine(left.name, right.name, result.name); return result; ;
// Hook into the game's internal events if possible (monkeypatch) let originalAddElement = null; if (window.addElement) originalAddElement = window.addElement; window.addElement = function(element, ...args) if (element && element.name) discovered.add(element.name); // Try to infer recipe from last craft const lastCombine = window.lastCombine return originalAddElement.apply(this, [element, ...args]); ;
// Attach click handlers to rows document.querySelectorAll('.ic-recipe-row').forEach(row => row.addEventListener('click', (e) => const left = row.getAttribute('data-left'); const right = row.getAttribute('data-right'); if (left && right) autoCraft(left, right); e.stopPropagation(); ); );