Skip to content

Instantly share code, notes, and snippets.

@Carlovan
Last active November 10, 2016 10:54
Show Gist options
  • Save Carlovan/fd87039b265dc30f52ee820ef7264830 to your computer and use it in GitHub Desktop.
Save Carlovan/fd87039b265dc30f52ee820ef7264830 to your computer and use it in GitHub Desktop.
Cookie clicker
function calcRatio(){
document.querySelectorAll('.product.unlocked').forEach((n, i) => {
var s = n.querySelector('.ratio');
n.setAttribute('onclick', 'calcRatio()');
if (!s) {
s = document.createElement('span');
s.setAttribute("class", "ratio");
n.querySelector('.price').appendChild(s);
}
var g = Game.ObjectsById[i];
s.innerHTML = ' (' + (g.price / g.storedCps).toFixed(2) + ')';
})
};
setInterval(calcRatio, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment