Last active
May 16, 2017 13:07
-
-
Save thexa4/2da63028a1d8007dedbd0ba9432c8345 to your computer and use it in GitHub Desktop.
For use with spaceplan
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Paste in console | |
var clickBestThing = function(){ | |
var things = [...document.querySelectorAll("#manufacture__container > div")].map(function(e){ | |
var res = {e}; | |
[...e.getElementsByTagName("span")].map(function(s){ | |
res[s.id] = +s.innerText.replace(/[^0-9]/g, '') | |
}) | |
if(e.id === "item__spudGun" || e.id === "item__potatoLauncher") res.powerGain *= 1000; | |
res.score = res.cost * (powerGain + res.powerGain)/res.powerGain; | |
// res.score = res.cost / res.powerGain; | |
// res.score = res.cost / res.spudGain; | |
res.name = e.getElementsByClassName("manufacture__name")[0].innerText; | |
return res | |
}).sort(function(a,b){return a.score - b.score}) | |
window.things = things; | |
var bestThing = things[0]; | |
if(!things[things.length-1].score) bestThing = things[things.length-1] | |
console.info("clicking " + bestThing.name) | |
for(var i = 0; i < things.length; i++) { | |
things[i].e.style.color="#fff"; | |
} | |
things[0].e.style.color="#f00"; | |
} | |
var timer = setInterval(clickBestThing, 500) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks! How can I use this?