User:GorillaMan/global.js

function createResourceToGemCalculator { var paras = document.getElementsByTagName("p"); var offset = 0; for (var index = 0; index < paras.length; index++) { if (hasClassTest(paras[index], "calc-r2g")) { var form = document.createElement("form"); var input1 = document.createElement("input"); var input2 = document.createElement("input"); var span = document.createElement("span"); form.setAttribute("onSubmit", "return calcResourceToGems(" + offset + ");"); input1.setAttribute("size", "10"); input1.setAttribute("value", "0"); input1.setAttribute("id", "resource_input_" + offset); input2.setAttribute("type", "button"); input2.setAttribute("value", "Calculate Gem Cost"); input2.setAttribute("onclick", "javascript:calcResourceToGems(" + offset + ");"); span.setAttribute("id", "gem_result_" + offset); span.innerHTML = " = 0 gems"; form.appendChild(document.createTextNode("Gold/Elixir: ")); form.appendChild(input1); form.appendChild(input2); form.appendChild(span); paras[index].appendChild(form); offset++; }  }     }