/api/code/villagepump/リアルタイム版ScrapCalc/script.js function scrapcalc_commands(){ const commands = []; let count = 0; for(let expr of document.querySelectorAll('.scrapcalc_result')){ expr.remove(); } for(let expr of document.querySelectorAll('.deco-\\=')){ let text = expr.innerText; if(text.match(/=/)){ commands.push(decodeURI(text) + ';'); } else { let id = `scrapcalc_element_id_${count}`; var span = document.createElement('span'); span.id = id; span.classList.add("scrapcalc_result"); expr.parentNode.appendChild(span) expr.classList.add("scrapcalc_exp") expr.style.display = 'none'; commands.push(`document.getElementById("${id}").innerText = ${decodeURI(text)};`); count += 1; } } return commands.join("\n"); }