-
-
Save scott-maddox/dadb6c74f3e5db98aad6bbaa71a05302 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 getThings = function(){ | |
var divs = [...document.querySelectorAll("#manufacture__container > div")] | |
var things = divs.map(function(e){ | |
var result = {e}; | |
var spans = [...e.getElementsByTagName("span")] | |
spans.map(function(s){ | |
var str = s.innerText.replace(/[^/.0-9]/g, ''); | |
var a = str.split("/"); | |
var num = +a[0]; | |
var den = +a[1] || 1; | |
result[s.id] = (+num) / (+den) | |
}) | |
if(e.id === "item__spudGun" || e.id === "item__potatoLauncher") result.powerGain *= 1000; | |
var cur_power = +document.querySelector("#watts--total").innerText.replace(/[^0-9]/g, ''); | |
result.score = result.cost * (cur_power + result.powerGain)/result.powerGain; | |
result.name = e.getElementsByClassName("manufacture__name")[0].innerText; | |
return result | |
}) | |
return things | |
} | |
var getFilteredThings = function(){ | |
return getThings().filter(function(e){ return e.cost !== 0 }) | |
} | |
//console.info(getThings()) | |
//console.info(getFilteredThings()) | |
//console.info(getFilteredThings().map(function(e){return e.score.toExponential()})) | |
var highlightBestThing = function(){ | |
var things = getFilteredThings().sort(function(a,b){return a.score - b.score}); | |
var bestThing = things[0]; | |
console.info("highlighting " + bestThing.name); | |
for(var i = 0; i < things.length; i++) { | |
things[i].e.style.color="#fff"; | |
} | |
things[0].e.style.color="#ff0"; | |
} | |
//console.info(highlightBestThing()) | |
var timer = setInterval(highlightBestThing, 500) |
Fixed unaffordable items being ignored. Changed highlight color to yellow.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Cleaned up the code and fixed for latest version of Spaceplan